Skip to content

Instantly share code, notes, and snippets.

View mhausenblas's full-sized avatar
🤷‍♂️
weeks of coding can save you hours of planning!

Michael Hausenblas mhausenblas

🤷‍♂️
weeks of coding can save you hours of planning!
View GitHub Profile
@thurloat
thurloat / FoulLine.py
Created June 4, 2010 14:36
Getting Google Storage working in Python App Engine
#Bring in the boto library
import boto
#Load the configuration variables from your .boto file
config = boto.config
"""
FAIL.
""""
@bellbind
bellbind / microdata.py
Created September 13, 2010 10:42
[python] HTML5 microdata parser
"""HTML5 microdata parser for python 2.x/3.x
- it requires lxml
- microdata specification: http://dev.w3.org/html5/md/
"""
try: from urllib.parse import urljoin
except: from urlparse import urljoin
import lxml.html as lhtml
def items(html, types=None, uri=""):
@chrisyour
chrisyour / Folder Preferences
Created December 4, 2010 20:05
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern
@LeifW
LeifW / Treeify.scala
Created July 15, 2011 22:27
Turn RDF graphs into JSON trees.
import org.scardf._
object Treeify {
def localName(res:UriRef) = ".*[#/]".r.split(res.uri)(1)
def apply(start:GraphNode) = {
val graph = start.graph
def treeify(subject:SubjectNode, visited:Set[SubjectNode]):Map[String,Any] = Map(
jQuery(document).ready(function(){
rdfstore.create(function(store) {
var myLocLat = 0;
var myLocLng = 0;
var nearbyRadius = 0.5; // in km
// extracts data from remote SPARQL endpoint
var queryStr2 = 'PREFIX lgdo:<http://linkedgeodata.org/ontology/>\
CONSTRUCT {\
@msmith
msmith / couchdb-ec2-install.sh
Created August 25, 2011 17:26
Set up CouchDB on EC2
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"
@lancejpollard
lancejpollard / index.md
Created March 15, 2012 18:12
Math for Coders

Sets =~ Arrays

A set is basically an array of unique items.

(A,B)

Ordered set.

[1, 2] != [2, 1]
@mhausenblas
mhausenblas / simple-rdf-store.py
Created March 30, 2012 13:52
Simple RDF store in ZooKeeper
import zookeeper, threading, sys
ZOO_OPEN_ACL_UNSAFE = {"perms":0x1f, "scheme":"world", "id" :"anyone"};
class ZKSimpleRDFStore(object):
SERVER_PORT = 2181
def __init__(self):
self.host = "localhost:%d" % self.SERVER_PORT
self.connected = False
@s3u
s3u / udfs.md
Created April 8, 2012 02:39
ql.io - User Defined Functions

User Defined Functions

A user-defined function is a Javascript function that can be used in where clauses and columns clauses.

UDFs in the Where Clause

When specified in the where clause, a UDF can apply custom logic to filter out or re-shape a row from a data set.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"