Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
import csv
csv.register_dialect('custom',
delimiter=',',
doublequote=True,
escapechar=None,
quotechar='"',
quoting=csv.QUOTE_MINIMAL,
@bdarcus
bdarcus / greader2bibo
Created December 18, 2010 21:38
a little script that takes my starred google reader items and converts to BIBO rdf
#! /usr/bin/env python
import sys
import re
from lxml import etree
from urlparse import urlparse
from rdflib import Literal, Namespace, URIRef, ConjunctiveGraph
"""
convert an atom feed from google reader into BIBO RDF
"""
@bdarcus
bdarcus / git-date.sh
Created January 15, 2011 03:00
how to get the updated date for a file from git, in proper iso format
$ git log --date=iso --pretty=format:"%ad" -1 apa.csl
@bdarcus
bdarcus / gitstyles.php
Created January 17, 2011 21:48
a little PHP app to create a CSL index page from a git repo
<?php
include('lib/glip.php');
$repo = new Git('test.git');
$master_name = $repo-->getTip('master');
$master = $repo-->getObject($master_name);
?>
@bdarcus
bdarcus / csl-repo.rb
Created January 18, 2011 01:51
using grit to interact with git repo
require 'rubygems'
require 'grit'
include Grit
repo = Repo.new('styles')
# get head
head = repo.commits.first
# get date for commit
@bdarcus
bdarcus / slugify.js
Created February 5, 2011 18:22
a slugify function for js
/* see also http://www.milesj.me/resources/snippet/13 */
function slugify(text) {
return text.toLowerCase().replace(/(_|\s)/g, "-");
}
@bdarcus
bdarcus / citenode.coffee
Created February 6, 2011 18:24
hello world in coffeescript, using express framework for node.js
# Goal:
# $ npm install citenode
# $ citenode start [optional parameters]
# etc.
# Should be completely independent of any particular
# application.
express = require 'express'
fugue = require 'fugue'
citeproc = require 'citeproc'
@bdarcus
bdarcus / pandoc.json
Created February 8, 2011 01:15
Pandoc document model dumped to JSON.
[
{
"docTitle":[
{
"Str":"The"
},
"Space",
{
"Str":"Title"
}
@bdarcus
bdarcus / liststyles.py
Created February 13, 2011 15:18
grab a list of style names from repo using gh api
import json, urllib, os
repo = 'citation-style-language/styles'
def list():
response = urllib.urlopen('http://github.com/api/v2/json/blob/full/' + repo + '/master')
content = response.read()
files = json.loads(content)
for file in files['blobs']:
name = file['name']
@bdarcus
bdarcus / ghstyles.sh
Created February 19, 2011 16:19
github api to get all files from styles master
$ curl http://github.com/api/v2/json/blob/all/citation-style-language/styles/master