Skip to content

Instantly share code, notes, and snippets.

@rdm
rdm / resolve.py
Created August 28, 2012 15:10 — forked from ericmoritz/resolve.py
#!/usr/local/bin/python
import re, os, sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "relux.settings.local")
import inspect
from django.conf import settings
from django.core import urlresolvers
urlconf = settings.ROOT_URLCONF
urlresolvers.set_urlconf(urlconf)
@rdm
rdm / gist:5266251
Last active December 15, 2015 13:19
a clunky example of a git sync script This is not in any way general, nor even efficient - it's the sort of thing that I evolve by addressing specific problems when they arise. In particular: The pip install stuff is relevant because this project uses django with an evolving list of requirements. the /tmp/requirements.txt is to avoid spending a …
#!/bin/sh
set -e
trap 'echo FAILED (need git push -u on new branch?)' EXIT
[ -r "$VIRTUAL_ENV" ]
branch=`git branch|awk '/\*/{print $2}'`
find . -iname '*.pyc' -print0 | xargs -0 rm -f
git fetch --prune origin
git pull origin $branch
git pull origin develop
while ! [ -e setup/requirements.txt ]; do cd -P .; cd ..; done
blocks 3
max depth 2
max block 143
scripts 2
max script 51
@rdm
rdm / webgl.html
Created January 12, 2014 03:34
A quick demo of something paint-like in webgl
<html>
<title>WebGL Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
function useShader(gl, program, scriptId) {
var shaderScript= document.getElementById(scriptId); console.log('shaderScript: ',shaderScript);
var shaderType= gl[shaderScript.type.replace(/.*\//,'')]; console.log('shaderType: ',shaderType);
var shader= gl.createShader(shaderType); console.log('shader: ',shader);
gl.shaderSource(shader, shaderScript.text);
@rdm
rdm / defs.ijs
Created January 23, 2014 22:57
example of gerunds as first order functions
ing=: `''
evoke=:adverb define NB. (
'`yes please'=. ,&<~m
please f.
)
apply=:dyad define NB. (
(x evoke)@(y evoke) ing
)
@rdm
rdm / Example use:
Created January 30, 2014 22:07
Draft: extract data from wavxml files (or similar xml files)
filename=: 'name'&extract_fromxmlfile_
directory=: 'hash'&extract_fromxmlfile_
sosgatetime=: ('utterance';'startofspeechgate';'time')&extract_fromxmlfile_
sosgatevalue=: ('utterance';'startofspeechgate';'value')&extract_fromxmlfile_
sostime=: ('utterance';'startofspeech';'time')&extract_fromxmlfile_
sosvalue=: ('utterance';'startofspeech';'value')&extract_fromxmlfile_
eostime=: ('utterance';'endofspeech';'time')&extract_fromxmlfile_
eosvalue=: ('utterance';'endofspeech';'value')&extract_fromxmlfile_
finalresult=: ('utterance';'finalresult';'value')&extract_fromxmlfile_
confidence=: ('utterance';'finalresult';'confidence')&extract_fromxmlfile_
cocurrent 'CurveFp'
Help=: 'Elliptic Curve over the field of integers modulo a prime.'
create=:3 :0
NB. The curve of points satisfying y^2 = x^3 + a*x + b (mod p).
'P A B'=: x:&> y
poly=: B,A,0,1
)
p=:3 :'P'
a=:3 :'A'
@rdm
rdm / copy.ijs
Created February 6, 2014 13:40
require 'csv'
stordir=: <'c:\voxtst\' NB. note < and trailing \
NB. Convert the csv file to a boxed J array
csvdata=: readcsv 'c:\voxtst\prophecy.csv'
NB. filenames
sourcefnames=: }. 0 {"1 csvdata
targetfnames=: stordir,each (}. 2 {"1 csvdata),each <'.wav'
assert (-: ~.) targetnames NB. unique file names
@rdm
rdm / nif.ijs
Created February 16, 2014 21:42
Draft nif handling code. Parses nif.xml and some Morrowing nif files
NB. roughly patterened after http://rpmfind.net/linux/RPM/sourceforge/p/py/pyffi/OldFiles/PyFFI-0.0-1.noarch.html
NB. you should not expect to read this any faster than you read the whole of PyFFI
NB. and if you are new to J you should also expect to spend some time learning the language
NB. recommendation: take breaks occasionally, play with this, try to make it fun
require '~user/nifxml.ijs'
coinsert 'nifxml' NB. for cond expressions
NB. FIXME: do not inherit from nifxml - factor out the expr support
NB. FIXME: most of this nif.ijs should be factored out into readnif.ijs which inherits from nif.ijs
@rdm
rdm / gist:3170282b06532400ccc8
Created March 13, 2015 13:03
keybase.io verfication
### Keybase proof
I hereby claim:
* I am rdm on github.
* I am rdm (https://keybase.io/rdm) on keybase.
* I have a public key whose fingerprint is D3CE 2BCC 07BC 89E2 B49B 8822 6C88 FCF8 618C C6E0
To claim this, I am signing this object: