Skip navigation

Category Archives: Code

There are many reasons you might want to tweet from the shell. Mine is that I want to be able to send one-liners in to evernote directly from terminal. I looked it up and found that since Twitter has updated to using Oauth for their API this has become much more diffucult. But there is a work around that doesn’t involve using oauth libs.

Enter Super Tweet: They provide a proxy to the twitter API which allows you to still use basic authentication to send tweets. You can sign up here: http://supertweet.net .

Once you have a Super Tweet account set up, create an auth file in your home directory with your Super Tweet account info as fallows:

username:password

Resist the urge to call your auth file something like “twitter_password” and make  sure to change the premissions so that only you can view it. I called my file “.twitter_a”.

Then just create this one line script:

curl -u `cat ~/.twitter_a` -d status="$*" http://api.supertweet.net/statuses/update.xml

You can now use the script like so:

./tweet.sh my awesome tweet goes here

This is all bare bones and it leaves a lot to be desired, but hey it works! Feel free to modify it and come up with your own uses for twitter in the CLI.

Hey just a quick tip.  I created a small script for generating passwords using http://makeagoodpassword.com/. The syntax is:

getpass

Gets a good password from makeagoodpassword.com

getpass simple

Gets a simple password from makeagoodpassword.com

Here is the code:

#/bin/bash
if [ "$1" == "simple" ]; then
wget -q -O - http://www.makeagoodpassword.com/password/simple/
else
wget -q -O - http://www.makeagoodpassword.com/password/strong/
fi

 

I’ve been experimenting with Facebook API. First step in using it is to get a token. This requires some user interaction. I started with code from Mining The Social Web. You can download the login script here:

https://github.com/ptwobrussell/Mining-the-Social-Web/blob/master/python_code/facebook__login.py

I made one modification. I’m using Python for Cygwin so the webbrowser class doesn’t really work. Instead I replaced line 76 with:

os.system('chrome "https://graph.facebook.com/oauth/authorize?'
+ urllib.urlencode(args) + '"')

and in Cygwin I created a symlink to the chrome executable in /usr/bin/ . Now when I run the script the access token loads in chrome. That’s it.

Stay tuned for part two where I’ll be showing you some of the fun I’ve been having gathering data about my FB friends 🙂

I was thinking of not posting this because it looks and works a lot like those stupid “see who views your FB profile” worms, but if you know javascript you can tell that it’s not doing anything malicious, just fun 😉

Paste this in to the address bar:

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',50); void(0)

Works best on a site with a lot of images!