Skip to content

Instantly share code, notes, and snippets.

View druzn3k's full-sized avatar

Maurizio Del Corno druzn3k

View GitHub Profile

TODO: make gem for this

This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.

Bower

  1. Set the install directory for Bower components:

// .bowerrc

/*
Title: Vanilla JavaScript to fix responsive SVGs in some versions of Safari.
What it does: Stops the problem I described here: http://stackoverflow.com/q/17158717/1147859 Reference URL of the issue: http://codepen.io/benfrain/full/fhyrD
It will work on all SVGs referenced inside objects as long as given the class .emb:
<object class="emb" data="img/cup.svg" type="image/svg+xml"></object>
And also any inline SVGs.
uglify: {
production: {
options: {
report: 'min'
},
files: [{
expand: true,
cwd: '<%= dir.tempJS %>/',
src: '*.js',
dest: '<%= dir.publicJS %>',
#! /usr/bin/env python2
# Requires: PIL, colormath
#
# Improved algorithm now automatically crops the image and uses much
# better color matching
from PIL import Image, ImageChops
from colormath.color_objects import RGBColor
import argparse
import math
func main() {
s := []string{"this", "is", "a", "test"}
mapper := func(s string) string {
return "prefix-" + s
}
tap := func(s string) {
fmt.Printf("tap: %s\n", s)
@druzn3k
druzn3k / proxy.go
Created December 21, 2013 16:44 — forked from vmihailenco/proxy.go
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@druzn3k
druzn3k / Makefile
Created December 14, 2013 09:26 — forked from bgschiller/Makefile
all: thread_prng adversary Makefile advantages
thread_prng: thread_prng.c
gcc --std=c99 -o thread_prng -lpthread thread_prng.c
adversary: adversary.c
gcc --std=c99 -o adversary adversary.c
advantages: adversary thread_prng
for option in r m; do \
#!/usr/bin/env ruby
# This is my current blacklist when playing spotify in radio mode with "heavy metal".
blacklist = ['Nickelback', 'Scorpions', 'Watain', 'Mayhem', 'Guns N\' Roses']
# gem install ruby-dbus
require "dbus"
session_bus = DBus::SessionBus.instance
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"