Saturday, June 19, 2010
Wednesday, October 21, 2009
Pythonic humour
Saw this on prog.reddit thread. Couldn't believe it so I actually tried it out!
$ python
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
>>>
Wednesday, May 21, 2008
Google Treasure Hunt - Sums of files
A Python solution program for the Google Treasure Hunt question: Product of sums of particular lines in files with names matching certain conditions.
You can download the program here. Remove the ".txt" from the ending of the file.
You can download the program here. Remove the ".txt" from the ending of the file.
# Solution for Google Treasure Hunt Question below:
# http://treasurehunt.appspot.com/ (sum of lines in files)
# Place this file in the folder where you downloaded and
# unzipped the google zip file containing the files. Set
# the UNZIPPED_FOLDER_NAME and other params below and run
# it from the command line
# Author: Pramod Biligiri, pramodbiligiri at gmail,
# http://pramodbiligiri.blogspot.com
from os import path
# Start of config vars
#Enter the name of the folder created when you unzip the download
#I suggest you rename the long random name to "google"
UNZIPPED_FOLDER_NAME = "google"
# For both files, enter the file extensions, the part of filename
# to look for, and the line number whose sum is to be added
EXT1, EXT2 = ".xml", ".rtf"
SEARCH_STRING1, SEARCH_STRING2 = "jkl", "vwx"
LINE1, LINE2 = 4, 5
# End of config vars
def addvalue(filename, result):
lines = [it.strip() for it in file(filename).readlines()]
if(filename.endswith(EXT1) and len(lines) >= LINE1):
result[0] += int(lines[LINE1-1])
if(filename.endswith(EXT2) and len(lines) >= LINE2):
result[1] += int(lines[LINE2-1])
def count(result, dirname, fnames):
for fname in fnames:
full = dirname + "\\" + fname
fullstr = "".join(full.split("\\"))[len(UNZIPPED_FOLDER_NAME):]
if not path.isdir(full):
if ((SEARCH_STRING1 in fullstr) and (fname.endswith(EXT1)) or ((SEARCH_STRING2 in fullstr) and (fname.endswith(EXT2)))):
addvalue(full, result)
def main():
result = [0,0]
path.walk(UNZIPPED_FOLDER_NAME, count, result)
print reduce(lambda x,y: x*y, result, 1)
if __name__ == "__main__":
main()
Wednesday, November 14, 2007
Kubuntu 7.10 (Gutsy) on Dell Latitude 630 audio/sound problem
I've installed Kubuntu 7.10 (Gutsy Gibbon) on the Dell Latitude 630 that ThoughtWorks gave me.
The audio didn't work out of the box. But I just had to run this excellent shell script by Martti Kuparinen for it. He's shared all the details of his Ubuntu on Latitude 630 there.
The audio didn't work out of the box. But I just had to run this excellent shell script by Martti Kuparinen for it. He's shared all the details of his Ubuntu on Latitude 630 there.
Monday, November 12, 2007
Lotus Notes quickstart for newbies
Here's some tips to get you started on Lotus Notes (which is what we use at ThoughtWorks). This should save you some 20 minutes of searching around in the menus.
1) Threaded view
Open "Views" from the menu of items in the left pane and select "Mail Threads"
2) Preview pane
View -> Document Preview -> Show Preview
3) To mark a mail as read when you preview it
File->Preferences->User Preferences. Look for "Additional Options". In that, select "Mark documents read when opened in preview pane"
4) Change browser to Firefox
File->Preferences->Location Preferences.
Pick the "Internet Browser" tab. Select "Other". There's an "Internet browser path" below. Firefox is usually in C:\Program Files\Mozilla Firefox\firefox.exe
5) Set a signature
Action -> Tools -> Preferences.
Look for the Signature tab
6) Quoting messages in the reply
To get the more conventional style of quoting messages in replies, click the Reply dropdown and choose "Reply with Internet-Style history"
Keyboard shortcuts
-----------------
* New Mail - Ctrl+M
* Close Tab - Esc
* Refresh mailbox - F9 (Don't try F5. It locks the app)
* Next unread message - Tab or F4
* Reply - Alt+2, Reply All - Alt+3
1) Threaded view
Open "Views" from the menu of items in the left pane and select "Mail Threads"
2) Preview pane
View -> Document Preview -> Show Preview
3) To mark a mail as read when you preview it
File->Preferences->User Preferences. Look for "Additional Options". In that, select "Mark documents read when opened in preview pane"
4) Change browser to Firefox
File->Preferences->Location Preferences.
Pick the "Internet Browser" tab. Select "Other". There's an "Internet browser path" below. Firefox is usually in C:\Program Files\Mozilla Firefox\firefox.exe
5) Set a signature
Action -> Tools -> Preferences.
Look for the Signature tab
6) Quoting messages in the reply
To get the more conventional style of quoting messages in replies, click the Reply dropdown and choose "Reply with Internet-Style history"
Keyboard shortcuts
-----------------
* New Mail - Ctrl+M
* Close Tab - Esc
* Refresh mailbox - F9 (Don't try F5. It locks the app)
* Next unread message - Tab or F4
* Reply - Alt+2, Reply All - Alt+3
Friday, November 09, 2007
Ron Paul donation info as Yahoo Messenger status message
Ron Paul is raising money with every passing money bomb. Wouldn't it be nice to display the daily amount as your Yahoo Messenger status message, so that you can let your IM friends know how well he's doing today? Now you can do just that, with the Ron Paul Donation Info Yahoo Messenger plugin.
A screenshot:
Just install it by following the instructions given there. I have tested it on Windows XP, Yahoo Messenger version 8.0 or above.
If you have any problems or suggestions, put a comment here or mail me at pramodbiligiri AT gmail Dot com.
A screenshot:
Just install it by following the instructions given there. I have tested it on Windows XP, Yahoo Messenger version 8.0 or above.
If you have any problems or suggestions, put a comment here or mail me at pramodbiligiri AT gmail Dot com.
Friday, August 31, 2007
LiveJournal embed tag extra whitespace - a solution
Whenever I embed a video on LiveJournal, I put below it a link to the original webpage so that the reader can launch it in a background tab and continue to scroll down on his LJ Friends page. But when LJ recently created a custom lj-embed tag that wraps the video in an iframe, it also added some unnecessary whitespace at the bottom of the iframe. So there would be a couple of extra blank lines b/w the embed and my caption link.
Luckily I know CSS, so I did a workaround: Use relative positioning to lift up the caption and any content following the caption. Here's the code:
The style attribute value for "A cool video" moves it upwards by the specified no. of units relative to where it would go by default. -32px worked just right for me. Since this line is moved up, you must also raise subsequent content, otherwise there will be a gap after the caption. This is easily accomplished by wrapping all content after the caption in a div with the same relative position values as the caption itself.
Luckily I know CSS, so I did a workaround: Use relative positioning to lift up the caption and any content following the caption. Here's the code:
<lj-embed>
..embed code for YouTube video ...
<div style="position:relative; top:-32px;"><a href="http://youtube.com/watch?v=blahblah">A cool video</a></div>
</lj-embed>
<div style="position:relative; top:-32px;" >..rest of my blog post...blahblah.....end of blog post</div>
The style attribute value for "A cool video" moves it upwards by the specified no. of units relative to where it would go by default. -32px worked just right for me. Since this line is moved up, you must also raise subsequent content, otherwise there will be a gap after the caption. This is easily accomplished by wrapping all content after the caption in a div with the same relative position values as the caption itself.
Subscribe to:
Posts (Atom)