Skip to content

Instantly share code, notes, and snippets.

View doppioslash's full-sized avatar

Claudia Doppioslash doppioslash

View GitHub Profile
@nilium
nilium / test.bmx
Created March 16, 2009 23:21
Example of Lua reflection code
' test.bmx
Type Foo {expose}
Method Bazzle( obj:Bar )
If obj = Null Then
Print "Null obj"
Else
Print obj.ToString()
EndIf
@dysinger
dysinger / Makefile
Created April 16, 2009 03:21
Simple Makefile for Lisp Flavored Erlang
LFE_SRC := $(wildcard src/*.lfe)
LFE_BEAM := $(LFE_SRC:src/%.lfe=ebin/%.beam)
INCL_DIRS := $(wildcard deps/*/include) include
EBIN_DIRS := $(wildcard deps/*/ebin) ebin
FLAGS := -noshell -noinput $(INCL_DIRS:%=-I %) $(EBIN_DIRS:%=-pa %)
OPTIONS := {outdir,"ebin"}
compile: $(LFE_BEAM)
@henrik
henrik / example.m
Created June 27, 2010 11:48
Locating the keyboard (UIKeyboard) on iOS 4, to e.g. add a custom button.
- (void)someSetupMethod {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
}
- (void)someTeardownMethod {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
}
@przemoc
przemoc / fibonacci.asm
Created July 19, 2010 14:06
Fibonacci n-th number (modulo 2^32) in x86 assembler
; Fibonacci n-th number (modulo 2^32)
;
; input:
; ecx = n
; modifies:
; eax, ecx, edx
; ouput:
; eax = number
; size:
; 15 bytes
@sanxiyn
sanxiyn / lisp.c
Created August 14, 2010 04:16
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@johnthethird
johnthethird / http_client_with_cache.coffee
Created September 1, 2010 03:38
HTTPClientWithCache for Titanium in CoffeeScript
###
------> HTTPClientWithCache <------
This class is a wrapper around the standard Titanium.Network.HTTPClient(), but it adds a
few nice features:
* A cache backed by a SQLite database. All HTTPClientWithCache instances use the same database table, with
the primary cache key being a hash of the full URL (and any data parameters in a POST)
* The cache is automatically pruned before each query
* A retry mechanism, so that you can retry a particular query a number of times before failing.
@robfe
robfe / Extensions.cs
Created October 11, 2010 08:45
ObservePropertyChanged extension method (INotifyPropertyChanged.Property => IObservable)
public static class Extensions
{
public static IObservable<TProperty> ObservePropertyChanged<TNotifier, TProperty>(
this TNotifier notifier,
Expression<Func<TNotifier, TProperty>> propertyAccessor,
bool startWithCurrent = false)
where TNotifier : INotifyPropertyChanged
{
// Parse the expression to find the correct property name.
@ibdknox
ibdknox / socket.clj
Created October 31, 2010 06:48
compojure with websockets
(ns wl.core
(:use compojure.core, aleph.core, aleph.http, hiccup.core, hiccup.page-helpers)
(:require [compojure.route :as route])
(:gen-class))
(def broadcast-channel (channel))
(defn chat-handler [ch handshake]
(receive ch
(fn [name]
@djpowell
djpowell / finger_tree_stats.clj
Created November 11, 2010 14:53
fingertree stats
(ns finger-tree-stats
(:use [clojure.data.finger-tree]))
(defrecord stats [^double number ^double mean ^double variance])
(def null-stats (stats. 0 0 Double/NaN))
(defn make-stats
[^double x]
(stats. 1 x 0))
@ryanflorence
ryanflorence / static_server.js
Last active March 13, 2024 08:05
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);