Skip to content

Instantly share code, notes, and snippets.

View joyrexus's full-sized avatar

J. Voigt joyrexus

View GitHub Profile
@joyrexus
joyrexus / uid.py
Last active December 15, 2015 00:38
Unique ID generator for prior project.
#!/usr/bin/env python
'''
Generate a unique primary key ID based on a combination of
subject, session, and row (optionally) IDs.
'''
epilog = '''
Note that one can use positional args instead of named args.
@joyrexus
joyrexus / tsv2sql.py
Created March 15, 2013 23:14
Convert a tab-separated-value formatted file to a set of SQL insert or update statements
#!/usr/bin/env python
'''
Convert a TSV-formatted file to a set of SQL insert or update statements.
'''
import argparse
from datastore.table import Reader
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--mode', choices=('insert', 'update'), default='update')
@joyrexus
joyrexus / xls2tsv.py
Created March 15, 2013 23:19
Print worksheet from an excel workbook (.xls files).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''xls2tsv - print the contents of a worksheet from an excel workbook.'''
import sys
import xlrd
import optparse
parser = optparse.OptionParser()
@joyrexus
joyrexus / quick.coffee.md
Created March 15, 2013 23:49
Quick coffee tips (fenced version for GH syntax highlighting)
@joyrexus
joyrexus / README.md
Last active December 15, 2015 00:38
Convert your literate script to a code-fenced variant.
@joyrexus
joyrexus / data.table.py
Last active December 15, 2015 00:49
Read and manipulate .tsv data files.
'''
Read in a TSV (tab-separated values) file as an array of dicts.
Usage:
r = Reader('tests/tsv/init.tsv')
print r
print r.rows
print r.column('name')
@joyrexus
joyrexus / ives.coffee.md
Last active October 25, 2018 07:13
Self-interpolating-litcoffee rendering hack.

St Ives

class Slider
  constructor: (@i, @range) -> 
    @ui = '<span class="slider">' + @i + '</span>'

slider = (i, range) -> new Slider i, range

There are #{sacks} sacks
Every sack had #{cats.ui} cats

@joyrexus
joyrexus / demo.coffee.md
Created March 19, 2013 19:12
Demo selective extraction of code blocks via Marked.js.

Demo

console.log 'hello'
print 'world!'
@joyrexus
joyrexus / demo.coffee.md
Last active December 15, 2015 04:20
Render us some litcoffee via strapdown.js

Demo

Render your markdown via strapdown.js.

Try:

coffee render.coffee.md demo.coffee.md | browser

Or:

@joyrexus
joyrexus / today.coffee
Last active December 15, 2015 05:19
Print today's date (M-D-Y)
console.log new Date().toString().split(' ')[1..3].join('-') # M-D-Y