LOLPython

June 06, 2007 at 01:17 PM | categories: python, geek humor | View Comments

IN MAI time GIMME localtime LIKE TIMEZOR

IZ __name__ KINDA LIKE "__main__"?
    VISIBLE "YOUZ GOT CHEEZBURGERS?"
    CATURDAY CAN HAS FIV
    TODAYZ CAN HAS TIMEZOR THING LOOK AT SIKS!
    YOUGOTZ CAN HAS raw_input THING
    IZ YOUGOTZ OWN lower THING KINDA LIKE "yes"?
        IZ TODAYZ KINDA LIKE CATURDAY?
            MYLOOPZ CAN HAS THR33
            WHILE I CUTE?
                VISIBLE "TODAYZ CATURDAY! I GETZ ALL YOUS CHEEZBURGERS!"
                MYLOOPZ THROWZ AWAY ONCE
                IZ MYLOOPZ SMALL LIKE EASTERBUNNY?
                    KTHXBYE
        NOPE?
            VISIBLE "O RLY? CAN I HAS YOUS CHEEZBURGER?"
    NOPE?
        VISIBLE "I SAW WHAT YOU DID, YOU ATE MY CHEEZBURGERS!"

Yea, you're probably saying to yourself, "WTF IS THAT?"

It's LOLPython, the geekiest, funniest thing I've seen all week!

The LOLPython interpreter translates a variation of LOLCode into standard python. LOLCode itself is pretty neat, but because LOLPython is based on Python, it automatically inherits all of the Python library too. Here's the above code after translation:

from time import localtime as TIMEZOR 
if __name__ == '__main__' :
    print 'YOUZ GOT CHEEZBURGERS?' 
    CATURDAY = 5 
    TODAYZ = TIMEZOR ()[ 6 ] 
    YOUGOTZ = raw_input ()
    if YOUGOTZ . lower ()== 'yes' :
        if TODAYZ == CATURDAY :
            MYLOOPZ = 3 
            while 1:
                print 'TODAYZ CATURDAY! I GETZ ALL YOUS CHEEZBURGERS!' 
                MYLOOPZ -= 1 
                if MYLOOPZ <= 0 :
                    break 
        else :
            print 'O RLY? CAN I HAS YOUS CHEEZBURGER?' 
    else :
        print 'I SAW WHAT YOU DID, YOU ATE MY CHEEZBURGERS!' 
1337 Cat Tellin like it is
Read and Post Comments

Python vs Java

April 20, 2007 at 11:24 PM | categories: python, java | View Comments

I've been coding in Python for two years now. I've recently been reteaching myself Java because some projects I'm working on require it. So far, about the only fun thing about it has been setting up Emacs abbreviations to handle all of Java's verbose syntax. I am simply amazed at how verbose Java is! Just to illustrate my frustration I coded one of the exercises I was working on in Java as well as in Python:

Python vs Java

Yes, both of these code samples do the exact same thing.

On the top is Python. 17 lines of very readable code. On the bottom, weighing in at 28 lines, is Java. Brackets and semicolons are everywhere -- Redundant type declarations and "new" object instantiations -- No syntactic sugar in sight except for the "+" operator that I'm not even allowed to overload myself!

I even think I'm being a bit generous to Java, in the way I've formatted the above code, I've only used a newline when I thought it adds to the readability. You'll note that I closed three whole blocks of code on line 23 instead of on separate lines. Yea, I could start doing this everywhere else to save space but that starts to make the readability of the code much worse than it already is.

Sure, Java is a fine language, it certainly has a long life still ahead of it and will continue to grow and mature... but coming down from a two year long 'Python high' and coming back to Java is.. well.. less than thrilling.

Update: The original java code had newbie-esque syntactical errors that prevented compilation as well as a much larger technical problem: when using an Array as the input for an ArrayList it changes the behaviour of the ArrayList such that it is fixed length meaning it no longer implements a removeAll() method (nor even an add() method, what's a list if you can't add items?!?) Wrapping a Array.asList inside of the ArrayList fixes it, but logically adds yet another line of code and further obfuscates things.

Read and Post Comments

Quod Libet

April 30, 2006 at 08:30 PM | categories: python | View Comments

I've been spending some time today playing around with Quod Libet, a free music player and organizer built for Linux. The nice thing for me is that it's written entirely in Python, which makes it really easy and fun to modify.

Today I wrote one plugin for it as well as one bug fix.

This is too much fun!

Read and Post Comments

Digital Photograph Fingerprinting

April 21, 2006 at 06:19 PM | categories: python, security | View Comments

Our printers have been spying on us for years, but soon we may be revealing our identity when we publicly post pictures we take with our digital cameras.

According to Jessica Fridrich, the holder of two new patents related to digital image fingerprinting, she has been able to statistically show whether or not a particular camera took a picture in question. She asserts that each camera has a unique signature in the way it captures the image and that this signature will be visible in every image that the camera takes. If true, this brings up many privacy concerns; it is most certainly beneficial to individuals, and society in general, to be able to post pictures anonymously.

Computer images are just a long string of RGB values, which are easily modifiable. What if we were to randomize those values within a small delta (using appropriate software)? If the delta were small enough, the change would be unnoticeable to the human eye, but would render any statistical analysis for identification purposes impossible.

Here's some python code to test my theory.

Here's an example test I ran. This is a scaled down copy of the original image (click the image for the original one):

Here's the same image run through at delta = 2:

Here's the same image run through at delta = 20:

Here's the same image run through at delta = 100... Now it's really grainy (click the image to see it better):

Obviously, you want to pick the right delta level. I personally can't see much of a difference between the original and delta=2. The question is: at what point does the image lose its "statistical identity"? I would tend to think that it would lose the identity at even delta=2. At delta = 100 the picture becomes really grainy (although at low resoultion it's easy to miss) ... When it comes time for the revolution though, I think we'll have more important things to worry about than grainy pictures.

Read and Post Comments

Python Reference

February 12, 2006 at 05:48 PM | categories: python | View Comments

I started a reference section to the site today. I added some Python code snippets that I've found useful over the past few weeks. The reference button at the top of the page will take you there.

Read and Post Comments

« Previous Page -- Next Page »