Skip to content

Instantly share code, notes, and snippets.

@wstucco
wstucco / elixir_brainfuck_interpreter_part_2.exs
Last active August 29, 2015 14:09
elixir_brainfuck_interpreter_part_2.exs
defmodule Brainfuck do
# opcodes
@op_vinc "+" # increment value at memory address
@op_vdec "-" # decrement value at memory address
@op_pinc ">" # increment memory address
@op_pdec "<" # decrement memory address
@op_putc "." # output byte at memory address
@op_getc "," # input byte into memory address
@op_lbeg "[" # loop begin
defmodule Brainfuck do
# opcodes
@op_vinc "+" # increment value at memory address
@op_vdec "-" # decrement value at memory address
@op_pinc ">" # increment memory address
@op_pdec "<" # decrement memory address
@op_putc "." # output byte at memory address
@op_getc "," # input byte into memory address
@op_lbeg "[" # loop begin
@wstucco
wstucco / state_machine.pde
Created February 28, 2014 17:54
Processing.org state machine
interface State {
public State nextState();
}
class IdleState implements State {
public State nextState() {
return new ScanState();
}
}
@wstucco
wstucco / example-1.1.go
Last active December 27, 2015 01:59
I tried Go and I liked it
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@wstucco
wstucco / git_rewrite_email
Last active December 17, 2015 08:28
change committer email and rewrite history
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "<email>" ];
then
GIT_COMMITTER_EMAIL="<new-email>";
GIT_AUTHOR_EMAIL="<new-email>";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
@wstucco
wstucco / require_valid_argument_1.php
Last active December 15, 2015 02:39
three different versions of a function handling parameters validation
<?php
// Takes the parameter value and validate it against a
// list of known validators and throws an exception if it doesn't
//
// params:
// mixed $value
// string $validator
//