Skip to content

Instantly share code, notes, and snippets.

View nesquena's full-sized avatar

Nathan Esquenazi nesquena

View GitHub Profile
@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 / nginx
Created October 19, 2010 02:42
/etc/init.d/nginx startup script
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu <=9.10.
# Description: nginx init.d dash script for Ubuntu <=9.10.
### END INIT INFO
@nesquena
nesquena / .gitignore
Last active April 4, 2019 11:22
Android .gitignore File
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@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;
}
@nesquena
nesquena / MainThreadCallback.java
Last active June 6, 2018 08:16 — forked from petitviolet/MainThreadCallback.java
OkHttp Callback on Main Thread.
public abstract class MainThreadCallback implements Callback {
private static final String TAG = MainThreadCallback.class.getSimpleName();
abstract public void onFail(final Exception error);
abstract public void onSuccess(final String responseBody);
@Override
public void onFailure(final Request request, final IOException e) {
project :test => :shoulda, :orm => :activerecord
generate :model, "account username:string password:string"
generate :model, "post title:string body:text"
generate :controller, "posts get:index get:new post:new"
generate :migration, "AddEmailToAccount email:string"
require_dependencies 'nokogiri'
git :init
git :add, "."
git :commit, "initial commit"
@nesquena
nesquena / backburner_test_helper.rb
Created May 31, 2014 20:50
Backburner Test Helper
if Rails.env.test?
module Backburner
def self.test_mode
@test_mode ||= :fake
end
def self.test_mode=(mode)
@test_mode = mode
end
@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 / linode_fog.rb
Created October 28, 2011 09:24
Linode and Fog Samples
## DNS
@dns = Fog::DNS.new(:provider => 'Linode', :linode_api_key => LINODE_KEY)
if @zone = @dns.zones.all.find { |z| z.domain == ZONE }
puts "Found zone #{@zone.inspect}"
else
@zone = @dns.zones.create(:domain => ZONE, :email => ZONE_EMAIL)
puts "Creating zone #{@zone.inspect}"
end