I found out there is a video lecture series to go along with my new book The Algorithm Design Manual. The audio level is really low, but I think it will complement my book reading nicely. There are also lecture notes and homework assignments. It also turns out MIT has a huge collection of free courses online. Not all of them have video though. I listed some interesting Computer Science related courses with video below. After more searching, I found UC Berkeley also has a number of free courses online, including four Computer Science courses with video. The final source ...
Read more...Here's an interview question I got recently from a Python company:
Write a program to read a multiple line text file and write the N longest lines to a new file. Where N and the file to be read are specified on the command line. Working solutions first but we are really looking for optimized solutions.
Here's my solution:
import sys
def main(filename=sys.argv[1],
N=int(sys.argv[2])):
""" Finds the N longest lines in filename and writes to filename + ".new"
"""
lines = open(filename).readlines()
lines.sort(cmp=lambda x,y: cmp(len(y), len ...I have been using a symlinking method to install Python packages up to this point. To better handle dependencies and multiple versions I have wanted to switch over to pip and virtualenv. Pip is a better alternative to Easy Install and virtualenv is a tool to create isolated Python environments. I have wanted to use pip and virtualenv for a long time now. Finally, today, I took my first steps and created an environment with the Python packages required for this blog. My notes are below. (I am running Ubuntu Intrepid and Python 2.5.)
A lot of my notes ...
Read more...I am using pytz, which is a time zone definitions package. You can install it using Easy Install. On Ubuntu, do this:
sudo easy_install --upgrade pytz
from datetime import datetime
from pytz import timezone
date_str = "2009-05-05 22:28:15"
datetime_obj = datetime.strptime(date_str, "%Y-%m-%d %H:%M:%S")
datetime_obj_utc = datetime_obj.replace(tzinfo=timezone('UTC'))
print datetime_obj_utc.strftime("%Y-%m-%d %H:%M:%S %Z%z")
Results:
2009-05-05 22:28:15 UTC+0000
from datetime import datetime
from pytz import timezone
fmt = "%Y-%m-%d %H ...Here are my notes on setting up nginx as a reverse proxy with Apache, mod_python, and Django on Ubuntu Intrepid. Nginx is used to serve my static media files while all other requests are passed on to the Apache/mod_python/Django web server.
I realize mod_wsgi has become the preferred way to deploy Django, but I'm a little behind the times and am still using mod_python. I hope to switch to mod_wsgi soon.
I have been using Amazon's CloudFront service for delivering my static media files. As far as I can tell, it has worked well. My main ...
Read more...I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more ยป
algorithms
(2)
aws
(4)
bison_flex
(1)
blogger
(4)
c
(11)
cardstore
(7)
colinux
(2)
concurrency
(8)
conkeror
(2)
cygwin
(17)
datetime
(3)
dell
(3)
django
(34)
eclipse
(30)
emacs
(18)
error
(11)
hosting
(1)
keyboard
(3)
linux
(34)
matplotlib
(5)
mercurial
(3)
openid
(1)
personal
(4)
preferences
(7)
pyqt
(18)
python
(95)
rails
(1)
ratpoison
(3)
rsync
(3)
ruby
(2)
softwaretools
(16)
sql
(11)
subversion
(4)
twisted
(5)
ubuntu
(39)
untagged
(7)
urxvt
(3)
vxworks
(25)
webservices
(2)
wmii
(5)