Home

Flickr Views HOWTO

  • Oct. 7th, 2008 at 11:30 AM
# Introduction #

Flickr (http://flickr.com) is an extremely popular photo sharing
website owned by Yahoo! and its rich web UI and programming interfaces
make it a great destination for exchanging photographic content among
photographers and consumers. This HOWTO gives tips on how to improve
view counts on your photostream and get your photographs to be noticed
not just by your friends but also unknown people who might be
interested in content that you have photographed.

Read more... )

Awk Jugglery

  • Sep. 25th, 2008 at 1:30 PM
Task: Given a file with on phrase on each line, followed by a frequency count at the end, sum up all frequency counts for each term and report. E.g. the input may be:
metallica 2
iron maiden 3
system of a down 3
metallica 1
megadeth 2
system of a down 1
The output for this should be (ordering doesn't matter):
3 metallica
3 iron maiden
4 system of a down
2 megadeth


Not an easy task, eh? Try it without general purpose programming languages like Python, PHP, Java etc. Perl would've been ideal for its ability to allow powerful one-liners but again, it's a general purpose language with classes and whatnot! Behind the cut is an awk one-liner to handle this crap, whenever you're ready.
Read more... )

Update:
My tryst with completely fucked up log files continues. I have another log file wherein I need to delete a line that matches a pattern and the two lines preceding it. Some more awk shite needed, maybe. You can trust the research engineer types to never generate logs that can be parsed easily. :(

Update 2:
Behind the cut is a python script that deletes n lines before the match. Oh, and it's not grep per se, but grep -x because of the way I match the line with the pattern.
Read more... )

Format strings

  • Sep. 19th, 2008 at 6:06 PM
So, things were never too simple in C++ world when it came to funky formatting while doing all the cin cout business. So, Python also follows C-like format specification strings and it's all happy and cool most of the time. Except, when it comes to shit like this:

print args = dict([x for x in mydict.items() if x[0] in ['xx', 'yy', 'zz', 'aa', 'bb']])
print "%(xx)d, %(yy)d, %(zz)d, %d(aa), %(bb)f" % args

This gave me:
{'xx': 99050L, 'bb': 3.1360260922879597, 'yy': 2556, 'zz': 2, 'aa': 0}
TypeError: not enough arguments for format string


Zoink! What the heck is going on here? After some half an our of frantic debugging (i.e. print abuse), I figured. I'd written %d(aa) instead of %(aa)d.

So much for format specifier funk.

Enemies of Islam

  • Sep. 14th, 2008 at 3:27 PM
If someone thinks they know Islam but are the most lacking in their knowledge of the basics, it has to be the Indian Mujahideen. "Mujahideen" literally means people engaged in holy war and what they've been doing isn't war, it's cowardly mischief. Secondly, even if they're under the delusion that they're waging a war, weren't they supposed to know that fighting is prohibited in the month of Ramzan? No they don't, and they won't. They wouldn't have been engaging in such activities had they had even an iota of the principles of Islam imbibed in them.

They're enemies of Islam masquerading as Muslims. They are the biggest threat to Islam today. Disgusting. Agonising.

BTW, check out the editorial in yesterday's Economic Times about the special laws for terrorism. It's brilliant.

Morality and loserdom

  • Sep. 8th, 2008 at 9:58 AM
These days, I sometimes get the feeling that I must be one of the most unethical, immoral blokes among the people I know. I also have confirmation of my loserdom now. No, it's not related to the immorality bit.

Last night I was up trying to finish at #1 on a race track while playing Forza Motorsport 2. I was quicker than the rest through most of the corners and my car had immense straight-line speed. All I had to do was to not lose it on two slow corners. And just trying to accomplish this took me 3 hours, with restarts every 2 to 10 minutes! Eventually, I figured how to go fast through those two corners themselves but that's besides the point. The number of times I lost my lead due to mistakes while going into the penultimate or final lap wasn't funny.

And then I had a realisation. Losers aren't those who can't win. Those are incompetents. Losers are those who don't win, when they clearly can win. They just have the habit of throwing it away while they're leading, rather than taking things to completion. I am one such person, a habitual loser.

