Twitter account hacked

Twitter SpamFirst off, an apology to those who were annoyed all day today by Twitter spam: I'm sorry, I was asleep (I write better code at night) and didn't know what was going on until I woke up this evening. Not my favourite thing to wake up to!

I do a lot of freelance work with the Twitter API, and someone asked me for a quote on a clone of a Ponzi-style follower train site. Not the kind of apps I build, but it looked slightly more legit than usual and I was foolish to log in to have a look around - that's where the trouble started. The site in question used the pre-oAuth login (as unfortunately most sites still do) which requires giving up your Twitter screen name and password.

As soon as they had it I was locked out of my account due to "too many incorrect password attempts", and didn't recover the account until tonight. The password has been changed and the spam in question deleted. I've learned my lesson, and will only use oAuth credentials in the future - you won't receive any more spam from this account.

Dream

char_marshaI had the strangest dream this morning.

So I'm walking through a grocery store with an umbrella, and randomly I'm approached by a drunk Julia Deakin, who is yelling and slurring at me incomprehensibly. I look down to see what she's pointing at, and five black cats jump out of my umbrella. The topic drifts abruptly from my cats to the Palm Pre, and she offered me a job on the register. Which was a nice of her, but she clearly didn't work in the store.

If you can figure out the symbolism behind this one, the men in white coats should be there any minute.

Human Readable Text Compression

As a Web Service

TweetShrinkTweetShrink, a web service from TRNSFR, uses a database of common instant / text messaging abbreviations to reduce the number of characters in a tweet. It's essentially a human-readable compression algorithm. For example, "Some text to shrink" becomes "sum text 2 shrnk" when passed through their API.

But it doesn't enforce Twitter's 140 character limit, which means it can be used beyond Twitter for whatever you like. Back in March I released the tweetshrink gem for Ruby, and today I've updated it to 0.2 which includes a command line interface.

From the command line

First, make sure you have Ruby and Rubygems installed. On Debian-based operating systems (such as Ubuntu), this goes a little something like

$ sudo apt-get install ruby rubygems

Now install the gem from it's GitHub repository:

$ sudo gem sources -a http://gems.github.com # (only need to do this once)
$ sudo gem install logankoester-tweetshrink

You can use it from the command line like this:

$ echo "Some text to shrink" | tweetshrink
# Or with a file…
$ tweetshrink ./file_to_shrink.txt

From vim

Or, you can integrate it with vim for ultimate text shrinking convenience. Just add the following to your .vimrc:

""""""""""""""""""""""""""""""""""
" Tweetshrink text filter (:tws) "
""""""""""""""""""""""""""""""""""
autocmd BufEnter * vmap ,tws !tweetshrink
autocmd BufEnter * nmap ,tws !!tweetshrink

Now you can shrink a single line by hitting ,tws in Normal mode, or shrink a whole a visual block.

Of course, this is just as easy to integrate with your favorite text editor; I just happen to use vim.

On the Web

When I integrated this feature with my blog & tweet scheduler PingLater.fm, I realized TweetShrink didn't have a favicon. I needed an icon to use for the button, so I created these - feel free to use them for whatever.

PingLater.fm

PingLater.fm - WelcomeI've spent the last couple of days working hard on a new app for managing your web presence.

There is a service called Ping.fm for broadcasting updates to your blogs, Twitter, Facebook, and other social networks all at once, from one place.

This can save you a lot of time if you're trying to manage a brand or keep up with different groups of friends, and it makes it easier to prevent your presence on these sites from becoming stale.

The application I'm calling PingLater.fm takes it one step further. Now you can set up pings to be sent at a specified time in the future. You could schedule a product highlight for each day of the month, release new blog posts while you're off on vacation, or whatever else you want to use a service like this for.

It's free for now while I gather feedback and optimize the code, but free users will eventually be limited to 3 pings scheduled at a time.

I have a number of premium features in mind (RSS posting, image/video, iPhone…) to make it a really indispensable tool  for pro bloggers and internet marketing people.

But we'll get to that. For now, I just want to hear from you. Let me know what I can do to make this useful for you!

Click here to try it out!

Amazon EC2 Cheatsheet

I use Amazon EC2 every day and yet I always forget how to use their command-line tools. Here are a few common scenarios I run into, and their solutions.

Okay, just kidding, there's only one. I'm planning on editing this post over time :-)

