Skip to content

Instantly share code, notes, and snippets.

View spalenza's full-sized avatar

Rodolfo Spalenza spalenza

  • RDStation
  • Vitória - ES - Brazil
View GitHub Profile
@spalenza
spalenza / KeyMappings
Created October 17, 2012 15:51 — forked from geekontheway/KeyMappings
NerdTree
o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
O.......Recursively open the selected directory..................|NERDTree-O|
x.......Close the current nodes parent...........................|NERDTree-x|
@spalenza
spalenza / Gemfile
Created October 17, 2012 20:36 — forked from robotarmy/Gemfile
Adding Rake to Sinatra with Rspec
gem 'sinatra'
group :development,:test do
gem 'rspec'
gem 'rack-test'
end
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@spalenza
spalenza / autopgsqlbackup
Created September 28, 2016 00:14 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <axelseaa@amadmax.com>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@spalenza
spalenza / mysql-largest-tables.sh
Created March 27, 2017 22:31 — forked from xurizaemon/mysql-largest-tables.sh
Show largest tables (optionally, in a specific DB)
#!/bin/bash
if [ -z $1 ] ; then
SQL="
SELECT
CONCAT(table_schema, '.', table_name) 'Table',
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') 'Tot Size',
CONCAT(ROUND(table_rows / 1000000, 2), 'M') 'Rows',
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') 'Data',
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') 'Idx',
@spalenza
spalenza / mysql-largest-tables.sh
Created March 27, 2017 22:31 — forked from xurizaemon/mysql-largest-tables.sh
Show largest tables (optionally, in a specific DB)
#!/bin/bash
if [ -z $1 ] ; then
SQL="
SELECT
CONCAT(table_schema, '.', table_name) 'Table',
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') 'Tot Size',
CONCAT(ROUND(table_rows / 1000000, 2), 'M') 'Rows',
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') 'Data',
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') 'Idx',
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 60
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
@spalenza
spalenza / slides.md
Created November 29, 2017 16:32 — forked from shadowmaru/slides.md
Palestras da RubyConf BR 2017
@spalenza
spalenza / migration_sql.rb
Last active May 23, 2019 20:33 — forked from xaviershay/migration_sql.rb
Get SQL output from a Rails migration
#!/usr/bin/env ruby
require_relative 'config/environment'
path = ARGV.shift || raise("specify migration as first argument")
require_relative path
filename = File.basename(path, ".rb")
timestamp, name = filename.split("_", 2)
@spalenza
spalenza / irb.rb
Created July 2, 2019 18:23 — forked from joshuapinter/irb.rb
Activate Authlogic in Console
if defined?(ActiveRecord::Base) && defined?(Authlogic)
controller = ApplicationController.new
require 'action_controller/test_case'
controller.instance_variable_set(:@_request, ActionController::TestRequest.new)
controller.instance_variable_set(:@_response, ActionController::TestResponse.new)
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(controller)
end
UserSession.new( User.first )