Skip to content

Instantly share code, notes, and snippets.

@ianbishop
ianbishop / MessagePassing1.rb
Created March 23, 2011 22:30
Simple message passing example in Ruby (1)
class Repeater
@@subscribers = []
# Add the new subscriber to our list of subscribers
def subscribe(newSubscriber)
@@subscribers << newSubscriber
end
# Send the message to all of our subscribers
def broadcast(message)
@zentrope
zentrope / grib2-local.scala
Created June 27, 2011 18:40
Fragment: decoding weather strings in a weather.gov grib2 file
// convert a byte into a list of ones and zeros
def bits(num: Int): List[Int] = (for (i <- Range(0,8)) yield (((num << i) & 0xff) >>> 7)).toList
// given a list, take the first N bits
def next(bits: List[Int], numBits: Int) = {
val filler = List[Int](8 - numBits) map (_ => 0)
val bitList = filler ++ bits.take(numBits)
@michiakig
michiakig / three.cljs
Created August 19, 2011 20:53
three.js demo in ClojureScript
(ns three.demo)
(def camera (THREE.Camera. 75 (/ window/innerWidth
window/innerHeight) 1 10000))
(set! (.z (.position camera)) 1000)
(def scene (THREE.Scene.))
(def geometry (THREE.CubeGeometry. 200 200 200))
(def obj (js/Object.))
(set! (.color obj) 0xff0000)
(set! (.wireframe obj) true)
(def material (THREE.MeshBasicMaterial. obj))
@odyssomay
odyssomay / SpecRunner.html
Created October 14, 2011 12:35
Clojurescript testing using jasmine
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css">
<script type="text/javascript" src="jasmine/jasmine.js"></script>
@stonegao
stonegao / evolvefn.clj
Created November 3, 2011 03:22 — forked from lspector/evolvefn.clj
Clojure code for a simple genetic programming system, for demonstration purposes.
(ns evolvefn) ;; Lee Spector (lspector@hampshire.edu) 20111018
;; This code defines and runs a genetic programming system on the problem
;; of finding a function that fits a particular set of [x y] pairs.
;; The aim here is mostly to demonstrate how genetic programming can be
;; implemented in Clojure simply and clearly, and several things are
;; done in somewhat inefficient and/or non-standard ways. But this should
;; provide a reasonable starting point for developing more efficient/
;; standard/capable systems.
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 15, 2024 23:32
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@Answeror
Answeror / gist:3832085
Created October 4, 2012 08:02
Activate virtualenv in blender
def activate_virtualenv(name):
"""Activate given virtualenv.
Virtualenv home folder is given by environment variable ``WORKON_HOME`` or
``~/Envs`.
"""
if 'WORKON_HOME' in os.environ:
home = os.environ['WORKON_HOME']
else:
home = os.path.expanduser(os.path.join('~', 'Envs'))
@ytomino
ytomino / dt.nim
Created January 12, 2016 22:16
Trying dependent types in nim
type Cell[T] = ref object
car: T
cdr: Cell[T]
type List[T, N] = distinct Cell[T]
proc makeNil[T]: List[T, range[0..0]] = nil
proc makeCons[T, N](car: T; cdr: List[T, N]): auto =
type N1 = range[0..high(N)+1]
@okdistribute
okdistribute / index.js
Last active January 28, 2019 08:29
dat with webrtc
var webrtc = require('webrtc-swarm')
var signalhub = require('signalhub')
var hyperdrive = require('hyperdrive')
var memdb = require('memdb')
var pump = require('pump')
var DEFAULT_SIGNALHUBS = 'https://signalhub.mafintosh.com'
var drive = hyperdrive(memdb())