Download Picasaweb Album on Linux

Using this project: http://sourceforge.net/projects/picasaalbumdown/

Direct download to Picasa does not work. It works on Windows.

James Gosling on Development of Java


James Gosling:So long as they do that. The development of Java is not an inexpensive thing. It takes a fair amount of funding. It's not just about writing code. Learning the code is two or three percent of the expense. You're shipping fifteen million copies a week, just the bandwith is horrible. The QA when you have to worry about something that has thirty issues. When you've got everything, every stock exchange, every phone company on the planet. Their security depends on Java. So it's not a causual piece of testing.

You know, when it comes to open source contributions, our history with contributions over the years have been kinda snarky. We'd get lost of people sending code and fixes. But on average, we'd get a submission that fixed the bug but it caused three or four more. And it probably didn't fix the bug for everybody. It probably only fixed the bug for their one case. And trying to get people in the community to actually think about the whole code base and not just their particular issue today. Doing one line of change means an immense amount of testing.

Most open source projects are way too casual for that. Sometimes when you get bugs that are potential security issues, you have to move fast, you have to put immense resources on getting it done. Maybe it's just one engineer fixing one character in one line, but then testing it and making sure you didn't introduce a bug. The harder stuff is if you have a bug, there are probably people out there who have worked around that bug, so how many of the workarounds are you going to break. And when you've got nine or ten million in the developer community you have enormous applications, trivial fixes are not trivial. And open source projects, the way the average open source projects are constituted. IT's easy to get people to do the fun stuff. It's hard to get people to do the hard stuff.

Like QAing the math libraries. Like doing QA on sine and cosine, you absolutely have to have a PHd in Mathematics. Sine and cosine: it sounds really simple, but there is unbelievable amount of depths of subtlety in there. There are extraordinarily few people on the planet qualified to QA that type of stuff.

http://www.basementcoders.com/transcripts/James_Gosling_Transcript.html

Quote HTML Function in python

def _quote_html(html):
return html.replace("&", "&").replace("<", "<").replace(">", ">")

Android Dev Phone 1

For all purposes, it is same as HTC Dream or G1

Additional X Server on Ubuntu

xinit -display :n+1 -- :n+1

-bash: /bin/ls: Argument list too long

In bash, doing a
ls *-output.log
on directory containing 7000 files fails with the error

-bash: /bin/ls: Argument list too long

The best way to go about with this is:

find . -name '*-output.log' | xargs ls -l

Nice join methods in python

_nulljoin = ''.join
_semispacejoin = '; '.join
_spacejoin = ' '.join

using imapfilter

http://moiristo.wordpress.com/2008/11/18/sorting-imap-mail-with-imapfilter/

I struggled a bit to use imapfilter to delete the mails at the server.
The following was configuration

--------------
-- Options --
---------------

options.timeout = 120
options.subscribe = true


----------------
-- Accounts --
----------------

-- Connects to "imap1.mail.server", as user "user1" with "secret1" as
-- password.
account1 = IMAP {
server = 'myserver.com',
port = 993,
username = 'username',
password = 'password.',
ssl = 'tls1',
}

results = account1.INBOX:contain_subject('Subject')
-- Delete messages. This DOES NOT Work.
-- results:delete_messages()

-- This Works

account1.INBOX:delete_messages(results)

urlopen with multiple retries

A good example from test_urllib2net



def _retry_thrice(func, exc, *args, **kwargs):
    for i in range(3):
        try:
            return func(*args, **kwargs)
        except exc, last_exc:
            continue
        except:
            raise
    raise last_exc

def _wrap_with_retry_thrice(func, exc):
    def wrapped(*args, **kwargs):
        return _retry_thrice(func, exc, *args, **kwargs)
    return wrapped

# Connecting to remote hosts is flaky.  Make it more robust by retrying
# the connection several times.
_urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError)



Constructing a command for subprocess execution

Python module, subprocess's Popen call takes a list as its first argument, with name of the command as the first element of the list. Most often, we do "command line sentence".split() to get the list for the subprocess.Popen call.  It is very suboptimal way, especially when you have double-quotes characters which served as shell escape characters.

Consider the following command and see how shlex module makes it more suitable for subprocess.Popen

/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"



import shlex
cmd = """/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'" """

list_cmd1 = cmd.split(' ')
list_cmd2 = shlex.split(cmd)

print list_cmd1
print list_cmd2

$python prog.py 
['/bin/vikings', '-input', 'eggs.txt', '-output', '"spam', 'spam.txt"', '-cmd', '"echo', '\'$MONEY\'"', '']
['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"]

Isn't the second version much simpler?