August 15th, 2007

Satire at it’s best

Posted by Jeremy2 in General Musings / Rants

I’ve just come across the company that does the Demotivators again (and purchased a couple of shirts), and they also have some video/audio podcasts that are definitely worth checking out. It’s entitled: Corporate Spin. There is one in particular that I like, which is called “Principles of Organizational Storytelling” which does not only apply to big companies, but to many smaller companies that I have worked for as well. If you don’t get too sick thinking about how your previous (or current) employers have mistreated you, it will probably make you laugh.

Edit: Wow, two in one day. There’s also the ADD list for the programmers. My personal favorite is in the comments: The decapitated chicken method.

August 9th, 2007

Changing an Internet Explorer input field type via JavaScript

Posted by Jeremy2 in Browser Bugs

Ok, this is a problem that has vexed JavaScript programmers for a long time, and frankly most of the solutions for this problem are rather convoluted. At first, I had written a helper function to determine whether or not Internet Explorer was being used, and then I figured out a better way to do things. Here is an example:


var file_input = document.createElement('input');
file_input.type = 'file'; // Works in everything EXCEPT for Internet Exploder
file_input.setAttribute('type', 'file'); // Works for everything I have tried it in so far.

So there. One less nightmare that you have to deal with when coding in JavaScript.

June 22nd, 2007

Google Finds Sites in a new way

Posted by Jeremy2 in General Musings / Rants

It seems that Google is now looking up site records themselves or something, because I’ve created a couple of sites lately, and they pull up within the Google index. They do this despite the fact that I have not submitted them to any search engines and have not linked to them from any other site. I’ve looked up the same sites in Yahoo! and MSN, and they are not there at all. I’m starting to think that Google is lowering the bar in who gets indexed, but I am sure that they are keeping it high for those who wish to get a top ranking.

–Update:–

It seems that if Google finds a piece of text (not necessarily a link) that has your URL, then it will index the site. That’s the only conclusion that I can come up with so far, as I have found text with my URLs in them on Google.

June 16th, 2007

Comparison Problem in Ruby

Posted by Jeremy2 in General Musings / Rants

For the past few days I have immersed myself in Ruby on Rails, and for the most part I have been loving every minute of it. However, there was a problem I was having in my code that was driving me nuts. I think I spent nearly four hours on it until I figured out what the problem was, exactly. I had the following bit of code in my model:


def add_attribute_group (the_id)
current_attribute_groups.each do |v|
found = v.attribute_group_id == the_id
break if found
end
if !found && grp = AttributeGroup.find(the_id)
iag = ItemAttributeGroup.new({:attribute_group => grp, :item => self})
current_attribute_groups < < iag
end
end

Rails defines the foreign key ID (in this case attribute_group_id) as a string rather than a number, and so if you try to do a comparison to a number, this will not work! I’ve been spoiled by PHP which treats 3 and “3″ as the same thing. For instance:


$a = '3';
$b = 3;
$a == $b ; //This will return true

However it appears in Ruby:

a = 3
b = '3'
a == b #This will return false

I had to amend this line:

found = v.attribute_group_id == the_id

… to read like this:

found = v.attribute_group_id.to_i == the_id

Next Page »