Skip to content

Instantly share code, notes, and snippets.

View nesquena's full-sized avatar

Nathan Esquenazi nesquena

View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@nesquena
nesquena / basic.sql
Created September 7, 2011 01:56
PostgreSQL Common Utility Queries
/* How to calculate postgreSQL database size in disk ? */
SELECT pg_size_pretty(pg_database_size('thedbname'));
/* Calculate size of a table including or excluding the index */
SELECT pg_size_pretty(pg_total_relation_size('big_table'));
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */
/* See indexes on a table with `\d tablename` */
@nesquena
nesquena / base.conf
Last active February 28, 2020 11:35
nginx configuration
include mime.types;
default_type application/octet-stream;
access_log logs/access.log;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
tcp_nopush on;
@nesquena
nesquena / Uniform Setup.md
Created August 3, 2010 22:30
Uniform Server Setup

Enable universe repository:

# /etc/apt/sources.list

## main & restricted repositories
deb http://us.archive.ubuntu.com/ubuntu/ jaunty main restricted universe
deb-src http://us.archive.ubuntu.com/ubuntu/ jaunty main restricted universe

deb http://security.ubuntu.com/ubuntu jaunty-security main restricted universe

deb-src http://security.ubuntu.com/ubuntu jaunty-security main restricted universe

@nesquena
nesquena / dj_multi.god
Last active December 5, 2019 17:41
god configuration
# delayed job priority ranges. Higher values represent lower priority.
PRIORITY_RANGES = [(0..9), (10..19)]
2.times do |num|
God.watch do |w|
w.name = "dj-#{num}"
w.group = 'dj'
w.interval = 30.seconds
w.start = "rake -f #{RAILS_ROOT}/Rakefile RAILS_ENV=production MIN_PRIORITY=#{PRIORITY_RANGES[num].first} MAX_PRIORITY=#{PRIORITY_RANGES[num].last} jobs:work"
w.log = "/var/log/god/god.log"
@nesquena
nesquena / mac_setup.txt
Last active February 10, 2019 17:58
Setup Local Mac
- Run software update
- Install Purchased Apps from App Store
- Disable caps lock key (Sys Pref => Keyboard => Modifier Keys)
- System Pref -> Expose -> Setup corners for spaces and expose
+ System Pref -> Security -> Sleep Password
- Setup Dropbox to Get Files
- Install 1Password
- Use dropbox synced file for keychain
- Install browser extension for chrome
- Install Prey
@nesquena
nesquena / .bash_profile
Created May 31, 2009 07:17
simple git branch ps1 with colored dirty state
# COLORS
LIGHT_GRAY="\[\033[0;37m\]"; BLUE="\[\033[1;36m\]"; RED="\[\033[0;31m\]"; LIGHT_RED="\[\033[1;31m\]";
GREEN="\[\033[0;32m\]"; WHITE="\[\033[1;37m\]"; LIGHT_GRAY="\[\033[0;37m\]"; YELLOW="\[\033[1;33m\]";
# GIT PROMPT (http://gist.github.com/120804)
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/';
}
function parse_git_status {
git status 2> /dev/null | sed -e '/(working directory clean)$/!d' | wc -l;
}
@nhance
nhance / method_logger.rb
Created September 6, 2012 12:58
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
Model.new.foo
@nesquena
nesquena / request.rb
Created May 10, 2011 00:44
Rails Request Logging
Rails.logger.info "REQUEST INSPECTOR"
Rails.logger.info " [REQUEST_URI] #{request.headers['REQUEST_URI'].inspect}"
Rails.logger.info " [RAW_POST]: #{request.raw_post.inspect}"
Rails.logger.info " [PARAMS]: #{request.params.inspect}"
Rails.logger.info " [HTTP_AUTHORIZATION] #{request.headers['HTTP_AUTHORIZATION'].inspect}"
Rails.logger.info " [CONTENT_TYPE]: #{request.headers['CONTENT_TYPE'].inspect}"
Rails.logger.info " [HTTP_ACCEPT] #{request.headers['HTTP_ACCEPT'].inspect}"
Rails.logger.info " [HTTP_HOST] #{request.headers['HTTP_HOST'].inspect}"
Rails.logger.info " [HTTP_USER_AGENT] #{request.headers['HTTP_USER_AGENT'].inspect}"
@nesquena
nesquena / autotest_install
Created June 30, 2010 22:23
Autotest Instructions
# http://ph7spot.com/musings/getting-started-with-autotest
$ gem install redgreen autotest-standalone autotest-fsevent autotest-growl autotest-rails-pure
$ mate ~/.autotest
require 'redgreen/autotest'
require 'autotest/timestamp'
require 'autotest/growl'
require 'autotest/fsevent'
require "autotest/restart"