A A

The Gmail Captcha is Optional

Tue, Jun 16, 2009

0 Comments

When you try to login with bad credentials, Gmail gives you a captcha to fill in before your next login attempt. Not only does this captcha appear randomly (keep putting in the wrong username and it will sometimes appear, sometimes not) (update: now it appears to be more consistent), but it’s also optional*. Just put in your correct username and password, ignoring the captcha, and it will log you in.

I probably discovered this out of frustration, but for the past few months (or years) I thought it was something we all knew until I saw one of my friend’s enter the captcha value. I never actually stopped to think about why a captcha would be “optional” – it’s ridiculous, and I’m probably overlooking an obvious point to this.

Enter the correct name/pass and hit login

Enter the correct name/pass and hit login

Seemingly random captcha

Seemingly random captcha

* I’m not sure why, but some people are saying that they cannot login without entering the captcha. I’ve tried on Swiftweasel and Firefox 3.x/Opera 9.x and 10/Konqueror/Chrome on Linux, and on Safari on the Mac, and have never needed to enter the captcha.

Also worth mentioning, a lot of forms you get when you try to download something are optional. For example, if you try to download Mimer SQL, it gives you this form: http://developer.mimer.com/downloads/downloads_licens.tml?id=528 but you can just scroll down and hit the download button without putting any info in.

Bash Tips for Power Users

Wed, Jun 10, 2009

1 Comment

Every Geek site needs an obligatory Bash Tips post

Copy Files Securely Between Two Machines

I used to always forget the syntax for this, until I realized that the syntax is exactly like the standard cp command. In fact, you can copy files like you normally would using scp, on your local machine. The following are equivalent:

$ cp file file.orig
$ scp file file.orig

Where they differ is, scp lets you copy files over a network, through SSH. Here’s an example:

$ scp contents.txt silver@ssh.domain.com:/tmp

This will copy local file contents.txt to /tmp on the remote machine ssh.domain.com, as user silver. Here are some more examples:

$ scp draft.pdf ssh.domain.com:

(copy draft.pdf to my home dir on remote machine. username is implied to be the same locally and remotely.)

$ scp swine.jpg rex@ssh.domain.com

(read: This will copy swine.jpg to local machine as a file named rex@ssh.domain.com. To make it go remote, append a : to the address, like above)

scp supports, among other things, compression (-C) and recursive copying of directories (-r).

$ scp -rC code/ ssh.domain.com:/archive/code_02032009

Trying to copy to a directory you don’t have permission to (/usr etc) will fail.

Don’t Get Lost Jumping To and Fro Between Directories

You can use cd - to jump to the previous (NOT parent) dir. For example:

kiwi@localhost: ~ $ cd /usr/local/share
kiwi@localhost: /usr/local/share $ cd -
/home/kiwi
kiwi@localhost: ~ $ cd -
/usr/local/share
kiwi@localhost: /usr/local/share $

Another way is using pushd/popd – A Last In First Out (LIFO) stack of dirs.

kiwi@localhost: ~ $ pushd /usr/local/share/
/usr/local/share ~

pushd is like cd but keeps note of the current dir before cd’ing into a new one. The stack of dirs is listed every time you invoke pushd (the “/usr/local/share ~” output you see above.)

kiwi@localhost: /usr/local/share $ pushd /
/ /usr/local/share ~

Stack is ordered left to right, latest push first. If we pop the first dir off:

kiwi@localhost: / $ popd
/usr/local/share /tmp ~
kiwi@localhost: /usr/local/share $

We’re back in the share dir. We can keep popping until there’s nothing left (throws an error):

kiwi@localhost: /usr/local/share $ popd
/tmp ~
kiwi@localhost: /tmp $ pushd /lib
/lib /tmp ~
kiwi@localhost: /lib $ popd
/tmp ~
kiwi@localhost: /tmp $ popd
~
kiwi@localhost: ~ $ popd
bash: popd: directory stack empty

Working with Long Lines

No need for more Bash shortcut cheat sheets, but here are some useful ones to help you work with long lines.

