Skip to content

Instantly share code, notes, and snippets.

View microwaves's full-sized avatar

Stephano Zanzin Ferreira microwaves

View GitHub Profile
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
@tomlea
tomlea / gist:207938
Created October 11, 2009 22:55
This is very rough and ready.
require "net/http"
# Example Usage:
#
# use Rack::Proxy do |req|
# if req.path =~ %r{^/remote/service.php$}
# URI.parse("http://remote-service-provider.com/service-end-point.php?#{req.query}")
# end
# end
#
@defunkt
defunkt / connection_fix.rb
Created November 19, 2009 20:00
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@lsbardel
lsbardel / redis-server-for-init.d-startup
Created December 15, 2009 21:01 — forked from mtodd/redis-server-for-init.d-startup
Init.d Redis script for Ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
require "resque"
require "resque/failure/multiple"
require "resque/failure/redis"
# Configure Resque connection from config/redis.yml. This file should look
# something like:
# development: localhost:6379
# test: localhost:6379:15
# production: localhost:6379
Resque.redis = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env]
#!/bin/bash
# author Gleicon Moraes
# q&d for provisioning VirtualBox images for a Hadoop project
# works on Mac Os X Snow Leopard.
# fill in for the ubuntu iso path (must be absolute or put it on VBox HDD dir)
#
if [ "$#" -lt 1 ]; then
echo "use as createvm <VMName>"
exit
# Sinatra minimalist RestMQ
# no COMET, just /q/ routes and queue logic
# the core of RestMQ is how it uses Redis' data types
require 'rubygems'
require 'sinatra'
require 'redis'
require 'json'
QUEUESET = 'QUEUESET' # queue index
anonymous
anonymous / gist:615570
Created October 7, 2010 18:11
diff -u -r varnish-2.1.3/bin/varnishd/cache_dir_random.c varnish-quorum/bin/varnishd/cache_dir_random.c
--- varnish-2.1.3/bin/varnishd/cache_dir_random.c 2010-03-24 09:44:13.000000000 +0000
+++ varnish-quorum/bin/varnishd/cache_dir_random.c 2010-10-07 18:22:42.506413284 +0000
@@ -75,6 +75,7 @@
enum crit_e criteria;
unsigned retries;
+ double quorum_weight;
double tot_weight;
struct vdi_random_host *hosts;
@sansumbrella
sansumbrella / SuperFormulaApp.cpp
Created February 19, 2011 08:42
Port of code from Form+Code by Chandler McWilliams and Casey Reas: http://formandcode.com/code-examples/visualize-superformula
#include "cinder/app/AppBasic.h"
#include "cinder/CinderMath.h"
#include "cinder/gl/gl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class SuperFormulaApp : public AppBasic {
public:
middle_name = case full_name
when /^.*\s(.*)\s.*$/
$1
else
"Peatrice"
end