Skip to content

Instantly share code, notes, and snippets.

@rpanachi
rpanachi / show git branch on terminal
Created November 27, 2009 15:54
Display the git branch on terminal
#include on ~/.bashrc
PS1="\[\033[38m\]\u";
PS1="$PS1\[\033[32m\] \w";
PS1="$PS1\[\033[31m\]";
PS1="$PS1\`git branch 2>/dev/null | grep \"^\*\" | \\
sed -r \"s/\*\ (.*)/ \(\1\)/\"\`";
export PS1="$PS1\[\033[37m\]$\[\033[00m\]";
@rpanachi
rpanachi / screen.txt
Created August 19, 2011 17:11
RVM Instalation
user@ubuntu:~$ sudo apt-get install git-core curl
user@ubuntu:~$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Cloning into rvm...
remote: Counting objects: 5375, done.
remote: Compressing objects: 100% (2544/2544), done.
remote: Total 5375 (delta 3492), reused 3850 (delta 2113)
Receiving objects: 100% (5375/5375), 1.84 MiB | 1.21 MiB/s, done.
Resolving deltas: 100% (3492/3492), done.
@rpanachi
rpanachi / nginx.conf
Created August 7, 2012 00:00 — forked from rogerleite/nginx.conf
Configuração Nginx
user www-data;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
@rpanachi
rpanachi / deploy.sh
Created September 20, 2012 19:18
Forrest Deployer Shell
#!/bin/bash
APP_DIR=/var/local/apps/app
RAILS_ENV=production
function step
{
if [ "$step_count" = "" ]; then
step_count=0
fi
#!/bin/sh
for q in $(echo 'SMEMBERS "resque:queues"' | redis-cli | awk '{print $1}')
do
echo $q $(echo "LLEN \"resque:queue:$q\"" | redis-cli)
done
# in a single line;
# for q in $(echo "SMEMBERS \"resque:queues\"" | redis-cli | awk '{print $1}'); do echo $(echo "LLEN \"resque:queue:$q\"" | redis-cli); done | awk '{s+=$1} END {print s}'
#!/usr/bin/env ruby
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
]
@rpanachi
rpanachi / require_profiler.rb
Last active August 29, 2015 14:04
Require profiler
#!/usr/bin/env ruby
#usage: ruby require_profiler.rb ./config/application
ENV['NO_RELOAD'] ||= '1'
ENV['RAILS_ENV'] ||= 'development'
ENV['RACK_ENV'] ||= 'development'
require 'rubygems'
require 'benchmark'
@rpanachi
rpanachi / skip_validation.rb
Last active August 29, 2015 14:09
Skip Validation
# source: http://gistflow.com/posts/749-canceling-validations-in-activerecord
# declaration
def skipping_validation(methods, &block)
skipped_validations = methods.map do |method, kinds|
Array(kinds).map do |kind|
_validators[method].select { |v| v.kind == kind }.map do |validation|
_validate_callbacks.select { |c| c.filter == validation }.map do |callback|
_validate_callbacks.delete(callback)
end
@rpanachi
rpanachi / tsocks.conf
Created May 25, 2015 12:13
tsocks.conf
# This is the configuration for libtsocks (transparent socks)
# Lines beginning with # and blank lines are ignored
#
# The basic idea is to specify:
# - Local subnets - Networks that can be accessed directly without
# assistance from a socks server
# - Paths - Paths are basically lists of networks and a socks server
# which can be used to reach these networks
# - Default server - A socks server which should be used to access
# networks for which no path is available
@rpanachi
rpanachi / db.rake
Created April 10, 2016 21:26
Rakefile for Sequel database operations
namespace :db do
require 'sequel'
Sequel.extension(:migration)
MIGRATIONS_PATH = 'db/migrations'
def db_conn_env
ENV["BOOKSHELF_DATABASE_URL"]
end