Skip to content

Instantly share code, notes, and snippets.

$ brew --config; brew doctor
HOMEBREW_VERSION: 0.8
HEAD: a2185815eb67d9d54230724bd54c6ba7a4277ae9
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: dual-core 64-bit core2
OS X: 10.6.8
Kernel Architecture: i386
@xandkar
xandkar / fibs.erl
Last active October 5, 2017 09:37
Fibonacci versions in Erlang. Naively recursive, array and list.
%%%----------------------------------------------------------------------------
%%% $ erl -noshell -s fibs main 40
%%% TRANSLATED ARRAY: 102334155 0.001755 seconds
%%% TRANSLATED LIST: 102334155 0.000048 seconds
%%% REVERSE ORDER LIST: 102334155 0.000004 seconds
%%% MINIMAL ARITHMETIC: 102334155 0.000001 seconds
%%% NAIVE RECURSIVE: 102334155 8.383385 seconds
%%%----------------------------------------------------------------------------
@xandkar
xandkar / gist:2483917
Created April 24, 2012 21:22
GODI blues
$ godi_perform -build apps-oasis
### Fetching godi-ocaml-data-notation (if necessary)
### Fetching conf-x11 (if necessary)
### Fetching conf-tcltk (if necessary)
### Fetching godi-ocaml-labltk (if necessary)
### Fetching godi-core-script (if necessary)
### Fetching conf-opengl (if necessary)
### Fetching conf-glut (if necessary)
### Fetching godi-lablgl (if necessary)
### Fetching godi-lablgtk2 (if necessary)
@xandkar
xandkar / pervasives.ml
Created May 7, 2012 04:28
List of alphanumeric vals from Pervasives module.
abs
abs_float
acos
asin
at_exit
atan
atan2
bool_of_string
ceil
char_of_int
@xandkar
xandkar / get_home_dir.erl
Created May 25, 2012 15:11
Another way to get user's home dir in Erlang.
init:get_argument(home). %%% {ok,[["/home/username"]]}
@xandkar
xandkar / awk-one-liners.awk
Created June 1, 2012 15:13
HANDY ONE-LINE SCRIPTS FOR AWK
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
@xandkar
xandkar / build-erlang-r15b.sh
Created July 13, 2012 21:37 — forked from bryanhunter/build-erlang-r15b.sh
Build Erlang R15B on a fresh Ubuntu box (tested on Ubuntu 11.10)
#!/bin/bash
# Pull this file dowm, make it executable and run it with sudo
# wget https://raw.github.com/gist/1603037/build-erlang-r15b.sh
# chmod u+x build-erlang-r15b.sh
# sudo ./build-erlang-r15b.sh
if [ $(id -u) != "0" ]; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
@xandkar
xandkar / lookup.awk
Created August 29, 2012 21:30
AWK dates lookup table
awk 'BEGIN{
m=split("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",d,"|")
for(o=1;o<=m;o++){
date[d[o]]=sprintf("%02d",o)
}
}
{
gsub(/\[/,"",$4); gsub(":","/",$4); gsub(/\]/,"",$5)
n=split($4, DATE,"/")
day=DATE[1]
@xandkar
xandkar / zipn.erl
Created October 19, 2012 14:04
Zip N lists
%% ----------------------------------------------------------------------------
%% Jesse Gumm <gumm@sigma-star.com>
%% http://erlang.org/pipermail/erlang-questions/2012-October/069832.html
%%
zipn(List) ->
zipn([],List).
zipn(Acc,[]) ->
lists:map(fun lists:reverse/1,Acc);
@xandkar
xandkar / concurrent_port_scanner.hs
Created October 20, 2012 05:00
Concurrent port scanner in Haskell
-- http://blog.moertel.com/articles/2004/03/13/concurrent-port-scanner-in-haskell
module Main (main) where
import Control.Concurrent
import Control.Exception
import Data.Maybe
import Network
import Network.BSD
import System.Environment