Skip to content

Instantly share code, notes, and snippets.

@axiomsofchoice
axiomsofchoice / FizzBuzz.py
Created January 10, 2011 14:01
Interview Zen Question 1: Implement FizzBuzz
# See http://www.interviewzen.com/interview/3PSvg
for i in range(1,101):
if i % 15 == 0:
print "FizzBuzz"
elif i % 3 == 0:
print "Fizz"
elif i % 5 == 0:
print "Buzz"
else:
@axiomsofchoice
axiomsofchoice / Jmol.java
Created January 17, 2011 00:41
Hacked Kinect Version of Jmol
package org.openscience.jmol.app;
import java.awt.Point;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.swing.JFrame;
import javax.vecmath.Vector3f;
import org.openscience.jmol.app.jmolpanel.*;
@axiomsofchoice
axiomsofchoice / OSC_TestServer.java
Created January 17, 2011 00:44
Test OSC server for the Jmol Kinect #pmrhack Emits a test signal - useful if you don't actually have a Kinect
package com.foo;
import java.net.SocketException;
import java.net.UnknownHostException;
import javax.vecmath.Vector3f;
import com.illposed.osc.OSCMessage;
import com.illposed.osc.OSCPortOut;
@axiomsofchoice
axiomsofchoice / gadget.xml
Created February 17, 2011 16:16
An example gadget made at Dev8D 2011 for the purpose of testing out SciVerse and maybe entering the challenge.
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="sciverse-gadget" author_email="someone@example.com" description="An example gadget made at Dev8D 2011 for the purpose of testing out SciVerse and maybe entering the challenge.">
<Require feature="opensocial-0.9" />
<Require feature="sciverse" />
<Require feature="hub" />
<Require feature="org.jquery.core-1.4.2" />
</ModulePrefs>
<Content type="html" view="canvas"><![CDATA[
@axiomsofchoice
axiomsofchoice / moire-ball.svg
Created March 19, 2011 00:22
Using a mask and animation to demonstrate Moire patterns
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@axiomsofchoice
axiomsofchoice / seq.hs
Created March 22, 2011 23:38
A brute-force attempt to test a few examples for the "sequence" puzzle
let primes = [2,3,5,7] in let mult (x,y) = x*y in let {f 0 ls = ls ; fn ls = map mult (zip primes (f (n-1) ls)) } in f 3 primes
"""Outputs a KML file with locations of certain comments from patientopinion.org.uk
Requires an API key to be provided on the command-line
"""
import urllib2
import re, sys
from xml.etree.ElementTree import *
# TODO: implement a paging mechanism
takeNumber = 20
@axiomsofchoice
axiomsofchoice / binarysearch.py
Created April 18, 2011 15:29
An attempt at Jon Bently's binary search algorithm challenge from his book "Programming Pearls"
"""
An implementation of binary search, based on the challanges in the following blog posts:
http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/
http://www.solipsys.co.uk/new/BinarySearchReconsidered.html?tw
This was not my first attempt however, there was a broken version (of course)
that I wrote prior to running it for the first time. Sadly I didn't take a
snapshot before I fixed it but the bug was fairly major; although I'd worked
@axiomsofchoice
axiomsofchoice / crossrefexample.py
Created April 20, 2011 16:50
Use content negotiation with a certain DOI to obtain linked data about that resource.
"""Use content negotiation with a certain DOI to obtain linked data about that resource.
See also:
http://myemail.constantcontact.com/CrossRef-and-International-DOI-Foundation-Collaborate-on-Linked-Data-Friendly-DOIs.html?soid=1102390657767&aid=eTYx65PAErU
http://www.crossref.org/CrossTech/2011/04/content_negotiation_for_crossr.html
"""
import urllib
exampleDOI = 'http://dx.doi.org/10.1126/science.1157784'
@axiomsofchoice
axiomsofchoice / sparcurl.sh
Created May 17, 2011 12:27
Using curl to query SPARQL endpoints
curl -H "Accept: application/sparql-results+xml" "http://localhost:8000/sparql/" --data-urlencode "query=SELECT ?s ?p ?o { ?s ?p ?o . }"