Skip to content

Instantly share code, notes, and snippets.

@bmabey
bmabey / memoize_fn.clj
Created August 10, 2011 05:00
memoized anonymous functions in clojure
; inspired from http://stackoverflow.com/questions/3906831/how-do-i-generate-memoized-recursive-functions-in-clojure
(defmacro memoize-fn
"Produces a memoized anonymous function that can recursively call itself."
[fn-name & fn-args]
`(with-local-vars
[~fn-name (memoize
(fn ~@fn-args))]
(.bindRoot ~fn-name @~fn-name)
@~fn-name))
@jeremytregunna
jeremytregunna / linked-list.ll
Created August 14, 2011 00:18
Linked List in LLVM IR
;; Linked list implementation
;; I compile it like this on Mac OS X:
;
; llvm-as linked-list.ll
; llc linked-list.bc
; as linked-list.s -o linked-list.o
; ld /usr/lib/crt1.o linked-list.o -o linked-list -lSystem -macosx_version_min 10.6
;; Type aliases
%free_func = type void (i8*)*
@tomykaira
tomykaira / core.clj
Created October 29, 2011 01:20
save your followers in neo4j
(ns friends-relationship-twitter.core
(:require [borneo.core :as neo]
twitter
[oauth.client :as oauth]))
(def oauth-consumer (oauth/make-consumer "KEY"
"SECRET"
"https://api.twitter.com/oauth/request_token"
"https://api.twitter.com/oauth/access_token"
"https://api.twitter.com/oauth/authorize"
@uhlenbrock
uhlenbrock / deploy.rb
Created December 14, 2011 17:36
Precompile assets locally for Capistrano deploy
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
@dherman
dherman / 1-recursive.js
Created February 7, 2012 20:10
turning recursion into iteration in JS
// Version 1. Simple recursive function. Blows the stack for large nodes.
function replace(node, from, to) {
switch (node.type) {
case IF:
return {
type: IF,
test: replace(node.test, from, to),
then: replace(node.then, from, to),
else: replace(node.else, from, to)
};
@kristianlm
kristianlm / chicken-scheme-opengl-hello-world.scm
Created February 17, 2012 13:00
chicken scheme - opengl hello world in 35 lines (gl, glu, glut)
(begin
(require-extension gl)
(require-extension glut)
(require-extension glu)
(glut:InitDisplayMode (+ glut:DOUBLE glut:RGBA glut:DEPTH))
(glut:InitWindowSize 400 300)
(glut:CreateWindow "gl hello world"))
(begin
@robertsosinski
robertsosinski / gist:2691813
Created May 14, 2012 04:37
Testing Postgres Listen/Notify using EventMachine
require 'rubygems'
require 'pg'
require 'eventmachine'
module Subscriber
def initialize(pg)
@pg = pg
end
def notify_readable
@samth
samth / http-client.rkt
Created May 31, 2012 15:40
A simple http client in Racket by p4bl0
#lang racket/base
;; By http://www.reddit.com/user/p4bl0 at http://paste.fulltxt.net/FZ4-HeULc
;; `racket -il readline -t http-client.rkt`
;; then you can use (M "/path/...") where M can be get, post, put, delete.
;; When authenticated, you can logout using (logout).
;; The host and port can be changed using set!.
(require racket/tcp
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet
@NeQuissimus
NeQuissimus / ..install.sh
Created July 23, 2012 14:16
ArchLinux on MacBook Pro 5,5
# 1. Install from NetInst CD, via Ethernet, minimal set of packages, use syslinux boot loader!
# 2. Initialize Pacman, hit random keys during init
pacman-key --init
pacman-key --populate archlinux
# 3. Install X and Awesome WM
pacman -Sy xorg-server xorg-xinit xorg-utils xorg-server-utils xterm awesome xf86-video-vesa
# 4. Install nvidia drivers