And I think the only thing that motivates and pushes me is peer pressure. If everyone else is winning, I'd want to win too. If everyone else is a loser or an incompetent bloke, I can't achieve anything either. Unfortunately for me, it's hard to find peers that'll always be finishing at the top.
Often you need to disable try/except blocks while debugging code because you want to find out the point of occurrence of the exception and other info which is swallowed by the block that catches the exception. With languages that use braces for block demarcation, it's as easy as simply commenting out the try and catch/except lines, minding the braces at the same time. Doing that with Python is not possible because you also need to un-indent the enclosed lines of code. I just figured a simple way of working around it. Change this:

try:
   some_code
   more_code
except:
   some_more_code


to this:

if True:#try:
   some_code
   more_code
if False:#except:
   some_more_code


Hope you find this useful.

SVN WTF

  • Aug. 10th, 2008 at 3:52 PM
[15:34:22 tahir:wisdomtap 0]$ grep -r 'capitalize()' *
lib/.svn/tmp/tempfile.2.tmp:                recog_terms[k] += [v.capitalize()]
lib/.svn/tmp/tempfile.2.tmp:                recog_terms[k] = [v.capitalize()]
lib/.svn/text-base/srp.py.svn-base:                recog_terms[k] += [v.capitalize()]
lib/.svn/text-base/srp.py.svn-base:                recog_terms[k] = [v.capitalize()]
lib/srp.py:                recog_terms[k] += [v.capitalize()]
lib/srp.py:                recog_terms[k] = [v.capitalize()]

Oops! We've got matching junk from .svn. Let's ignore it.
[15:34:41 tahir:wisdomtap 0]$ grep -r 'capitalize()' * | grep -v .svn
lib/srp.py:                recog_terms[k] += [v.capitalize()]
lib/srp.py:                recog_terms[k] = [v.capitalize()]

Aaah! Better. I just want to replace capitalize() with title(). So,
[15:36:10 tahir:wisdomtap 0]$ grep -lr 'capitalize()' * | xargs perl -pi -e 's/capitalize()/title()/g'
[15:36:12 tahir:wisdomtap 0]$ svn diff *
[15:36:14 tahir:wisdomtap 0]$ 

Baroo! Why's nothing changed?
[15:36:27 tahir:wisdomtap 0]$ grep -lr 'capitalize()' *
[15:36:33 tahir:wisdomtap 1]$

Baroo! Where did capitalize() go? Well, it did get changed faithfully to title(). But then why's svn diff not showing anything? Err... oooooooooooops... forgot to grep -v .svn before piping to xargs. Now what? How do I commit? What happens when I commit, say, an unrelated change?

*cluesless*

A Typical Technical Yahoo - MacBook, latte, and O'Reilly books
A Typical Technical Yahoo - MacBook, latte, and O'Reilly books
Originally uploaded by GirlieMac.

This is one of the grooviest things I've seen in quite some time. Rawk on!

I'm Death, yeah?

  • Jul. 31st, 2008 at 7:25 PM

Your result for The Which Discworld Character Am I Test...

DEATH

You scored 87 intelligence, 42 morality, and 54 physical strengenth!

YOU ARE SMART, SAVVY, AND KNOW WHAT DEDICATION TO THE JOB IS...MOST OF THE TIME. YOU ENJOY YOUR WORK, AND EVEN HELP OUT OTHER ANTHROPOMORPHIC PERSONIFICATIONS FROM TIME TO TIME. RECENTLY, YOU'VE LEARNED WHEN TO BEND THE RULES, MUCH TO THE DEATH OF RATS'S CHAGRIN.

Take The Which Discworld Character Am I Test at HelloQuizzy

From [info]bluesmoon, justbecos I'm too fucking bored and somewhat unhappy. Oh, and I have no clue what Discworld is, though Ankh-Morpork (more pork?) sounds familiar.

Tags:

We aren't done with Hardy Yet

  • Jul. 31st, 2008 at 12:25 PM
This morning I discovered that the brightness control key now increments the level by 4 (of 8) units. So, instead of 8 levels, I now just have the equivalent of dark, medium and full brightness. WTF?

And don't get me started on the keyboard shortcuts story. Oops! I got started already. For interpreting shortcuts for the desktop, there are at least two levels of entrapment that I figured. One is the window manager, Metacity and the other is the Open GL compositor (Compiz Fusion). There are various different places where you could configure your cross-application keyboard shortcuts. For what it's worth, I've not been able to configure my desktop to lock the screen on Super+l -- a combination that I had been using since the days of Red Hat 8.0 (2002?).

