Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env escript
%%% This script converts an arbitrary binary file to an Erlang module with a
%%% single exported 'bin/0' function that returns the original binary.
%%%
%%% See the end of the file for how I figured out the correct terms.
main(["+debug_info" | Files]) ->
io:format("Embedding binaries with debug_info...\n"),
lists:foreach(fun(X) -> embed_file_in_beam(X, [debug_info]) end, Files);
@cjbayesian
cjbayesian / intro_to_simulation.R
Created March 22, 2013 11:50
Introduction to simulation using R
#########################################################
## Intro to Simulation - R/Stats Intro Series
## Designed by: Corey Chivers, 2013
## Department of Biology, McGill University
#########################################################
##@ 0.1 @##
rm(list=ls()) # Housekeeping
#setwd('<my working directory>') # set working dir
@milktrader
milktrader / load_spx.jl
Created December 28, 2012 14:37
getting market data into Julia
julia> require("Calendar")
julia> using Calendar
julia> require("DataFrames")
julia> using DataFrames
julia> require("Thyme")
julia> using Thyme
julia> spx = read_stock("spx.csv");
julia> check = falses(nrow(spx));
julia> for i in 1:nrow(spx)
check[i] = dayofweek(spx[i,1]) == 6
@tobyhede
tobyhede / postsql.sql
Created May 17, 2012 03:08
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@umjasnik
umjasnik / Sql.rl
Created December 27, 2011 20:06
simple SQL parser using ragel - get all tables that are referenced in a SQL statement
package de.uwefleischer.statemachines;
import java.util.Set;
import java.util.TreeSet;
public class Sql {
private static Set<String> tables;
%%{
@kevsmith
kevsmith / gist:1473809
Created December 13, 2011 20:44
deadcode detecting escript
#!/usr/bin/env escript
%% -*- erlang -*-
%% Find unused exports in a given module
%% Example: deadcode mod_foo deps/foo/ebin deps/bar/ebin
%% Assumes this script is in a file named deadcode
main([Module0|Dirs]) ->
Module = list_to_atom(Module0),
{ok, _Pid} = xref:start(foo),
@mbbx6spp
mbbx6spp / ghc
Created October 19, 2011 02:54
To fix ghc 7.0.x of all those horrible "text reloc warning" linker messages on OS X 10.7 (Lion). Based on comments to ticket #5128: http://hackage.haskell.org/trac/ghc/ticket/5128
#!/bin/sh
exedir="/usr/local/Cellar/ghc/7.0.4/lib/ghc-7.0.4"
exeprog="ghc-stage2"
executablename="$exedir/$exeprog"
datadir="/usr/local/Cellar/ghc/7.0.4/share"
bindir="/usr/local/Cellar/ghc/7.0.4/bin"
topdir="/usr/local/Cellar/ghc/7.0.4/lib/ghc-7.0.4"
pgmgcc="/usr/bin/llvm-gcc"
extraopts=-optl"-Wl,-read_only_relocs,suppress"
executablename="$exedir/ghc"
(ns type-level-tagger
{:doc "Implements State-of-the-art Unsupervised Part-of-speech Tagger
from \"Simple Type-Level Unsuperivsed POS Tagging\"
by Yoong-Keok Lee, Aria Haghighi and Regina Barzilay
(http://www.cs.berkeley.edu/~aria42/pubs/typetagging.pdf)
blog post: http://wp.me/pcW6S-x"
:author "Aria Haghighi (aria42@gmail.com)"}
(:use [clojure.java.io :only [reader]]
[clojure.contrib.duck-streams :only [with-out-writer]]
[clojure.contrib.seq-utils :only [indexed]]
@kennethkalmer
kennethkalmer / smtp-sink.rb
Created July 23, 2010 12:15
Very simple SMTP sinkhole that just prints the messages to stdout
require 'rubygems'
require 'eventmachine'
class SmtpSink < EM::Protocols::SmtpServer
def receive_data_chunk( data )
buffer.concat data
end
def receive_message
puts
@zaphar
zaphar / date_util.erl
Created May 1, 2009 06:07
set of utility functions that wrap the calendar module and erlangs now() date() and time() functions
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.