Bundling an AMI from a running instance

  1. Use scp to copy your private key (pk-*.pem) to root@yourami:/mnt
  2. Log in as root and bundle the volume
    $ ec2-bundle-vol -d /mnt -k /mnt/pk-*.pem –cert /mnt/cert-*.pem -u YOUR_AWS_ACCOUNT_ID -s 10240

    Now you have several minutes to kill. Click play…

  3. Upload the image to Amazon S3. You may want to do this inside of screen; I had my ssh session time out on me while it was working a couple of times.
    $ s3cmd ls # List all S3 buckets
    $ ec2-upload-bundle -b YOUR_S3_BUCKET -m /mnt/image.manifest.xml
    $ ec2-upload-bundle -b YOUR_S3_BUCKET -m /mnt/image.manifest.xml -a YOUR_ACCESS_KEY -s YOUR_SECRET_ACCESS_KEY
  4. Register the AMI. This is something you need to do even when updating an image that has already been registered.
    $ ec2-register YOUR_S3_BUCKET/image.manifest.xml

    This will return an AMI identifier that can be used to run a new instance.

    $ ec2-run-instances YOUR_AMI_IDENTIFIER

More information on Creating an Image at Amazon


Deploying Sinatra to a sub-URI using Passenger

It's not hard, but it turns out there's a trick to it. I've run into this problem twice now, so I figure it should be documented. This is the solution if your "/" route is resulting in "Not Found" or an Apache directory listing.

You can read more about the problem at Ardekantur's "Phusion, Rack, Sinatra, and sub-domains", but here's my quick solution:

  1. Disable mod_autoindex if it is enabled.
  2. Make sure your RackBaseURI does not have a trailing slash.
  3. Add this before_filter to your Sinatra app:
    before do   request.env['PATH_INFO'] = '/' if request.env['PATH_INFO'].empty? end

I suppose an alternative solution would be feasible using Rack middleware, but this is what I'm using. Thanks to Ryan Funduk for helping me figure this stuff out.

Setting up rTorrent with Firefox

Downloading Elephant's Dream

Being the closest thing we have to a native uTorrent in Linux, I really like Deluge. But, at least for me, it uses a seemingly impossible amount system resources. Since a Bittorrent client is the kind of thing I want to leave running in the background, I needed a lighter alternative.

I don't see any real need for a graphical interface when ultimately all it's doing is moving bits around on a network, so I went with rTorrent. One of the benefits of using command-line software is that you can use SSH and screen to control it over the network… we don't need no fancypants AJAX interface for this!

Part 1 - rTorrent

If you're using Ubuntu, you can get rTorrent from the repositories, like so…

sudo apt-get install rtorrent

Now that you've got the software, you're going to need to configure it. rTorrent looks for a configuration file called .rtorrent.rc in your home directory. Don't panic. Just save the sample as ~/.rtorrent.rc and open it up in your favorite text editor.

You don't need to worry about most of the stuff in this file, but you can if you want to. Here's how I have it set up:

# Maximum and minimum number of peers to connect to per torrent.
# I like to limit this because I'm often connected through cheap
# wireless routers that have trouble with lots of connections.
min_peers = 40
max_peers = 450

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
max_peers_seed = 50

# Maximum number of simultanious uploads per torrent.
max_uploads = 30

# Where do you want your downloads to go?
directory = ~/downloads

# You can put this anywhere you like, but I put it here.
# Remember that you'll have to create this directory
session = ~/.rtorrent/session