You can jump to the start & end of a line using CTRL+a & CTRL+e respectively. Example (* is the cursor):

kiwi@localhost: ~ $ echo al the ducks are swimming in the w*

and you want to fix the first word. You can hop to the beginning of the line with CTRL+a:

kiwi@localhost: ~ $ *echo al the ducks are swimming in the w

and now you can jump to the end of the misspelled word “al” using CTRL+Right twice to correct it:

kiwi@localhost: ~ $ echo all*the ducks are swimming in the w

Now ctrl+e to jump to the end of line:

kiwi@localhost: ~ $ echo all the ducks are swimming in the w*

Instead of backspacing every character, use ALT+Backspace to backspace entire words. You can also delete all or part of a line using CTRL+u combo. It deletes everything before the cursor. Likewise, CTRL+k wipes out everything after the cursor. I’ve developed a habit of using CTRL+e CTRL+k to delete lines.

Bash has a lot of ALT commands that let you move and manipulate words. ALT+l and ALT+u will make a word in front of the cursor lowercase or uppercase, for example. A neat one I don’t think I ever used is ALT+\ It pulls everything after the cursor left to the first non-whitespace character. Here’s an example, * is the cursor:

BEFORE:

$ my     spacebar is    *sticky

AFTER (ALT+\):

$ my     spacebar issticky

Avoid Retyping Commands & Arguments

ESC + . is very useful. Escape followed by a period will output the argument you sent to your last Bash command. Command calls themselves are outputted if they were invoked without any arguments (popd, ls, etc).

Example, unzipping a file and moving the archive to /tmp:

$ unzip archive-with-a-long-ambiguous-name-03092009-5960-1.2.5.zip
$ mv archive-with-a-long-ambiguous-name-03092009-5960-1.2.5.zip /tmp

In the mv command, the archive name was outputted by pressing ESC+. (full command being mv (ESC+.) /tmp) There was no need to type the long archive name twice.

The argument is taken from your bash history. You can keep invoking ESC+. to cycle back through all your recent command arguments. (history -c to clear)

Try not to forget this; You’ll naturally find plenty of uses for it.

Another way to avoid re-typing commands is CTRL+R. It will initiate a search of your command history. Begin typing, and watch Bash try to complete your command from previous ones you entered.

Command Getting Too Big? Send it to your Editor

Sometimes you begin writing what you think will be a simple command, only to realize that it has grown too complex for the command line, and you wish you were in your text editor.

First make sure your default editor is set. This is either in $EDITOR (export EDITOR=/usr/local/bin/vim) or elsewhere depending on the distro.

Use “fc” to open the last executed command in your editor:

ls -paul --sort=size
... ls output ...
fc

Now the ls line will be open in your editor. But what if you hadn’t executed the command yet? No problem. You’re sending off an email, but quickly realize that the command line isn’t ideal for everything:

echo -e "Dear Santa, \n\n\tIt has become evident that your fat ass is contributing to Global Warming, primarily due to the large quantity of coal you distribute annually. We hereby

No matter where you are on the line, hit CTRL+x, CTRL+e to invoke your editor, which now contains what you were typing on the cmd line.

I always find myself wanting to finish a command in vim, but unwilling to type the first few lines over, especially when I’m trying to write a for loop or any ugly multiline Bash code.

IMPORTANT: Whatever you type in your editor is executed automatically after you quit the editor.
(more…)

Do You Keep Old Programming Books?

Mon, Jun 1, 2009

0 Comments

Photo by ailatan (flickr)

Photo by ailatan (flickr)

I knew HTML and learned ActionScript (actually ActionScript wasn’t out yet. Flash only had basic scripting support) , and around 1999 I wanted to learn Javascript. I ended up getting a book on Java, thinking it was Javascript. It didn’t take more than a day to figure out they’re completely different languages, but for some reason, I kept the book anyway. $30 was a lot of money at the time. I could of bought a used Playstation game, or saved it towards what would become the greatest console of all time, released 9/9/99. But – the book will be useful eventually, I told myself, and with that, on my bookshelf it went.

