Easy life with SSH Configs


If you are ssh'ing constantly to a lot of boxes using long ssh commands with many switches, you are doing it wrong. Make your life easier with the ssh config file (~/.ssh/config)

Host home home.example.com
    HostName home.example.com
    User j
    Port 12345
    LocalForward 45901 localhost:5901
    LocalForward 40080 localhost:80

Now all you need to do is "ssh home" and it will connect using those options. That easy. All the options can be found in ssh_config(5)

Better yet, the Host option can contain wildcards, so you can set common options for sets of domains. I use it extensively when logging in to Amazon EC2 machines.

Host *amazonaws*
    IdentityFile ~/.ssh/your_ec2_key.pem
    User root

Now all you need to do is "ssh blah-1-2-3-4.ec2.amazonaws.blah.com" and it will connect using your EC2 private key as root.

Another great usage is if you constantly vnc in to your home computer remotely through ssh tunnels. Usually you set up a ssh with a local forward, then fire up vnc manually. Well now you can do it in one command.

Host remote
    Hostname home.example.com
    User someuser
    Port 12345

    LocalForward 59999 localhost:5901
    ExifOnForwardFailure yes

    PermitLocalCommand yes
    LocalCOmmand vncviewer localhost:59999 &>2 &

So now you just simply type "ssh remote" and it will set up the tunnel and pop up the vnc window. Enjoy!


Twitter and URL Shortening Services


Lately, all my primary technology news sources have been polluted with articles about Twitter and URL shortening services. A part of my dies inside every time I hear about one of these. I can understand the hype about Twitter, but the only reason there is a hype about URL shortening is because of Twitter.

I have an open suggestion to Twitter that would benefit them, their user base, and hopefully kill the URL Shortening market space in one go. (so it would be one less thing to pollute my daily tech news with).

Solution

Twitter, implement your own shortening service and integrate it with the service. There is #hashtags, and there is @mentions. Using the same convention and use either ! % or ^ to implement URL redirection.

Example

"Hey @person, go check out ^s89n3"

If a user wants to shorten the url http://www.janitha.com, the service would map that url to a code such as "1a2b3c". Now if a user enters ^1a2b3c, it links directly to the original URL (or links to something like http://www.twitter.com/redir/1a2b3c that redirects to the correct place). It's really trivial, everyone and their grandmother is implementing URL Shortening services, so I am sure you can spare a fraction of your millions in funding to implement this simple feature.


Listen to your Feeds


Last night I was wondering how interesting it would be to have your friends Facebook status updates, twitter tweets, and other types of live feeds be read back as speech in real time as they are updated.

A coffee cup later, jFeedSpeak was written. It's a Feed-to-Speech script I wrote in python and it accepts any number of RSS feeds (facebook status updates, twitter, Google news, pretty much any RSS you throw at it). The newest updates are piped in to Festival (Text to Speech engine) which you can listen to (and optionally pynotify that pops up a notification, but I commented that out for compatibility).

The default script uses the Twitter public feed, but it can become really annoying, so I highly suggest you modify and add more personalized feeds to it. Instructions and configuration inside the script. Enjoy!

Download jFeedSpeak


Telephone Number Geocoder


Want to map out a whole bunch of telephone numbers by their location?

Telephone Number GeoCoder

That was my Sunday afternoon project. Inspired by @joshuabaer's tweet looking for such service, decided to implement one just for fun today. Sorting through the data was fun, loads of wget, bash scripts to cut, awk, grep and process, python to mix and match, some php to whip out a interface, and sweet little mysql db to store it all.

It has a resolution per city using area code & prefix (123-123-....), and it turns out the US has a total of 155,972 unique geographically based telephone sectors.

You can feed it a list of phone numbers in any order, or even a chunk of text with phone numbers inside it and it will try it's best to extract all the valid phone numbers. Valid formats include 1231231234, 123-123-1234, (123)123-1234, 123.123.1234, etc... yay for regular expressions.

I need to start using the google maps api more frequently, maybe next weekend project.

Update Dec 4, 2009: The Telmapper was taken down due to Abuse.


A New Captcha


I was tired of seeing the same variety of CAPTCHA systems online that consist mainly of letters and numbers. These have gotten so complex, they are close to impossible for even humans to guess. Since my new site needed a captcha system to stop the comment spam, I decided to write my own captcha just for fun, except instead of letters, using shapes. It's very simple, yet quite effective (no spam comments since I launched, compared to several hundred spam comments with the last wordpress with a conventional captcha system).




