Tag Archive for 'linux'

Downloading Flickr photos

Flickr leech

Flickr Leech is a cool web app. It displays all Flickr photos, including those already rendered invisible because of the 200-photo limit in free accounts. But I need more: I want to download these photos for backup.

After looking around, I found several tools that does the job. They didn’t quite work for me, so I decided to hack my own.

Using the Flickr API and a Python wrapper, I came up with the following:

  1. Get flickr.py and manually add it to the host Python library.
  2. Get an API key from Flickr.
  3. Write the script:
    #!/usr/bin/python
     
    import flickr
    import urllib
     
    flickr.API_KEY = 'API key goes here'
    user = flickr.people_findByUsername(u'username')
    photos = flickr.people_getPublicPhotos(user.id, 500)
    total = 0
    for photo in photos:
       photoURL = "http://static.flickr.com/%s/%s_%s_o.jpg" % (photo.server, photo.id, photo.secret)
       photoFile = "%s_%s.jpg" % (photo.title, photo.id)
       data = urllib.urlretrieve(photoURL, photoFile)
       total = total + 1
       print "Downloading %s" % photoFile
    print "Done with %s photos." % total
  4. Make the script executable, create a directory where to download files, and execute the script from there.
  5. Rinse, dry, press.

I know, the script is very rudimentary. It’s my first Python script, and it needs a lot of work: there’s no exception-handling for one. But it worked perfectly for me.

Twitter updates, via CLI

TwitterI’ve just started using Twitter, an up-and-coming web service that posts user status on the web, in IM and in SMS. The service also exposes its API, so it’s possible to build apps using it.

I found a nifty way of updating my Twitter status through the command line:

curl -u username:password -d status='status_goes_here' -s http://twitter.com/statuses/update.xml > /dev/null 2>&1

Dell asks: ‘What Linux flavor do you want?’

After their IdeaStorm survey to gather customer feedback, and with the resounding call for Linux on Dell notebooks (and desktops), Dell is now asking what Linux flavor customer wants?

I think Dell would be better off coming up with different offerings, and become OS-agnostic. Then again, there are support costs involved (even if there are available community support infrastructures for one’s OS of choice), but the idea is to fit the product to the customer’s requirements. For example, for a Windows user who wants to make the shift to Linux, Dell with Ubuntu would be great. For experienced Linux users (from basic to intermediate), there should be choices between Fedora Core, Ubuntu or OpenSuse.

(I did not add the “paid” Linux variants, but those are better for corporate accounts, I guess.)

[Update] Here’s an even better idea: Dell should ensure that their hardware works with the kernel (and xorg, at least) out of the box.

Who wrote the latest Linux kernel?

It turns out that about 2,000 developers contributed at least one patch to the 2.6.20 version of the kernel.

The study used the lines of code changed as a metric to determine the top contributions to the kernel code.

Interestingly, while kernel development was “spread out among a broad group of people, most of whom (were) paid for the work they do.” Not surprisingly, Red Hat, IBM, Novell and Oracle — top players in the Linux market — were among the top contributors. But it is also interesting to note that companies like Nokia and Sony also contributed portions to the code.

Definitely not the case of having too many cooks.

FizzBuzz

Hmmm

In Bash, I would have done:

$ for i in `seq 100` ; do if [ `expr $i % 15` -eq 0 ] ; then echo FizzBuzz; elif [ `expr $i % 3` -eq 0 ]; then echo Fizz; elif [ `expr $i % 5` -eq 0 ]; then echo Buzz; else echo $i; fi; done

Then again, it took me about 10 minutes to do that. (I couldn’t get the ternary operator to work, somehow.) In C: about five minutes (rusty — I last used C way back in college {ages ago!}).

In a recent phone interview, I was asked to programmatically (in shell) rename a set of files. I blundered for about two minutes, and gave up in the end, saying I could probably do that by experimentation. I could fairly say I passed that interview. The point? Answering “FizzBuzz” questions does not reflect real-world situations — it’s how you approached the problem, even if you didn’t get the answer, that matters.

If I were an interviewer, I’d concentrate on the steps rather than the solution.