-
Nat Geo Adventure
Nat Geo Adventure — neat community site for those with a love of travel (just dont connect it to your twitter account).
-
Hacking del.icio.us with Python
I wrote this a few weeks ago, it's a hack for del.icio.us to scratch an itch that I had. At work we have a communal del.icio.us account so that if one of us finds a link we think might be interesting or informative to the others we can post it, together with our name as a tag to the account.
This is great if you don't also have a personal delicious account, you just stay logged into delicious and use the 'post to delicious' bookmarklet, dandy. The problem for me at least was that I wanted to post to my del.icious, and only occasionally if I found something really interesting, post it to the Torchbox delicious account. In order to do that however, I had to be logged in to my account to use the bookmarklet to post to my delicious, then go to the delicious site log out and then back in again with the Torchbox details in order to use the bookmarklet again. Not optimal!
To scratch the itch I wrote a Python script that runs every 20 minutes from the crontab. I wanted the script to look at my account for link posts I had specified with a particular tag ('fortorchbox' in my case) and to take these and post to the communal account.
Realising other Torchbox-ers would likely want to use this too, I set up the script to read from a configuration file to know what user names and corresponding tags to look for. Given that all delicious api requests are done over https and require HTTP-Auth, getting the delicious user names and passwords for the accounts of my colleagues was not really a good plan. Instead, the script sucks in and parses the public RSS feed for the user it is looking at. This now means that that the only password you need is that of the communal account.
Instead of the hassle of logging out and in again, all I or any of my colleagues covered by the script have to do is post a link to delicious with the pre-agreed tag. This can be different for each user - mine is 'fortorchbox'. The script then posts this to the communal account together with a tag of the user who submitted it.
If you suffer from a similar problem of communal link sharing, to use my solution all you need is the python script - which in true modern style losing vowels in proximity to an 'r', I called snaflr - the configuration file with the names etc, and the following line in your crontab (which you can run anywhere in your server by typing
crontab -e)0,20,40 * * * * /usr/bin/python /home/natbat/applications/snafflr/sync.py
This then runs every 20 minutes. The first path is the full path to your python (you can get this by typing
which python) and the second is where you have put the script - once copied dont forget to rename the file from sync.txt to sync.py, the config file remains as .txt.I put the script and configuration file outside of my public html directories for privacy as it contains login details for the communal account.
The configuration file is then in the following format:
#Username - tag prefix - tag to look for - mainusername, mainpw username1, realNameToTag1, tagToLookFor1 username2, realNameToTag2, tagToLookFor2 username3, realNameToTag3, tagToLookFor3 username4, realNameToTag4, tagToLookFor4 ...
Each user has their own line, lines starting '#' are comments, and the line starting '-' is the login information for the communal account.
Feel free to take this script and improve it as you like, it is released under the MIT License.
2 items tagged "adventure"
Look at "adventure" on del.icio.us, Flickr or Technorati
