Skip to content

Instantly share code, notes, and snippets.

@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
//
@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 / 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 / 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();
}
}
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 / 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
@wstucco
wstucco / app.json
Last active August 29, 2015 14:10
OpenFin
{
"env": "2.0.7.0",
"startup_app": {
"name": "Hello Open Fin",
"url": "http:/localhost:5000/index.html",
--> "uuid": "OpenFinHelloWorld",
.
.
.
}
/*
* Copyright (C) 2012, Tino Didriksen Consult
* Developed by Tino Didriksen <tino@didriksen.cc>
* Modified by Massimo Ronca
*
* This file is part of Benchmarks
*
* Benchmarks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@wstucco
wstucco / main.rb
Last active May 28, 2019 00:24
Opal Meteor
if Meteor.client?
user = User.new('Admin')
puts user
puts user.admin?
puts "hello from client #{user.name}!"
end
if Meteor.server?
user = User.new('Massimo')
puts user

Keybase proof

I hereby claim:

  • I am wstucco on github.
  • I am massimo (https://keybase.io/massimo) on keybase.
  • I have a public key whose fingerprint is 4538 9292 4496 E67A 6CE2 BF39 5D2C 6772 9E02 C529

To claim this, I am signing this object: