Skip to content

Instantly share code, notes, and snippets.

View phrozen's full-sized avatar

Guillermo Estrada phrozen

View GitHub Profile
class Dicer
def Dicer.roll(faces, n = 1)
result = 0
n.times { result = result + 1 + rand(faces) }
result
end
end
class Dice
attr_reader :faces, :rolls, :result
@phrozen
phrozen / hash.go
Created June 11, 2011 00:03
Simple utility to obtain multiple hashes of a file from the command line.
/*
Hash - Guillermo Estrada
Marko Mikulicic
Kyle Lemons
Simple utility to obtain the MD5 and/or SHA-1
of a file from the command line.
2011
*/
@phrozen
phrozen / BundlerOutput.txt
Created February 23, 2012 23:45
Error Haml not finding markdown
C:\Users\some\user> bundle install
Fetching source index for http://rubygems.org/
Using rack (1.4.1)
Using adsf (1.0.1)
Using builder (3.0.0)
Using coffee-script-source (1.2.0)
Using multi_json (1.0.4)
Using execjs (1.3.0)
Using coffee-script (2.2.0)
Using haml (3.1.4)
@phrozen
phrozen / SegfaultNanocWindows.txr
Created February 24, 2012 00:07
Nanoc Segfaults Ruby1.9.3p125
Loading site data...
Compiling site...
C:/Ruby193/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/commands/compile.rb:220: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
-- Control frame information -----------------------------------------------
c:0044 p:---- s:0183 b:0183 l:000182 d:000182 CFUNC :new
c:0043 p:0037 s:0180 b:0180 l:000d9c d:000d9c METHOD C:/Ruby193/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/commands/compile.rb:220
c:0042 p:0070 s:0175 b:0175 l:0007e8 d:000174 BLOCK C:/Ruby193/lib/ruby/gems/1.9.1/gems/nanoc-3.3.1/lib/nanoc/cli/commands/compile.rb:155
c:0041 p:---- s:0171 b:0171 l:000170 d:000170 FINISH
@phrozen
phrozen / main.go
Created March 28, 2012 23:51
Peter De Jong Attractors in Go
/*
Processing version
http://www.openprocessing.org/sketch/2097
by Thor Frølich
Go version
by Guillermo Estrada
*/
package main
@phrozen
phrozen / sqlitemark.d
Created April 16, 2012 00:40
SQLite benchmark program
/*********************************************************************************************************************************************
** GNU LESSER GENERAL PUBLIC LICENSE
** Version 2.1, February 1999
**
** Copyright (C) 1991, 1999 Free Software Foundation, Inc.
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
** Everyone is permitted to copy and distribute verbatim copies
** of this license document, but changing it is not allowed.
**
** This is the first released version of the Lesser GPL. It also counts
@phrozen
phrozen / sqlitemark.go
Created April 16, 2012 01:00
SQLite benchmark program in Go
package main
import (
"bitbucket.org/jpoirier/cpu"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/mattn/go-sqlite3"
"math/rand"
"os"
@phrozen
phrozen / sqlitemark.lua
Created July 6, 2012 19:53
SQLite ffi library benchmark with LuaJit implementation.
local sql = require "ffi/ljsqlite3"
-- Global Variables
local singledb = "single.sqlite"
local manydb = "multi.sqlite"
local elapsed = 0
local times = {}
local values = 1000000
local tables = 1000
local x, y, z = {}, {}, {}
@phrozen
phrozen / deJong.java
Created September 13, 2012 20:04
deJong to port to Love2D Luajit
//Attractors and Fractals
//Grant Schindler, 2008
//Variables and Coefficients (Initial Values) ------------------------------------
float a = 1.78125, b = -0.78125, c = 1.90625, d = 2.65625, e = 0.7, f = -1.1; //Coefficients
float x = 0.6, y = 0.9, z = 0.3; //Variables
float xn,yn,zn,la,lb,lc,ld; //Temporary Copies of Variables, Coefficients
int N = 512, u, v; //Image Size, Pixel Coordinates
PImage img = createImage(N,N,RGB); //Image Itself
@phrozen
phrozen / main.go
Last active December 25, 2016 18:00
STL reader
package main
import (
"bufio"
"bytes"
"encoding/binary"
"flag"
"fmt"
"github.com/spf13/nitro"
"io"