Today I walked by my bookshelf and there it was: Teach Yourself Java. The last time I opened this book was the day after I bought it, sometime in 1999. Even if I keep it, if I’d like to learn Java now, I would buy a new book anyway.

A lot of us keep books. Seeing our library physically grow feels good, even if we haven’t read most of the books in it, because we will eventually, right? Keeping reference books is one thing (though I never use mine, what with cheat and all) but most books should be traded or given away. Technical books especially, not only because they’re expensive, but because unlike novels and most other types of books, they become obsolete. But unless you seriously plan on re-reading them, even books that are cheap and timeless should be traded or given away.

Who doesn’t love a book fair? or going through a big box of books in a garage sale? If we all horde books, who would keep this circle going? So what can you do with your old books instead?
(more…)

Calculate Your GPA Using this Bash Script

Thu, May 21, 2009

0 Comments

This Bash script is used to calculate your Grade Point Average (GPA) on the command line. Usage might not be intuitive. Please see the usage function or just run the script without passing it any arguments.

The gval function should be edited to reflect your own region or university. It has been written and tested on Bash 3.2.48.

#!/bin/sh
#
# Bash GPA calculator
#
# Isam | r0cketjump@yahoo.com | biodegradablegeek.com
# 05/21/2009 - Just another 4 AM project

function usage {
  echo -e "\nBASH GPA Calculator"
  echo
  echo -e "\tAccepts an even # of arguments in the form of C G C G C G ..."
  echo -e "\t (C = number of credits, G = grade for the course)"
  echo
  echo -e "\tExample: You got a B+ in a 4 credit course, "
  echo -e "\t         an A in a 3 credit course, etc.."
  echo
  echo -e "\tUSAGE: $0 4 B+ 3 A 3 F 3 B-"
  echo
  echo "Acceptable grades are A B C D F WU (eq to F)"
  echo
}

function calc {
  echo `echo "scale=3; $1" | bc`
}

function gval {
  grade=`echo "$1" | tr [a-z] [A-Z]`
  case $grade in
    A+ ) echo '4.3';;
    A ) echo '4';;
    A- ) echo '3.7';;

    B+ ) echo '3.3';;
    B ) echo '3.00';;
    B- ) echo '2.7';;

    C+ ) echo '2.3';;
    C ) echo '2.0';;
    C- ) echo '1.7';;

    D+ ) echo '1.3';;
    D ) echo '1.0';;
    D- ) echo '0.7';;

    F ) echo '0';;
    WF ) echo '0';;
    WU ) echo '0';;
  esac
}

# check # of arguments. is it even?
let MOD=$#%2
if [ ! $MOD -eq 0 ]; then
  usage
  exit