The current version uses circles and boxes and prompts the user to enter the count. The shape overlaps and deformations make it pretty hard for a bot to guess (but not impossible). Compared to a using a regular captcha, the biggest strength in rolling your own captcha is that no one would try to create a bot or find a already existing one to break that since the captcha system is rare (such as this one). Security through obscurity in a way. So if you have a big comment spam problem, and have a hour or two to spare, I would highly recommend you create your own captcha variant.

When you are developing your own, make sure to bind the corresponding captcha image to the session, ip, unique key, and what ever else you want and make sure to have a expiration method as well as have a failure threshold to thwart brute force attacks.

My Captcha in Action

Update Dec 4, 2009: I migrated the comment system to Disqus, so this is not available on my site any more. Disqus is taking care of the spam/bot issues for me now on.


Don't Steal My Laptop


So lately I've been hanging out a lot at Coffee Station and on campus using my Laptop. Doing this, one of the biggest annoyances I had was whenever I had to leave the area to get a coffee or something, I risk leaving the Laptop unattended. Using a cable lock every time was annoying, so instead I wrote a anti theft alarm script that utilizes the Laptop's built in accelerometer. Originally it's meant to be used for the HDAPS, or Hard Disk Active Protection System, to detect shock and prevent data corruption, but I will be using it for a different purpose. Here is a demo video...



This is how it works. Whenever I am about to leave the laptop, I start the script which locks the laptop and start the gnome screensaver. Any small bumps or tilting up to 20 degrees of the laptop will produce a small chirp sound where the volume is directly proportional to how tilted it is (so the more you tilt it, the more loud it becomes) as a initial warning to anyone who bumps or laptop or for small movements. Any movement beyond 20 degrees of tilt will start the alarm at the highest volume (and the ThinkPad speakers are Loud). The script monitors the gnome screensaver status, so the only way to stop the alarm or to unarm the system is to log in using the password or a finger swipe which the gnome screensaver.

If you want to get this working on your linux laptop, make sure you have HDAPS on your laptop and Tp_smapi installed. There are other anti theft implementations that use the HDAPS data you can find here, but none of them integrated well with the gnome screensaver or have the initial warning feature. That's all for now, hope you found this useful.

Script Source

Update Nov 8, 2008: A variation of this same script for Kubuntu/KDE written by Colin Verot.


Facebook Face Extractor


A few days ago I was messing around with some face detection libraries when an idea hit me, what better place to look for faces than Facebook! After a few hours and a copious amounts of coffee, I started piling one idea after other until I ended with a rather interesting combination of technologies and data sources.

Before I explain any further, please step back for a second and appreciate the insanity of information stored along with pictures uploaded to Facebook. Not only are the images stored on Facebook's servers, but they are also tagged with who ever is in the image, including their name and the xy coordinates of that person's face on the image.

To make things more interesting, the Facebook API allows very easy access to this crazy database, including the images. For example, Photos.Get can be used to get a list of all the images that are tagged with a certain person, then for each image, you can use Photos.GetTags to get the X and Y coordinates to locate where their face is (FBQL would also work). With this information, you can crop and build a collection of smaller images that only include their face. A simple face detection library such as fdlib can be used to verify that the smaller cropped face images are indeed faces since some people tag incorrect locations.

Now you have a collection of smaller images with just the face. Other than the creepy factor, what other uses can this have? There are face recognition algorithms out there that can build a detailed facial characteristics model for a person provided several images of their face, which in turn can be used in automated face recognition systems to identify people. You see where I am going with this...?


Let me give an example of how scary or interesting an implementation of this can be (depending on who you are). Imagine if someone runs these steps for everyone at an University, they would end up a database of facial models for every person that had an image tagged (and they don't even need to be a member of Facebook since people tag everyone anyways). Now for example, build an iPhone app which can take a picture of anyone in that University, and the system would compare the picture to the facial model database and return who that person is. Or a camera system that identify everyone who walks past it (Remember: Minority Report subway scene with targeted ads). Other uses can be to tag even more images automatically, even on other image databases such as Flickr or Picasa.

Implementations of this technology combination is limitless, yet scary and very disturbing, not to mention the privacy concerns. What's even more interesting is how simple this whole thing is, my implementation was less than 200 lines of php/c/cgi including the facebook API stuff and did everything including verification with fdlib but not the facial recognition (and no I will not post the source for obvious reasons).

I am torn between considering if this is a good or a horrible use of technology: I can see some very interesting and cool uses, but at the same time it can be used in some very unfavorable ways. Just be careful of what information you put online, specially when they are large databases like Facebook and tagging pictures...


Newer Posts

Older Posts

Navigate

Archives