continue reading hover preload topbar hover preload widget hover preload

Ubuntu, Node and Heroku

Categories: Node.js, Open Source, Software, Web Development  |   No Comments

I recently started playing with Node.js, and while I can play locally just fine, I wanted to make sure I had a place to host once I had something worth hosting. Enter Heroku. Why? Because it’s free to host until you draw some real traffic, it has a really cool addon service and I knew other people using it so I could turn to them if I had problems.

In order to get your application on their service, you need to install their command line tool, which requires Ruby. No problem, just install it all with apt-get and you’re good to go, right? Short answer, yes. Long answer, No. You’ll be using an unsupported version (the version of ruby in the Ubuntu repos is aged), so while it might work now, it may not in the future. If you do like I did, you’ll also end up with 1.8 and 1.9 on your machine, and while that didn’t cause any problems, it seemed silly.

Poking around, I found this article which lays out how to use RVM to both install a newer version of Ruby as well as easily update it in the future. So, here’s the whole shebang:

Serving Files in Internet Explorer over HTTPS

Categories: Computers & Technology, PHP, Software, Web Development  |   No Comments

I recently came across a problem where serving a file to Internet Explorer would result in the following error message.

This affected IE6, IE7 and IE8 in my testing. The way I was serving the file was through PHP via readfile. Before sending the contents of the file, I was, of course, setting some header parameters so that the browser would handle the file and the user wouldn’t just see some binary garbage on their screen. In my case, I was serving a PDF file that was being generated server-side and sent to the client. The basic header parameters are as follows:

// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called your_file.pdf
header('Content-Disposition: attachment; filename="your_file.pdf"');
// declare Files Size here (for the sake of peoples sanity, please add this
header('Content-Length: '.filesize($filename));

This works just fine in most situations, but once you introduce a secure connection, IE fails with the above error. Of course, like most IE problems, this doesn’t happen in any other browser. Ugh.

Samsung X360 Backlight Control with Ubuntu

Categories: Computers & Technology, Hardware, Linux, Open Source, Software  |   No Comments

I recently send my Samsung X360 laptop to the shop. The bearing on the fan had gone bad so I sent it in for warranty replacement. Before I sent it, I thought I would wipe out all my data since a lot of it was work-related and I didn’t need that information getting out, plus I didn’t want to confuse the poor tech with Linux.

When I got it back, I immediately installed Ubuntu’s most current version, 9.10 (Karmic Koala). I was really impressed with it; even more-so than with 9.04 in fact. But I ran in to a problem when I was setting it all up; I couldn’t get the backlight adjustment to work.

Living with PulseAudio via PulseAudio Device Chooser

Categories: Computers & Technology, Hardware, Linux, Open Source, Software, Usability  |   No Comments

Telecommuting is a pretty sweet gig with a good number of benefits. To name a few, while I’m working I can:

  • Toss some laundry in the machine
  • Start my lunch and work while it cooks
  • Sign for packages when they are delivered

And that’s just the tip of the iceberg. However, to make telecommuting possible, there are some technologies I simply MST have working. VPN is a big one, so I can get at the computers back in the office. SSH and FTP access is important to manage servers and files. And of course, I need to communicate with people; for that, we use AIM and Skype. Up until recently, it’s been enough for me to use my Nokia N800 to make my calls back to the office. It’s no good for chatting with video though, so I needed to set it up on my desktop with my camera and, preferably, my headset.

Simple enough task really; both my Logitech webcam and Plantronics headset work out of the box with Ubuntu (at least in 9.04) with nearly zero configuration required. I just plug them in, tweak Skype quickly and I’m up and running. However, with the addition of PulseAudio in the more recent version of Ubuntu, this became a little trickier.

Asynchronous PHP

Categories: PHP, Software, Web Development  |   No Comments

