Skip to content

Instantly share code, notes, and snippets.

@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 . }"
@axiomsofchoice
axiomsofchoice / prime_birthday.php
Created May 30, 2011 20:47
Prime Birthday Computation Script
<html>
<body>
<form action="prime_birthday.php" method="post">
Day: <input type="text" name="day" />
Month: <input type="text" name="mon" />
Year: <input type="text" name="year" />
<input type="submit" />
</form>
@axiomsofchoice
axiomsofchoice / irc_clients.sparql
Created June 4, 2011 22:31
Query DBpedia for GPL licensed IRC clients
## An attempt to query the data here: http://en.wikipedia.org/wiki/Comparison_of_Internet_Relay_Chat_clients
## via http://dbpedia.org/spraql to determine which IRC clients for Windows are GPL licensed
prefix dbo: <http://dbpedia.org/ontology/>
prefix dbpprop: <http://dbpedia.org/property/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix yago: <http://dbpedia.org/class/yago/>
select distinct ?client ?label ?license ?os
@axiomsofchoice
axiomsofchoice / hello.c
Created June 5, 2011 01:48
Simple hello world C prog for testing emscripten's handling of stdio.h
#include <stdio.h>
int main(int argc, char **argv) {
FILE *fp;
char mc ;
fp = fopen(argv[1],"r") ;
printf("Reading contents of file\n");
while((mc = (char) fgetc (fp)) != EOF) {
@hmarr
hmarr / gist:1013596
Created June 8, 2011 01:22
post{,de}activate scripts for virtualenvwrapper
#!/bin/zsh
# Global virtualenvwrapper postactivate, lives in $WORKON_HOME/postactivate
# Remove virtual env from start of PS1 as it's in RPROMPT instead
PS1="$_OLD_VIRTUAL_PS1"
PROJECT_DIR="$HOME/projects/$(basename $VIRTUAL_ENV)"
if [ -d $PROJECT_DIR ]; then
# If we aren't already within the project dir, cd into it
@mariofusco
mariofusco / MnemonicsCoder.scala
Created June 12, 2011 16:23
Encodes a number in one (or more) list of words corresponding to its phone mnemonic code
class MnemonicsCoder(words: List[String]) {
private val mnemonics = Map('2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL",
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ")
/** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */
private val charCode: Map[Char, Char] =
for ((digit, str) <- mnemonics; letter <- str) yield (letter -> digit)
/** Maps a word to the digit string it can represent */
require 'rubygems'
require 'nokogiri'
m = {}
f = {}
open("dist.male.first").readlines.each { |l|
d = l.split(/ +/)
m[d[0].downcase] = d[1].to_f
}
open("dist.female.first").readlines.each { |l|
@visnup
visnup / StackScript.sh
Created August 23, 2011 17:45
node.js knockout 2011 StackScript
#!/bin/bash
# <UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" />
# root ssh keys
mkdir /root/.ssh
echo $SSH_KEY >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
# update to latest
@axiomsofchoice
axiomsofchoice / query-all.sparql
Created August 31, 2011 15:33
How to select *everything* in a triplestore containing several different named graphs
# How to select *everything* in a triplestore containing several different named graphs
SELECT * { { ?s ?p ?o . } UNION { GRAPH ?g { ?s ?p ?o } } }
@axiomsofchoice
axiomsofchoice / MyRandomNumbers.pde
Created September 3, 2011 14:32
Processing Tutorial #solo11
/*
#myrandomnumber Tutorial
[email protected]
April, 2010
*/
//This is the Google spreadsheet manager and the id of the spreadsheet that we want to populate, along with our Google username & password
SimpleSpreadsheetManager sm;