# Watch a directory for new torrents, and stop those that have been
# deleted.
# This will be important when we're setting up Firefox.
schedule = watch_directory,5,5,load_start=~/downloads/torrents/*.torrent
schedule = untied_directory,5,5,stop_untied=

# Port range to use for listening.
# Remember if you're connected through a NAT router, you'll
# need to forward these ports.
port_range = 50471-50479

# Enable peer exchange (for torrents not marked private)
peer_exchange = yes

Part 2 - Save Link In Folder

Okay, so you've got rTorrent all set up now, and configured to watch for new *.torrent files in a directory (mine is ~/downloads/torrents/*.torrent). Now let's configure Firefox. There's an extension by Achim Seufert called Save Link In Folder. You'll want to install this.

After your browser restarts, go to Tools > Add-ons > Save Link In Folder > Preferences and add a new folder, like this…

Save Link In Folder - Torrents

Remember - the download directory must be the one you told rTorrent to watch!

Downloading a torrent

Now when you click a torrent link, just save it instead of opening it with Deluge. If rTorrent is running it will notice the new torrent, and get to work! You can even queue up torrents while rTorrent is off, for downloading later.

I'm definitely an rTorrent noob, having just set this up tonight, but so far I like it a lot, and no longer have the performance issues I had using Deluge. This configuration would also be ideal for setting up a seedbox / media center machine, if you set up all your Firefoxes to save torrent files to a network mount on the server.

Links

TweetShrink gem for Ruby

TweetShrink's API is so simple that this gem barely adds anything on top of HTTParty, but here it is.

require 'rubygems' require 'tweetshrink' t = TweetShrink.shrink "One wonders why" # t['difference'] => 4 # t['text'] => "1 wonders y" # t['original_text'] => "One wonders why"

You can get it from my github account, here, or via rubygems like

$ sudo gem install logankoester-tweetshrink

Enjoy.

Installing Linux Mint 6 on your Asus EeePC 901

I was a fan of ubuntu-eee (now known as EasyPeasy) for a long time, but after upgrading to EasyPeasy 1.0 on my 20gb EEE 901 ($379.99) tonight, I've decided it's time to move on, and I'm happy I chose Linux Mint. Here's what I've done so far to get it running great:

Install Linux Mint

Since the EeePC has no optical media drive, you will need a USB flash drive to install Mint. Download the Linux Mint .iso file and use UNetbootin to burn it to your USB disk, then plug it into your Eee.

Turn on the machine and hit F2 to enter the BIOS setup. Set the boot priority to try the USB disk first. You may also want to make sure the webcam/bluetooth is turned on, while you're here. Save your changes and reboot, and Mint will guide you through the rest of the installation.

When it asks you how you want to partition your disk, choose Guided - use entire disk and let it use the larger of the two SSDs.

Install the EeePC kernel

As usual with Linux installations, most of your hardware will work from the get-go, but not everything. The first thing you'll want to do is get the wireless card working. Plug in an ethernet cable, and then follow these instructions. I recommend the lean kernel, and uninstalling the generic one since it will just be wasting precious disk space.

Enable Desktop Effects

Mint makes this easy for you by taking care of installing the correct drivers for your video card. All you should need to do is turn Compiz on in Preferences > Appearance > Desktop Effects.

Enabling Desktop Effects in GNOME

Allow tall windows to move past the top of the screen

Sooner or later you're going to run into a window that is too tall to display on the 9" screen, and cannot be resized. The solution is to open up a terminal and run this command:

$ gconftool-2 --set /apps/compiz/plugins/move/allscreens/options/constrain_y --type bool 0

This will allow you to move these windows past the top of the screen (use ALT+Drag anywhere in the window. There are a number of other useful gconftool hacks on Ubuntu's EeePC page.

Create $HOME/bin directory

You're going to want a place to store little scripts and tools where they can be executed on the command line.

$ mkdir ~/bin

Now add it to your PATH so bash can find it. Open up your ~/.bashrc file and append

if [ -d ~/bin ] ; then
  PATH=~/bin:"${PATH}"
fi

Make the LCD ultra bright!

This hack is really cool. I found it on the EasyPeasy wiki. Create a new file called ultra-bright in $HOME/bin and paste in this line, then save.

sudo setpci -s 00:02.1 f4.b=ff

You will need to make it executable, so

$ chmod +x ~/bin/ultra-bright

Now you can run

$ ultra-bright

to turn on the extra brightness, and use the bright/dim function keys to reset it. If you're like me, you'll want the extra brightness turned on all the time, so go ahead and create an entry for it in Preferences > Sessions.

Making the screen ultra bright when you log in

Enable the WiFi / Bluetooth / webcam toggle and performance tuner

For this you'll need a package called eee-control. You've already installed the Eee kernel, so this package should be available to you from the repository you added to your Software Sources.

$ sudo apt-get install eee-control

Alternatively, you can download the Ubuntu package from the website.

Now you can find this nifty utility in your Administration menu. Unless you need the extra battery life, I recommend setting performance to "super". To make use of your webcam, install the cheese and/or skype packages.

Make sure text is being rendered crystal clear

Open Preferences > Appearance > Fonts and select "Subpixel smoothing (LCDs)". Then click Details… and set Hinting to "Full". If you're like me you absolutely hate Ubuntu's default monospace font. I prefer Terminus. To switch, install the xfonts-terminus package and make it the default Fixed Width font.

Boost GNOME Performance with /etc/hosts

Following this guide will help improve your system performance, and it takes about 2 seconds.

Installing Avant Window Navigator

AWN is similar to the Dock on Mac OS X.

$ sudo apt-get install avant-window-navigator

Right-click the panel at the bottom of your screen and check "Allow Panel to be Moved". Drag it to the top of your screen, right-click and lock it again. Now launch Accessories > Avant Window Navigator. It's kind of ugly and huge by default, but we can fix that.

Right-click on AWN and click Preferences. Turn on "Auto hide bar when not in use", then switch to the Bar Appearance tab and change Bar Height to something more reasonable, like 32.

Now you'll want to get rid of the Window List at the top of the screen. Right-click on it and select "Remove from Panel". Gone! Now there is lots of room for program shortcuts and silly panel applets.

That's it!

You now have a usable OS on your Asus EeePC, which means you are both cooler and more attractive than every other clown with a clunky Xandros-based netbook. Thanks for following my guide. Let me know in the comments section how your installation experience went and if you have any other EEE tricks worth sharing.

I'm back!

Well, almost. I haven't gotten this Wordpress installation completely setup yet and most of the pages are just stubs still, but it's a start. One of my goals for 2009 is to start blogging actively again. I will mostly be writing about my experience as a freelance web hack(er), with an emphasis on "How I solved #{this}" and "How to do #{that}"-type articles on Ruby, Linux and some occasional PHP randomness.