I just set up a github repository to hold my code.
Here’s the link http://github.com/simao/mycode
Currently, the repository contains only the code of my latest Python script, rssTorrents.py.
I just set up a github repository to hold my code.
Here’s the link http://github.com/simao/mycode
Currently, the repository contains only the code of my latest Python script, rssTorrents.py.
I was looking for a way to parse a RSS feed I built using yahoo pipes and add new torrents to Transmission to download them automatically.
I couldn’t find anything useful, so I just wrote a python script to do just that.
If you want to use it, you’ll need to configure the first lines of this file to suit your needs.
The script is pretty self explanatory.
#!/usr/bin/python2.6
#
# Python script to parse a RSS feed containing torrent files urls and
# add new torrent files to transmission based on the time of the last added
# torrent. The script stores the RSS item date of the last added
# torrent and adds a new torrent to the BT client if the RSS contains
# one or more items with a later date
#
# Sat Jan 23 21:30:00 WET 2010
#
DATEFILE = "rsstorrents.pid"
RSSFILE = "http://pipes.yahoo.com/pipes/......" # Change RSSFILE to point to your RSS file URL
TORRENTCOMMAND = "transmission-remote -n username:password -a "
import feedparser
import pickle
from datetime import datetime
from datetime import timedelta
import time
import commands
# Read the date, download shows from last 3 weeks if we can't read any date
try:
with open(DATEFILE, "rb") as f:
lastdate = pickle.load(f)
print "Read date %s" % lastdate
except Exception:
lastdate = datetime.now() - timedelta(weeks=3)
print "Could not read date of last feed, using last 3 weeks %s" % lastdate
# Fetch RSS File
feedInfo = feedparser.parse(RSSFILE)
# Fetch all items until date is later than the stored date
# Add all files to deluge
n = 0
for entry in feedInfo.entries:
feedDate = datetime.fromtimestamp(time.mktime(entry.modified_parsed))
if feedDate > lastdate:
torrentURL = entry.enclosures[0]['href']
print "Adding torrent %s" % entry.title
outputstatus = commands.getstatusoutput(TORRENTCOMMAND + torrentURL)
if(outputstatus[0] != 0):
print "Error adding torrent: %s" % outputstatus[1]
else:
n = n + 1
else:
break
# Set the last date to the date of the most recent item of the RSS feed
lastdate = datetime.fromtimestamp(time.mktime(feedInfo.entries[0].modified_parsed))
try:
with open(DATEFILE, "wb") as f:
pickle.dump(lastdate, f)
print "Saved date %s" % lastdate
except Exception:
print "Could not save date of last feed"
# Feedback user
print "Finished. Added %d torrents" % n
Disclaimer:
I use this script to download legal torrents
I just found out about a another cool emacs plugin: WindMove
This packages allows you to switch windows withouth using C-x o.
WindMove is included with emacs, just include the following code in your .emacs:
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
More info @ http://www.emacswiki.org/emacs/WindMove
I recently signed up for an account at Jungle disk, http://www.jungledisk.com.
I’m paranoid about backups, I use Time Machine to do a full weekly backup and Jungle Disk as an off-site backup solution. It seemed the cheapest option since you only pay for what you upload, and although I have a full 160GB hard drive, my sensitive files only total about 10 GB. At 0.18$/Month that’s 1,8$/Month + bandwidth.
Jungle Disk Uploads files to an Amazon S3 disk, in my case, located in Europe. I chose to pay 0.03$/Month + bandwith extra for that location because I thought latency would influence the speed of my backups, that’s why I went with Amazon over Rackspace. I’ll probably migrate anyway when Jungle Disk offers a migration tool for this.
I have access to an internet connection with a symmetric 100 Mbit link so I was surprised when I noticed jungle disk was only using about 40 KB/s. After thinking about it, it actually makes sense.
The reason for the slowness of the backup is due to several factors.
Jungle Disk Uploads Individual files, not a big compressed file containing all files to be backed up.
In practice, this means JD does not have a continuous stream of bytes to upload like with a big file, instead it has to stop sending information while preparing to send the next file (including encrypting, it see next item). Besides, it needs to setup the S3 file system to receive the new file. During this time, the TCP connection is almost stopped. When JD starts uploading the next file, the TCP connection already lost all it’s speed, that’s why the speed is only high when JD is uploading big files, the TCP connection has enough time to adjust and recognize the speed of the link.
Jungle Disk Encrypts the files using AES before sending it over the internet through a SSL connection. (UPDATE: This is wrong, see comments)
This means JD has to stop sending files until it finishes encrypting and entire file. This could be solved if JD could encrypt files at the same time it sends the previous file. This could reduce the time the TCP connection is stopped.
Uploading only differences is not really an improvement.
While it’s true that uploading only new files or changed files is a big improvement, uploading only the differences of the files themselves it’s not that big of an improvement. When you think about it, what files have you edited lately with small differences? Text files? So you only send 10 KB instead of 50KB? You gain 40KB? That’s nothing in today’s bandwidth speeds. When you edit a big file, like a big image, you most likely edited a big part of the file and you still have to upload most bytes of the file.
Jungle Disk is a really nice service, and I think it’s the best you can get. Probably there’s not an off-site backup solution that isn’t slow. Besides, it’s only slow the first time, when you have to upload 10GB in one time, after that you only have to upload new or changed files, that’s about 1GB per backup in my case.
If you don’t have an off-site backup solution yet, Jungle Disk is the way to go. And you DO need an off-site backup solution, right?
Here’s a nice post on how to clean up macports:
http://simenhag.blogspot.com/2008/11/cleaning-up-macports.html
I do this cleansing from time to time.
The latest emacs pretest version (23.0.95) includes EasyPG making it easier to encrypt/decrypt files almost transparently.
You just have to C-x C-f a file and C-x C-s and EasyPG takes care of the rest for you.
I had my Time Machine backup working and I used to do my backs every week or so.
After I ran out of space, I bought a new external to use as a backup volume, so I formatted the new hard drive using Disk Utility and set it to use the GUID partition scheme and HFS+.
I started time machine and it began a new backup but after some time the backup always stopped.
I retried several times, and I reformatted my external hdd multiple times, and several other solutions I found while googling but Time Machine always stopped during the backup.
I saw this knowledge base article from apple, where they advice users to use GUID, so I didn’t try anything else. Until I did, and it worked.
So my solution on how to fix Time Machine when it stops repeatedly during a backup is to use MBR and not GUID (as apple suggests). I think the SATA controller of my disk doesn’t like using GUID.
Smultron has a nice advanced find and replace feature and it uses ICU as the regular expressions engine.
To help you building nice regular expressions for smultron, you can get more information about this engine at http://userguide.icu-project.org/strings/regexp
Another one for the geeks.
I’m preparing some posts about moleskines and pens, meanwhile, I’m writing this post about gpg keys.
Gpg keys is an extremely good solution to protect your privacy, here are some links you can use to know more about it.
http://www.gnupg.org/
http://www.gnupg.org/gph/en/manual.html
http://www.queen.clara.net/pgp/art3.html
You can use enigmail, with Mozilla Thunderbird, to integrate gpg capabilities to your e-mail client. (Really recommended)
Just search google if you need more info.
You can lookup my key on mit’s public keyserver, you can use it to verify every thing I wrote, was really wrote by me:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xFFF7D6FE
If you want to change some encrypted e-mail, just for fun (or not), you can use my public key to encrypt it, and send it to simao at bliter dot com.
I’ll reply, and you’ll receive a encrypted message that you can decrypt with your private key.
Of course you have to upload your public key to a keyserver, so I can encrypt e-mail to you.