Skip to content

Instantly share code, notes, and snippets.

View fedesilva's full-sized avatar
👁️‍🗨️

federico silva fedesilva

👁️‍🗨️
View GitHub Profile
@fedesilva
fedesilva / planes.scala
Created June 6, 2012 18:22 — forked from gclaramunt/planes.scala
Very simple phantom types example
trait Flying
trait Landed
case class Plane[Status]()
def land(p:Plane[Flying])=Plane[Landed]()
def takeOff(p:Plane[Landed])= Plane[Flying]()
val plane = new Plane[Landed]()
@fedesilva
fedesilva / exprswitch.js
Created June 18, 2012 22:07
Make Javascript's switch be an expression ... sort of.
var rqRaw = (function(method){
var client = Envjs.ahcClient
switch(method) {
case "POST": return client.preparePost( xhr.url ); break;
case "GET": return client.prepareGet( xhr.url ); break;
case "PUT": return client.preparePut( xhr.url ); break;
case "DELETE": return client.prepareDelete( xhr.url ); break;
case "HEAD": return client.prepareHead( xhr.url ); break;
case "OPTIONS": return client.prepareOptions( xhr.url ); break;
default: throw "Method "+xhr.method.toUpperCase+" Not Implemented in Envjs.remoteXHR. Naughty coder was lazy!"
@fedesilva
fedesilva / proxy_nginx.sh
Created June 20, 2012 15:25 — forked from rdegges/proxy_nginx.sh
Create a HTTP proxy for jenkins using NGINX.
sudo aptitude -y install nginx
cd /etc/nginx/sites-available
sudo rm default
sudo cat > jenkins
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
@fedesilva
fedesilva / jquery.spin.js
Created June 21, 2012 17:28 — forked from innotekservices/jquery.spin.js
jQuery Plugin for Spin.js
/*
You can now create a spinner using any of the variants below:
$("#el").spin(); // Produces default Spinner using the text color of #el.
$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
$("#el").spin({ ... }); // Produces a Spinner using your custom settings.
$("#el").spin(false); // Kills the spinner.
@fedesilva
fedesilva / .tmux.conf
Created June 29, 2012 17:07 — forked from paulrouget/.tmux.conf
Paul's configurations files
set -g default-terminal "screen-256color"
set -g status-utf8 on
bind M source-file ~/.tmux/mac.session
bind L source-file ~/.tmux/linux.session
# set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# THEME
set -g status-bg black
@fedesilva
fedesilva / MersenneTwister.scala
Created August 20, 2012 23:31 — forked from jesperdj/MersenneTwister.scala
Mersenne Twister - Random number generator
// Mersenne Twister 19937
// Based on code from: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
// Note: This implementation is not thread-safe!
final class MersenneTwister (seed: Int = 5489) {
private val N = 624
private val M = 397
private val MatrixA = 0x9908b0dfL
private val UpperMask = 0x80000000L
@fedesilva
fedesilva / artifactory.conf
Created September 4, 2012 00:28
Artifactory behind nginx
upstream artifacts {
server 127.0.0.1:8081 fail_timeout=0;
}
server {
listen 80;
root /var/www;
server_name artifacts.inconcert artifacts;
$ tree cookbooks/cassandra/
cookbooks/cassandra/
├── attributes
├── definitions
├── files
│   └── default
├── libraries
├── metadata.rb
├── providers
├── README.md
import com.googlecode.objectify.annotation
import scala.annotation.target.field
object Annotations {
type AlsoLoad = annotation.AlsoLoad @field
type Embed = annotation.Embed @field
type Id = annotation.Id @field
type Ignore = annotation.Ignore @field
type IgnoreLoad = annotation.IgnoreLoad @field
@fedesilva
fedesilva / MacroSample.scala
Created October 26, 2012 20:33 — forked from takezoe/MacroSample.scala
Macro Example in scala-2.10.0-20120419
import language.experimental.macros
import scala.reflect.makro.Context
object MacroSample {
def compiledTime(): String = macro compiledTime_impl
def compiledTime_impl(c: Context)(): c.Expr[String] = {
import c.mirror._
import c.reify