elif [ $# -eq 0 ]; then
  usage
  exit
fi

args=($@)
n=${#args[@]}

points=0
credits=0

for ((i=0;i<$n-1;i+=2)); do
  k=${i}

  creds=${args[$k]}
  cgrade=${args[$k+1]}

  # convert cgrade (C-) to a number
  grade=`gval $cgrade`
  pts=`calc $grade*$creds`

  echo "$creds * $cgrade ($grade) = $pts"

  points=`calc $points+$pts`
  credits=`calc $credits+$creds`
done

gpa=`calc $points/$credits`
echo "------------"
echo "Total points  = $points"
echo "Total credits = $credits"
echo "------------"
echo "** GPA (pts/crd) = $gpa"
echo "------------"

(Script uses bc as the calculator. Change that in the calc function if you need to.)

I’ll never get used to Bash’s ugly ass syntax. … esac?

How to Block AIM’s Annoying ‘AOL System Msg’ in Pidgin

Fri, May 1, 2009

3 Comments

The following plugin for Pidgin will block the incredibly annoying and useless notifications from AOLSystemMsg on AIM.

“AOL System Msg: Your screen name (mrEman) is now signed into AOL(R) Instant Messenger (TM) in 2 locations. Click here for more information.”

To use, paste code in file, save file as blockaolsystemmsg.pl in ~/.purple/plugins/ and then open (or re-open) Pidgin and go to Tools -> Plugins (or press CTRL+U), and enable “Block AOLSystemMsg.” That should be it!

If you’re having any trouble, try going to Help -> Debug to open up Pidgin’s debug console.

#!/usr/bin/perl
# BlockAOLSystemMsg plugin tested on Pidgin 2.5.5. Put in ~/.purple/plugins/ and enable
use Purple;
our $target = 'AOL System Msg'; # case-insensitive
our $plugin_name = 'Block AOLSystemMsg'; 

%PLUGIN_INFO = (
  perl_api_version => 2,
  name => $plugin_name,
  version => "0.1",
  summary => "Blocks the screen name 'AOL System Msg'",
  description => "Ignore annoying 'your SN has signed on at 2 locations' AIM message",
  author => "Isam ",
  url => "http://biodegradablegeek.com",
  load => "plugin_load",
  unload => "plugin_unload"
);

sub loginfo { Purple::Debug::info($plugin_name, " @_\n"); }
sub minimize {
  my $r = lc($_[0]);
  $r =~ s/ //g;
  return $r;
}

sub plugin_init { return %PLUGIN_INFO; }

sub plugin_load {
  my $plugin = shift;
  $target = minimize($target);
  loginfo("Sight set on '$target'");
  Purple::Signal::connect(Purple::Conversations::get_handle(),
                          'receiving-im-msg', $plugin, \&callback, '');
}

sub plugin_unload {
  my $plugin = shift;
  loginfo('Block AOLSystemMsg Unloaded.');
}

sub callback {
  my ($acc, $sender, $msg, $flags) = @_;
  if (minimize($sender) eq $target) {
    loginfo("(BLOCKED) <$sender> $msg");
    return 1
  };
}

4 Do-It-Yourself Whiteboard Alternatives

Mon, Apr 13, 2009

0 Comments

post it note wall by rainbowcookee 300x225 4 Do It Yourself Whiteboard Alternatives
Whiteboards are as useful as they are overpriced. I built one using tileboard (the thing they use in bathrooms), and I highly recommend making/buying one. It took me awhile to find tileboard in my area. In case anyone has the same problem, here are 4 alternatives I considered:

They are not in any specific order.

Glass or Plexiglas

Anything Expo markers can write on may be used as a board surface. This means a piece of glass, or acrylic glass (Plexiglas), placed over a bright white surface it (i.e., a wall or table). Glass actually works pretty well in terms of eligibility and clean up, but it’s heavy, has sharp edges and cannot be drilled into (easily). It’s also not cheap.

Plexiglas works well, but I heard some dry erase Expo markers have problems coming off. Research this before trying Plexiglas. Never use Acetone to clean Plexiglas (or any plastic).

Plexiglas might be a hassle to cut. Sawing at a high speed, be it power or manual, might cause the edge to melt and stick back together between each cut. It’s usually cut underwater ( don’t try putting a power saw in your bathtub).

What I did was use a regular hack saw, and had my friend shoot the area I was sawing with a water gun to cool it between each cut. A water gun.

Both glass and plexiglass have the advantage of letting you make overlays (assuming they are translucent). You can put anything behind this board, as opposed to having an all white surface. Some examples I’ve seen are adding templates like a blank calendar or checklist behind the glass.

If you put some work into it, this can be a nice, cheap setup.

Chalkboard or Chalkpaper

Chalkboards are cheaper than whiteboards, and even cheaper if you go the DIY route and make one using chalk paper. Chalk paper is basically a rough surface you can buy in rolls, which can be written on using standard chalk. Which means.. hopscotch in the office!

Chalkboards have great contrast, and chalk is dirt cheap compared to dry/wet erase markers (unless you steal those from your local college). The problem, and it’s a big one, is chalk dust. Chalk dust in a small room or office make this route unacceptable for most people. There is “anti-dust” / dust-free chalk, but dust can still be a problem if you don’t have good ventilation.
(more…)