Oct 31

Packaging images in your code

Tech 6 Comments »

Packing up resources can sometimes be a challenge. What if you have a plugin that you want someone to be able to install. Do you make them unpack a set of images/css/… to a certain place?

I recently say a PHP plugin that encapsulated everything it did in the one PHP script. I was wondering where the images were, and then I saw them inline in the PHP code itself!

/**
* Images
*/
$images = array();
$images['subscribed.png'] = "iVBORw0KGgoAAAANSUhEUgAAABUAAAAICAMAAAAhgUThAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAGUExURai0vvP8+20m9Z0AAAACdFJOU/8A5bcwSgAAAE5JREFUeNpiYAQBBhBGAgABxAARZYBgRigPIIBgchAI1cgAEEBwFWDlUNMYAAIIWS3cIAaAAEIyFy7OyAAQQAxIbkDYBhBAcCaKywACDAAgyABfpZamZwAAAABJRU5ErkJggg==";
$images['subthread.png'] = "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAAEF7NTqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACmSURBVHjaYvz//z8DCAAEEBMDFAAEECNMBCCA4CIAAQQXgQGAAGJiQAMAAYSiAiCAGIEYzgMIIBSlAAGEogwggBignP/oGCQOEEAYNiADgADCKwkQQBiOhQGAAGIByzIyosgCFTMCBBBOHQABhFMHQADh1AEQQDh1AAQQTh0AAYRTAh8ACCBEzKBZhY8PEEBMDGQAgAAiSxNAAJGlCSCAyAoIgAADAEniPAbcSIg9AAAAAElFTkSuQmCC";
$images['subthread-open.png'] = "iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAAEF7NTqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAACoSURBVHjaYvz//z8DCAAEEBMDFAAEECNMBCCA4CIAAQQXgQGAAGJiQAMAAYSiAiCAQOg/VOA/QAChKAUIIBRlAAHEAFOCjkHiAAGEYQMyAAggvJIAAYThFBgACCAWsCwj4380dzICBBBOHQABhFMHQADh1AEQQDh1AAQQTh0AAYRTAh8ACCBEzKBZhWE6kjxAADExkAEAAogsTQABRJYmgAAiKyAAAgwA3YE+/1F5tWAAAAAASUVORK5CYII=";
$images['spacer.png'] = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQI12NgYGBgAAAABQABXvMqOgAAAABJRU5ErkJggg==";

if(isset($_GET['image']))
{
header("content-type: image/png");
print base64_decode($images[$_GET['image']]);
exit;
}

I never would have thought to encode my images and output them from my script itself. Oh those crazy PHP guys :)

Oct 28

HTML is not statically typed. It scales ok?

Tech 5 Comments »

I played poker tonight with a bunch of techie-types in San Francisco. It was a fun crowd, and the game went well.

At one point the discussion got to languages, and the age old static versus dynamic language debate got going.

I heard all of the old gems:

I could never build anything large in a non-static language

This always makes me laugh, knowing that several HUGE systems have been built on dynamic languages.

It doesn’t make sense, as you can use discipline to build something large from anything. It is all about building modules and composing these modules. These modules may be packages, classes, etc… or they could be functions and non-OO.

A friend at the table then talked about how it is interesting that HTML is not statically typed, yet it has scaled pretty well. The internet architecture has made this happen. We are loosely coupled and modules (pages/site) are seperated out.

There are definitely pros and cons to the static vs. dynamic debate, but don’t go extreme to one side, and don’t be arragant enough to think that your way is right.

Always assume that some others are building better, larger, more scalable applications that you do… as it is probably and hopefully true :)

Oct 24

Pruning past iTunes podcast content

Ruby, Tech No Comments »

I keep running across the same feature that I wish I had in my applications. As someone who subsribes to a lot of content, I really need to be able to cap the amount in some feeds.

E.g. I want to say “This planet feeds gets a ton of traffic, so just keep a rolling max of 100 so I don’t turn around and see it full with 4000 entries”

This problem is even more important when subscribing to content such as pod/vidcasts. Before I look around, my hard drive is screaming about my podcast directory.

Since iTunes didn’t seem to help me out, I ended up writing a tiny Ruby script that would allow me to nuke any content longer than X weeks. This is far from perfect, as I would like to set it up on a podcast basis. Some podcasts I like to keep around. Others, I don’t really care about, and I only listen to when on long trips and I have exhausted the rest :)

The bulk of the script is simply:

Find.find(PODCAST_DIRECTORY) do |path|
if FileTest.file?(path) && older_than_given_weeks?(path)
puts "Deleting '#{path}' which had the mod time of '#{File.mtime(path)}'"
File.delete(path)
end
end

iTunes, aggregators, please let me setup queue maximums :)

Oct 24

Madison gets WiFi

Tech 7 Comments »

Wow, it even made it to Slashdot. Madison is getting WiFi.

A couple of years ago, I emailed the mayor pointing him to some other cities that had set up a mesh network of WiFi for the city. I thought that Madison was the perfect size city for a similar endeavour.

I was amazed to get a reply right away, talking about how they want to do just this. It got a bit tough, as they had to think about the private sector (this is the US after all ;) and had a few offers to get over, but hopefully it will really get here at some time soon.

I can’t want to do some work by the lakes in the summer, and float around getting access :)

Kudos to the mayor.

Oct 20