The easiest one -- setting it through System > Preferences > Keyboard Shortcuts -- doesn't work. The dialog shows that it has faithfully registered Super+l as the shortcut but locks the screen as soon as I press Super. So, I can't use Super+Space, Super+s, Super+m or any of the other window management shortcuts that are meant to be triggered by Super (windows, get it?) key. Ergo, while locking my screen was earlier as instinctive as taking my hands off the keyboard and standing up to leave my computer, I now end up leaving my screen unlocked because clicking the desktop icon is too much of a hassle.

Never have I been so disappointed with a Linux distribution as I have been with the piece of crap that Hardy fucking Heron is. Linux on the (personal) desktop/laptop was a dream that I'm done with. What's the worst thing about it being F/OSS? You don't have the right to complain since you never did anything to help it.

Oh wait, I donated $100 of David Filo and Jerry Yang's money to the Gnome Foundation once. Fuck, yes, I can complain.

More Ubuntu Hardy Fuck-ups

  • Jul. 30th, 2008 at 5:28 PM
The screensaver decides to freeze randomly when unlocked. Incidentally, XKCD is also on Ubuntu's case now. Unfortunately, I don't want to recompile the kernel, even though my wi-fi has also been out for two weeks (see the alt text). Unfortunately, I also can't do anything about it anytime soon because my laptop is my dev- machine as well and there are no free machines at work to create a dev box out of.

Cautionary

I CAN HAZ OPINIONS

  • Jul. 28th, 2008 at 12:07 PM
  • Ubuntu Hardy Heron (LTS) is a step back for Linux-kind. It's broken. It sucks. It's given me hours of frustration and lost productivity, to the extent that I went to the Apple Store yesterday with real interest
  • Debian packaging has to be the most brain-dead of the three package management systems I've worked with -- deb, rpm and Yahoo! internal stuff. The Yahoo! internal stuff is amazing.
  • The apt toolchain is a bane for GNUmanity.
  • If you are into digital photography, an Apple Cinema display is a must have for you. You won't miss it until you use it, though. 23" display available from the Apple Store for INR 55k odd. No, your MacBook/MBP laptop screens aren't anywhere close to being scaled down Cinema displays. The panel technology is totally different.
  • How do I choose whether to buy XBox 360 or Playstation 3? The answer is simple -- I buy the one that can feed High Definition content to my HDTV. XBox can, via the component video cable that comes with it. Playstation 3 can't because it's illegal to make cables that can take HDMI output from PS 3 (or any other HDMI device out) and convert them to Component Video. Why? Some jackass copy-protection issues, that's why. Ergo, I now have an XBox 360 and for the first time in its life, my HDTV gets to display Real HD content at 720p (equivalent of 1280x720 px resolution on a 29" 4:3 screen cropped down to 16:9 format). BTW, for all their power consumption and their bulk, CRTs still kick LCD screens' collective arses in picture quality.
  • Pylons + mod_wsgi + Apache 2 is no slouch of a setup

Evil Nikon

  • Jul. 2nd, 2008 at 8:23 AM

Nikon D700

Nikon D700 FX Digital SLR Camera

  • ISO 200-6400 (100 - 25600 in pulled/pushed mode)
  • 12.1 MP 35mm (FX) CMOS Sensor
  • 14 bit RAW
  • Magnesium Alloy Body with Weather Seals and Self-cleaning Sensor
  • Live View, HDMI Output, Crazy awesome focusing in Live View

How the heck can you be a photography enthusiast, especially a Nikon afficionado, and not drool over this model? Time to start saving up $2999, US, somehow. Oh, and I'm getting the 85mm f/1.8 goodiness this autumn. Can hardly wait to get the feel of the expanded FoV from my existing 35mm f/2 D lens and this new one on the FX sensor. Suddenly, the 18-200mm VR permanently on the D80 becomes a super attractive combo again :-)

Milestones Completed: 3

  • Jun. 26th, 2008 at 3:14 AM
  • First Night Drive
  • First Solo Drive
  • First entry into the basement parking

Tags:

State of the Crass

  • Jun. 21st, 2008 at 7:33 PM
