Post-Rice Haze

Devin Naquin
Recent Rice alum. Living and coding.

Apr 20
“…that inside this building is the president, and not just any president—though admittedly that probably would not have mattered—but this is a president that, fuck, we have some sort of crush on this man. He speaks like a president, not always authoritative or anything but he can form sentences, complex sentences with beginnings and ends, subordinate clauses—you can hear his semicolons! He knows the answers to questions. He knows acronyms and the names of foreign leaders, their deputies. It is heartening, it makes our country look smart, and this is an important thing, something we have too long been without.” Dave Eggers about Clinton circa 1994 in A Heartbreaking work of Staggering Genius.

Comments (View)
Mar 29
“I need to see what’s inside that box. If I learned anything from 24, you’re going to want to zoom in and enhance.” 30 Rock, “Apollo, Apollo”

Comments (View)
Mar 16

A lot of people have used The Cure’s “Close to Me”, Diplo included. NME gives a rundown, but uses a terrible Diplo example.

Now Lady Sovereign’s thrown her two cents in with her new single. I like. Plus it’ll give me good material for Lady Sovereign/Diplo/The Cure extended transitions.


Comments (View)
Mar 9
[Flash 9 is required to listen to audio.]

For some reason, I followed Barack’s senate race in 2004. Though living in Texas and being from New Orleans meant it was of little relevance to me.

The gem that came out of the race was this little track. When Barack started running for president, I kept wishing I could find this track, but it had gotten lost somewhere deep in my hard drive. Well. I found it.


Comments (View)
Mar 6

Worst Line of Code and Why

I needed to grab the latest Link object for a certain Forum from Django’s ORM.

Normally, I’d do this with:

link = forum.link_set.order_by('-id')[0]

But for some reason, adding the slice (which adds a limit to the SQL query), was considerably slowing down the call. Whereas, just getting the iterator was fine.

link_qs = forum.link_set.order_by('-id')

Which is disturbing. I haven’t figured out why, but I wanted to get the code I was working on done before figuring out why this query was slow, so I hacked around it.

So, of course, I could just convert that QuerySet to a list and index the list with:

link = list(forum.link_set.order_by('-id'))[0]

But that would load the entire result into memory. My results could potentially be extremely large, so I didn’t want to go down that route.

So I wrote the obvious solution, using the iterator, but only saving the first result. Which turned out to be one of the worst lines of code I’ve ever written.

In all it’s glory:

for link in forum.link_set.order_by('-id'):
    break

Comments (View)
Feb 25
“Trust me, they don’t apply to your app. If in doubt, explain your use case for XML to an experienced Python developer. Or, if you have a thick skin and don’t mind being laughed at, try explaining to a Lisp programmer why your application needs XML!” Python is not Java

Comments (View)
Feb 11

i've lost it

i grew up. learned how to take care of myself.
buy beer. car insurance.

and suddenly the words don’t pretty. oh! forgot the insomnia of restless sparkling girls’ eyes from across the bar. two sets at a time.

oh!

suddenly midnights are:
consumption.
alcohol. television. transportation. oh!

nothing geography can’t solve?


Comments (View)
Jan 24

Elegant Fibonacci Iterator

After a bunch of versions of Fibonacci functions months back, the following iterator appeared in my notebook.

def fib():

    future = [0, 1]

    while True:

        future.append(sum(future))

        yield future.pop(0)

Though of no particular engineering marvel. It is, at O(n), slower than the best case O(log(n)) I can do using matrix multiplication of powers of two.

I find it particularly elegant.


Comments (View)
Dec 26
Whitney and I picked up a stray kitten a little while back. My first real pet. Whitney and I picked up a stray kitten a little while back. My first real pet.

Comments (View)
Dec 22
“Numbers that fool the Fermat test are called Carmichael numbers, and little is known about them other than that they are extremely rare. There are 255 Carmichael numbers below 100,000,000. The smallest few are 561, 1105, 1729, 2465, 2821, and 6601. In testing primality of very large numbers chosen at random, the chance of stumbling upon a value that fools the Fermat test is less than the chance that cosmic radiation will cause the computer to make an error in carrying out a “correct” algorithm. Considering an algorithm to be inadequate for the first reason but not for the second illustrates the differences between mathematics and engineering.” footnote pg. 53 SICP

Comments (View)
Page 1 of 3