Zend PHP Framework, and Eclipse member

PHP, Tech No Comments »

Zend has stepped PHP up to the plate lately. At their conference they just announced the Zend PHP Collaboration Project:

The Zend PHP Collaboration Project is an open source initiative through which the PHP community and Zend’s corporate partners will create an industrial-grade, de facto standard PHP Web application development and deployment environment, said company co-founder and CEO Doron Gerstel.

To begin with they have a web based framework, and then they have tools on top of this, created in the Eclipse foundation.

The heavy hitters at the conference were Marc Andreessen and Rod Smith (of IBM)

Marc came out hitting with “the simplicity of scripting language PHP means it will be more popular than Java for building Web-based applications.

He also said:

“My new company is running a combination of Java and PHP. This is something I get no end of crap about”

The hardest problem for PHP to get over is the stigma.

I hope Zend takes PHP to the next level, gets it into the enterprise, and we see more competition :)

Oct 20

Zend PHP Framework, and Eclipse member

PHP No Comments »

Zend has stepped PHP up to the plate lately. At their conference they just announced the Zend PHP Collaboration Project:

The Zend PHP Collaboration Project is an open source initiative through which the PHP community and Zend’s corporate partners will create an industrial-grade, de facto standard PHP Web application development and deployment environment, said company co-founder and CEO Doron Gerstel.

To begin with they have a web based framework, and then they have tools on top of this, created in the Eclipse foundation.

The heavy hitters at the conference were Marc Andreessen and Rod Smith (of IBM)

Marc came out hitting with “the simplicity of scripting language PHP means it will be more popular than Java for building Web-based applications.

He also said:

“My new company is running a combination of Java and PHP. This is something I get no end of crap about”

The hardest problem for PHP to get over is the stigma.

I hope Zend takes PHP to the next level, gets it into the enterprise, and we see more competition :)

Oct 19

Fake email from mobile device

Tech 2 Comments »

More and more people are emailing from their phone/pda/small device of some kind.

As such, they often have something on the bottom such as:

Sent from my phone; pardon brevity.

This gives you licence to write a very short reply, and not care about grammar as much ;)

So, why not fake it? If you don’t want to say much, add that to the bottom of your email, and Bob’s your uncle! :)

Oct 17

Dumb TV Question Pattern in Britain

British, TV / Movie 2 Comments »

Every tv show over here seems to have a text-in question, where you can win something.

The questions are ridicously dumb though, such as this:

What is the name for the Japanese delicacy of raw fish?

  • Sushi
  • Tandoori
  • Cornish Pasty

Why do they make them so obvious? Because each text message costs money.

TV is already dumb enough, but do you have to keep putting random idiotic question on the screen to make a few bucs. Argh!

Oct 17

The Daily Show makes it to the UK

British, TV / Movie No Comments »

I have been bugging my british friends for ages about The Daily Show, my favourite on TV.

Today I saw a commercial on Channel 4, saying that The Daily show is now on More 4.

So, those brits who have it, watch More 4 for Jon Stewart at his best.

Oct 17

Boycotting Aerolineas Argentina

Travel 15 Comments »

My travel category gets fuller and fuller, but this time the nightmare travel was via my sister-in-law who is studying in Spain, and came to visit us in London.

Let’s set the stage:

She is a student, taking a semester away from her US college, and studying in Spain for a few months with a programme. She has been able to take trips all over europe. Now, she comes to visit London, has a great time, until she tries to get home…

The airline is the argentine: Aerolineas Argentina, and I will refuse to fly them based on their service.

Before issuing a boarding pass, lots of questions come flowing out. Proof of leaving Spain at some point is required. They won’t listen to the facts that:

  • Spanish student id
  • Stamps in her passport

So, because she doesn’t have her PROOF of flight out of Spain, that is months from now, they are giving her a hard time. She ends up calling me, so I can try to get this proof over to her. Several phone calls to the US later, and we do have all of the info (confirmation number etc etc), but couldn’t fax over the hard copy in time for her flight. She has it on her computer of course, but that is back in Spain.

Armed with the confirmation/reservation number, surely they can look it up right? Well, they can see the flight… but not that Madeline is on it. They only had one phone number for Continental and noone was there. “Sorry, nothing we can do”.

They also had an internet connection, and if they would cooperate and let us USE it, they could have logged in to SEE the confirmation number. “This isn’t our concern”.

Explaining that the stamp in the spanish passport allows for free travel in the EU for three months fell on deaf ears too. “We don’t know anything about that”. Remember, she has been travelling all over bloody europe with no problems like this!

As time is running out, they are forcing us to buy ANOTHER ticket, from Spain back to England. This would be a ticket that would NEVER BE USED.

Then we find out that the flight is delayed, and not just delayed for a few minutes, hours and hours.

This would mean that she would miss her last train from Madrid to her university town, so rather than deal with these people, and get stuck in Madrid at 2am, we got a ticket with a nice airline (British Airways) for the next morning, and came back to our hotel.

We also talked to British Airways about what happened, and they were disgusted.

Why these idiots think that they are on a power trip, and wanna-be-INS-officials, well it makes my blood boil.

I never write complaints in, but I feel like I have to do so here. They were the opposite to “service”, and did nothing to help.

Thanks for nothing Aerolineas Argentina, and their Gatwick employees.

(NOTE: This was the short version. It got even worse!)