Skip to content

Instantly share code, notes, and snippets.

View microwaves's full-sized avatar

Stephano Zanzin Ferreira microwaves

View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jodosha
jodosha / adapter_test.rb
Last active August 11, 2019 03:12
MiniTest shared examples
require 'test_helper'
shared_examples_for 'An Adapter' do
describe '#read' do
before do
@adapter.write(@key = 'whiskey', @value = "Jameson's")
end
it 'reads a given key' do
@adapter.read(@key).must_equal(@value)
@boriscy
boriscy / install-ruby-debug-ubuntu-ruby-1.9.3
Created November 1, 2011 18:57
ruby-debug in ruby-1.9.3 and ubuntu
#To install ruby-debug on Ubuntu ruby-1.9.3 you need to download from http://rubyforge.org/frs/?group_id=8883
linecache19-0.5.13.gem
ruby_core_source-0.1.5.gem
ruby-debug19-0.11.6.gem
ruby-debug-base19-0.11.26.gem
#Then in your console
export RVM_SRC=/your/path/to/ruby-1.9.3
@mauricioszabo
mauricioszabo / connection_fix.rb
Created October 10, 2011 18:38 — forked from defunkt/connection_fix.rb
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/
middle_name = case full_name
when /^.*\s(.*)\s.*$/
$1
else
"Peatrice"
end
@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:
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;
# 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
#!/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
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]