Looking at my last several journal entries might make one wonder what went wrong with me. I mean, heck, suddenly there's a lot of Python shitnez floating around and there's no sign of ranting anywhere. What? Has someone else started writing under my name?

Well, naah, that was mostly me, being totally excited about my new job and the kind of stuff I'm doing there. Oh, but there is something about the job that bugs me a lot too. We'll come to it in a bit as I write about the state of the crap in my life right now in descending order of suckiness.

Ze Ca
First off, a big L-) to everyone who made me think that I needed a car, like, last year. Well, fuck, I didn't. It undoubtedly allows me greater mobility and expands the zone in hours of the day that I can be mobile but, heck, I'd rather be sleeping during the hours that I can't find a means of public transport (read Auto Rickshaws, as that's the least sucky means of public transport in this village of transportation horrors). Even if that's not the case, who the fucking hell has the time and energy to take the vehicle out for servicing, PUC tests and shit like that? And apart from everything else, WHO THE FUCK WANTS TO DRIVE? Not me, na-a, nope, not in this loserville.

Daddy spent INR 10k on getting the car shipped from Delhi to Bangalore, and I think I'll spend another INR 10k getting it shipped back to Delhi. I can't bloody keep a car. I can't, I can't, I can't.

Ze Home
Month #1: I iz super kicked with the cost savings in employing a cook at home. Suddenly, even after paying the cook some cool money, my monthly food expenses come down five times.

Month #2: I realise why it costs 5 times more to eat out than to get food in-house. YOU FRIGGIN' DON'T have to run to the market EVERY WEEK to buy GROCERIES. Have you guys seen "Some Kind of Monster"? It's a documentary about the shit that Metallica went through during the time they were working on "St. Anger". There's a scene in there where Lars Ulrich is frustrated with Hetfield and he goes, "Fuck, fuck, fuck, fuck, fuck..." so many times, with frustration pouring out the way he says it each time. I feel like saying it the same way. You want a demo? Come meet me, I'll show you how it's said. Oh, and for five times the money, you also get about 20 times the variety in food. Lamzorness.

Ze Cash
It's been seven years since I've been earning and for six of those seven years, I had a usable ATM right next to the office. Now, suddenly, I find that I have to walk at least 1.5 km to find any ATM and travel over 10 km from home to find an ATM of either of the three banks that I have accounts with. Ergo, these days I'm highly likely to be roaming around without cash... except when I find someone (as of now my little brother) to drive the said car and take me to that ATM 10km away from home. Fu-u-uck!

Ze Work
Before I start out with talking about work, let me again mention that the reason why this journal has been so devoid of frustration for the last few months is because of the awesome stuff I've been getting to do at WisdomTap. End of employer-pacifying disclaimer. Now for the suckage. #1 The "office" (note the quotes) is located in such a lovely place, I bet it's got to be the best area in the whole of Bangaloreville.

There's a pharmacy every 15 meters around there, there's a fine dining restaurant (the only fine dining restaurant I know of that has self-service) right under the office and there are swanky villas and high rise apartments all around. Apparently, the real estate developers were in such a hurry to build stuff in that area, they forgot that they need to lay the sewer lines and build roads. The entire bloody area is devoid of anything that remotely resembles a road. You think you've got a tough SUV? Well, use it to come to work every day of the week and by the end of a quarter you'll have a broken suspension. I wonder what the pharmacies are about.

That, and there's no such thing as a weekend :-| Fuck.

Okay, I'm done ranting. Fuck everything.

The Breakdown of Modern Web Design

  • Jun. 10th, 2008 at 2:13 PM


Courtesy [info]vijayr

PS: Oh, I forgot to mention. We still have an open req for a front-end engineer. You really do want to join us because with your help, we're all gonna get rich! Umm... conditions apply, but there's unconditional free Red Bull on the house, yo!

Little surprise in Flickr Mailbox

  • Jun. 5th, 2008 at 2:25 PM
You are now an administrator of SuperBikes in Bangalore


The last administrator of SuperBikes in Bangalore has left the group and you have been made into an administrator. This is because you are the longest serving member of the group. Well done :)


Heheh. Hahah. Hahahah. HAHAHAHAH! MWAHAHAHAHAHAAH! Flickr rocks!

