Skip to content

Instantly share code, notes, and snippets.

View rjungemann's full-sized avatar

Roger Jungemann rjungemann

View GitHub Profile
/* Converts any Io method (You'll have to wrap CFunctions in an Io method for those to work) to continuation passing style */
/* This is working code, not code someone posted asking for help. Feel free to use how you want, public domain. */
Object convertToCPS := method(str,
m := self getSlot(str)
blk := Block clone
blk setArgumentNames(getSlot("m") argumentNames append("__k"))
blk setMessage(Message clone fromString("__k call(self performWithArgList(\"#{str}\", call evalArgs append(__k)))" interpolate))
self setSlot("#{str}CPS" interpolate, blk setIsActivatable(true))
)
WEBGL MODULE: ../lib/webgl.js
create program passed! ( {"id":1} )
create shader passed! ( {"type":35633,"id":2} )
create shader passed! ( {"type":35632,"id":3} )
shader source passed! ( )
shader source passed! ( )
compile shader passed! ( )
compile shader passed! ( )
attach shader passed! ( )
attach shader passed! ( )
@tj
tj / equivalent.js
Created August 24, 2011 00:21
example of backbone-style routing with Express
app.get('/help', function(req, res){
res.send('some help');
});
app.get('/search/:query/p:page', function(req, res){
var query = req.params.query
, page = req.params.page;
res.send('search "' + query + '", page ' + (page || 1));
});
@rjungemann
rjungemann / r.markdown
Created August 25, 2011 05:42
Quick Intro to Manipulating Tabular Data in R

Quick Intro to Manipulating Tabular Data in R

Getting Started

Download R here.

Run R. You will be greeted by the R console. You can interactively type in commands and it will respond, allowing you to experiment quickly.

@creationix
creationix / greengl.js
Created August 30, 2011 00:07
A simple sample showing how to use my "sdl" and "webgl" node libraries
// To test on Ubuntu, install the requirements to build
// `apt-get install libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libgles2-mesa-dev`
// Then load the node libraries needed `npm install sdl webgl`
// Then run this script!
SDL = require('sdl');
gl = require('webgl');
SDL.init(SDL.INIT.VIDEO);
var screen = SDL.setVideoMode(640, 480, 0, SDL.SURFACE.OPENGL);
@rtomayko
rtomayko / optparse-template.rb
Last active June 3, 2023 03:16
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@utaal
utaal / Makefile
Created September 5, 2011 16:42
webserver using libuv
webserver: webserver.c libuv/uv.a http-parser/http_parser.o
gcc -I libuv/include \
-lrt -lm -lpthread -o \
webserver webserver.c \
libuv/uv.a http-parser/http_parser.o
libuv/uv.a:
$(MAKE) -C libuv
http-parser/http_parser.o:
@nikcub
nikcub / mails.sh
Created September 12, 2011 19:43
Send email with Mail.app from command line script
#!/bin/sh
/usr/bin/osascript > /dev/null <<ASCPT
set stdinText to "$(cat | sed -e 's/\\/\\\\/g' -e 's/\"/\\\"/g')"
set recName to "Nik Cubrilovic"
set recAddr to "[email protected]"
set theSubject to "Email from standard input"
tell application "Mail"
@creationix
creationix / ffi-sdl.lua
Created September 13, 2011 06:52
Using SDL from luajit's built-in ffi module
-- load the luajit ffi module
local ffi = require "ffi"
-- Parse the C API header
-- It's generated with:
--
-- echo '#include <SDL.h>' > stub.c
-- gcc -I /usr/include/SDL -E stub.c | grep -v '^#' > ffi_SDL.h
--
ffi.cdef(io.open('ffi_SDL.h', 'r'):read('*a'))
-- Load the shared object
@raggi
raggi / fiber_race.rb
Created September 15, 2011 23:34
An example race condition using fibers
## SCROLL DOWN FOR THE RACE, THE FOLLOWING IS JUST UTILITY FROM COMMONLY USED CODE.
# Author:: Mohammad A. Ali (mailto:[email protected])
# Copyright:: Copyright (c) 2008 eSpace, Inc.
# License:: Distributes under the same terms as Ruby
require 'fiber'
class Fiber