I needed to “asynchronous PHP” recently and it took me a little while to find the solution. What my script basically does is generate a PDF file for the user to download based on some parameters they have chosen. The problem was, the PDF generate take a while and during that time I needed to show the user a screen explaining that the file was being generated, which would also show the download link once the generation was complete. My setup is as follows:

generate.php

This script is where the user is sent when they click “download” on the parameter choice page. This is where the asynchronous magic has to happen. From here, the user is immediately sent to download.php.

download.php

This script gives the user either a “please wait” message of a “click here to download” message, depending on where the target PDF has been generated yet.

My problem was, even though was added the header redirect code (shown below) to generate.php, the browser would still wait for the PDF to be generated before sending the user to download.php. In other words, it was only synchronous PHP, which didn’t help me at all.

header("Location: download.php");

Thanks to this comment on php.net, I was able to make it work! Basically, you need to tell the browser that you are done sending it data, even though the PHP script will keep executing. Code below:

//redirects the browser to the new url, but continues processing in the background
function redirect_and_continue($sURL) {
header( "Location: ".$sURL );
ob_end_clean();
header("Connection: close");
ignore_user_abort();
ob_start();
header("Content-Length: 0");
ob_end_flush();
flush();
session_write_close();
}

So, the user is sent to generate.php, which immediately calls redirect_and_continue(‘download.php’), redirecting the user to download.php while still continuing to execute generate.php (and make the PDF file). Once the user is at download.php, the script checks for the existence of the generated PDF file (as indicated by the filename sent through the session) and uses a meta refresh tag in the HTML to keep reloading download.php. Once the PDF file exists, it provides the user with a link to the PDF file for download.

Ubuntu 64-bit, Firefox and Flash

Categories: Computers & Technology, Linux, Software  |   No Comments

OK, so you have this sweet new computer (much like myself) running 64-bit Ubuntu like a champ. Except for one thing; Flash elements on webpages in keep flaking out. That is, from time to time, instead of seeing the Flash content, you see a grey box that doesn’t do anything. It just sits there, mocking you, until you close and re-open either the tab, or in most cases, the browser itself.

I had this happen in both Firefox and Opera. As it turns out, the problem is related to the machine running a 32-bit version of flash with a 64-bit version of the browser. There are 2 ways to fix this: run a 32-bit browser or run 64-bit flash. But, why would you run a 32-bit browser on your sweet 64-bit machine? Well, because there isn’t a 64-bit version of flash… or at least, there wasn’t until recently.

I was tired of this problem so I hit Google and looked for a solution. Sure enough, I found one! Now, I will warn you that the 64-bit Flash is still in Alpha, but i’ve been running it for a few weeks now without any problems. Here’s how you can too.

How NOT to Sell MP3s

Categories: Computers & Technology, Linux, Software, Usability  |   Comments(4)

I recently came across the band 3 on last.fm and absolutely love them. I managed to find all of their albums via torrents, but I thought I would actually buy their stuff since they aren’t on an RIAA label. Their website didn’t help at all and CDBaby didn’t have any of their stuff. I was about to give up when I thought I’d give Amazon a try. Turns out, it was a good idea; Amazon had all of their albums available for sale. But, that’s also where the problem came in.

Remote Backups with Amazon’s S3

Categories: Computers & Technology, Linux, Open Source, Software  |   Comments(2)

Recently, my SATA controller on my RAID box failed, silently corrupting my entire array. Fun stuff, I assure you. Luckily, I had backed up the array about a month before the failure and was keeping a nightly rsync running. I had a few things that weren’t included in the rsync backup, but I didn’t really lose much data. So, again, backups saved my ass!

But, I’ve been aware for a while that regardless of how much I back up, I still have everything in one place. If there were a fire or a robbery, I’d be completely SOL. This fact has prompted me to look for some free or very low cost online file storage services. Most of the ones I found required you to run their software for them to work. This wasn’t very desirable for several reasons, the most important being that I run Linux and most of the services didn’t have a Linux client to use. But even more than that, I wanted to be the one in change of the backups, something that would allow me to just set up a cron job that would encrypt my data and ideally use rsync (via this script) to send that data. Unfortunately, I still haven’t found that, but I did find service that is both cheap and easy to use; Amazon’s Simple Storage Service!

Fallout 3 Terminal Hacker

Categories: Games, Javascript, Software  |   No Comments

I recently started playing the game Fallout 3 a little more and I came across a terminal I could actually attempt to hack. After a few failed attempts at it, I thought I would poke around on the Internet and see if anyone had any guides for hacking the things. Instead, I found this online terminal hacker, among others (this was the best one though). I thought, “man, that’s pretty slick, but I wish I has something that I could run locally in the event my Internet was down.” I poked around online a little and found a bunch of people claiming to be prepping downloadable, standalone versions, but nobody had yet delivered. Then I thought, “I bet I could write me own,” and that’s exactly what I did.

The rules for hacking the terminals are:

  • You get 4 tries, after which you can never try again
  • If you exit before the 4 tries are up, your available tries reset to 4, but so does the puzzle
  • For each word you pick, you will be told how many matching letters you got
  • That count is how many matching letters there are in the SAME position of the correct word

Originally, I was going to write it in Python. That way I could potentially execute it from anywhere I could install the Python interpreter and it would give me a reason to dive in to Python. Then I decided I wanted it done quick, and in an even more portable way; as a raw HTML page. So, I decided to write my version in Javascript, and here it is!

I used the one over at mediumexposure.com as a benchmark and honed mine down a bit (I didn’t catch that last rule when I was playing the game, which is why I could never figure the puzzles out). I will admit, mine isn’t as smart as his since it doesn’t take past guesses and matches into account, only the most recent guess and the remaining list of possible words. So, there’s a chance mine won’t guess correctly in the 4 attempts, but in the handful of tests I ran, I always managed to get it.

Now, I know what you might be thinking. “Hey, this is just another online file, how is this portable? How can I run it from my machine?!” Simple, save the html file to your computer and open it locally. All of the magic happens in the Javascript code (which I commented so you can follow along), which will run from your machine without the need for any extrernal processing or server. Go ahead, give it a spin and be sure let me know what you think in the comments. It’s a work in progress, so when I make it smarter, I’ll update the file and post again. Enjoy!

Building a Better CAPTCHA

Categories: Computers & Technology, Software, Usability, Web Development  |   No Comments

CAPTCHAs can be good for stopping SPAM, but the last thing most of them are are usable. Don’t take my word for it, it’s a fact. One of the coolest ideas I ever saw was a HotOrNot mashup where you had to pick the three best looking ladies to prove you are a human. It was both usable and easy for a normal person, like my Grandparents, to use. That’s pretty unique and hard to come by, and that’s why I liked it.

One of the other easier CAPTCHAs I’ve used at work is a little dynamic images that asks you to do a little simple math. It’s an idea I saw on another site so I thought I would give it a try and it’s been extremely effective despite it’s ease of being broken. Surprisingly, it has completely stopped all SPAM coming through our contact form.

Another one I tried, much less effectively, is a colored word and a dropdown with a number of colors to choose from. It literally asks “What color is this text?” and offers a number of possibilities. This, however, was not effective for more than a week or so. The form still sees about one or two SPAM messages a day, which is especially strange because it’s a site that sees far less traffic. I think if I added more colors that weren’t even valid selections and changed the order it might be more effective, but I still need to find something better.

I’m thinking a system that would show three images and ask which one doesn’t belong could be usable, but it’s a little more difficult to implement; where do I get the images, how do I randomize the data, etc. I really like the HotOrNot CAPTCHA because the images always change and all of the images and data are crowdsourced, nothing for you to manage.

So, what can one do? Sadly, I don’t have an answer, but there is a lot of work being done on the topic. I think I need to just keep looking and mull this all over for a bit. We’ll see what I can find or come up with.