PS: The first thing I did was to change the scope of the group to include Superbikes anywhere in India. If you've got pics of them Hayabusas and YZF-R1s, post 'em there. Photos from exhibitions like Auto Expo aren't included in the scope, though.

Ode to Internet Explorer 6

  • May. 28th, 2008 at 4:59 PM
IE 6 is a bitch, she's a big fat bitch,
She's the biggest bitch in the whole wide world,
She's a stupid bitch, if there ever was a bitch,
She's a bitch to all the boys and girls.

On Monday she's a bitch
On Tuesday she's a bitch
On Wednesday thru Saturday she's a bitch
Then on Sunday just to be different,
She's u super king kamehameha bitch

Have you ever met my friend IE 6,
She's the biggest bitch in the whole wide world,
She's a mean old bitch, she has stupid hair,
She's a bitch, bitch, bitch, bitch, bitch, bitch, bitch
Bitch, bitch bitch bitch bitch bitch bitch
She's a stupid bitch, IE 6 is a bitch,
And she's such a dirty bitch.

Talk to kids around the world,
It might go a little something like this...

[Sung in three different languages by other children]

Have you ever met my friend IE 6,
She's the biggest bitch in the whole wide world,
She's a mean old bitch, she has stupid hair,
She's a bitch, bitch, bitch, bitch, bitch, bitch, bitch
Bitch, bitch bitch bitch bitch bitch bitch.
She's a stupid bitch, IE 6 is a bitch,
And she's such a dirty bitch;

I really mean it,
IE 6, she's a big fat, stinking bitch
Big old fat fuckin' bitch, IE 6ssssssss
YEAHHHHH, Chaaaaa

May. 27th, 2008

  • 4:58 PM
I just bumped into Eric S. Raymond's notes on Python while I was searching for addition of ad hoc members in Python classes. He wrote something that caught my attention as being very insightful and something that I can identify with, yet couldn't articulate as well as he:

My second came a couple of hours into the project, when I noticed (allowing for pauses needed to look up new features in Programming Python) I was generating working code nearly as fast as I could type. When I realized this, I was quite startled. An important measure of effort in coding is the frequency with which you write something that doesn't actually match your mental representation of the problem, and have to backtrack on realizing that what you just typed won't actually tell the language to do what you're thinking. An important measure of good language design is how rapidly the percentage of missteps of this kind falls as you gain experience with the language.

When you're writing working code nearly as fast as you can type and your misstep rate is near zero, it generally means you've achieved mastery of the language. But that didn't make sense, because it was still day one and I was regularly pausing to look up new language and library features!

This was my first clue that, in Python, I was actually dealing with an exceptionally good design. Most languages have so much friction and awkwardness built into their design that you learn most of their feature set long before your misstep rate drops anywhere near zero. Python was the first general-purpose language I'd ever used that reversed this process.


And to end this post, here's two more nifty idioms from Python:
# substitute for C's ternary operator (?:)
exp1 if condition else exp2 

# swap the values of variables a and b
(a, b) = (b, a)

Web Developer Required

  • May. 27th, 2008 at 1:53 AM
WisdomTap, a start-up that I work for, requires a full time web developer to join its existing staff of six and quick.

We're a very new company building a new product based on knowledge search and opinion mining and we are close to releasing a limited public beta of our product. While working on the alpha release we realised that we need an F2E wizard among us for the long term. The profile for the requirement is:

Mandatory: HTML, CSS, JavaScript
Also required: Skills in i18n, accessibility, cross-browser compatibility, graceful degradation and progressive enhancement, F2E design and organisation
Nice to have: Knowledge of Python, Python web frameworks, apache server configuration

Our development and deployment environment is based on Ubuntu Linux.

I'd like to emphasise that we need a high level of skill in the above areas since we're small and we'd like to get a lot done, and done well. We offer highly competitive compensation packages to match the skill level we need. If you are interested in applying for this position or know someone who would be suitable for it, please leave a comment below with the relevant contact details. All comments containing contact info would be screened.

Please do this NOW, but please keep in mind that we'd be doing the interviews etc. ourselves so we can only devote limited time to this activity. I hope that you'd be duly diligent in making recommendations.

TIA!

Tags:

Profile

LogoCrop
[info]code_martial
Aragorn, Son of Arathorn
My photostream

Latest Month

October 2008
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags