Skip to content

Instantly share code, notes, and snippets.

View datwright's full-sized avatar
🤠
YEEHAW

Dave Wright datwright

🤠
YEEHAW
View GitHub Profile
@datwright
datwright / gist:7755579
Created December 2, 2013 19:23
Customize OSX terminal. Put this in your ~/.bash_profile \u is the username \h is the current host \w is the current directory
# \u is the username
# \h is the current host
# \w is the current directory
function prompt {
local GRAY="\[\033[0;37m\]"
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
require 'csv'
def transform_merge(csv_file)
CSV.open(@csv_file).read.each do |line|
end
end
def multiple_merge(inputs)
errors = []
@datwright
datwright / gist:1355453
Created November 10, 2011 17:14
SOCKS Proxy for remote FTP server
OH NO! It turns out that simple one-port SSH Tunnels won't work for FTP since it uses another random port to actually transfer data. No problem! SOCKS Proxy to the rescue!
This assumes that you have SSH access to a server that can successfully connect to the FTP server you want access to.
On your local execute:
ssh -ND 1234 [email protected]
You'll need an FTP client that supports SOCKS Proxies. I recommend Filezilla. Enter localhost:1234 as your SOCKS proxy server and connect to the FTP server using its regular internet address (as though you were connecting from your production server). SWEEEET!
@datwright
datwright / gist:1349416
Created November 8, 2011 22:03
SSH Tunnelling
Say a server is only accessible from your production server. And let's say you have SSH access to the production server. GOOD NEWS. You can connect to that server.
Server
Address: ftp.something.com
Port: 3306
Production server
Address: ssh.whatever.com
Username: tony
@datwright
datwright / gist:1197953
Created September 6, 2011 15:54
pass_fail
SELECT u.id, u.name, COUNT(CASE WHEN `assessment_results`.passed = 1 THEN 1 ELSE NULL END) / COUNT(*) as pass_rate, COUNT(*) as total, COUNT(CASE WHEN `assessment_results`.passed = 1 THEN 1 ELSE NULL END) FROM users u
LEFT JOIN assessment_results ON assessment_results.user_id = u.id
WHERE u.certification_id = 3
AND (u.certification_status = 'green' OR u.certification_status = 'yellow')
AND assessment_results.submitted = true
group by u.id
ORDER BY pass_rate DESC a
@datwright
datwright / gist:1172659
Created August 26, 2011 03:59
How I like my terminal prompt
function prompt {
local GRAY="\[\033[0;37m\]"
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local MAGENTA="\[\033[0;35m\]"
local RED="\[\033[0;31m\]"
local BLACK="\[\033[0;30m\]"
local YELLOW="\[\033[0;33m\]"
local BLUE="\[\033[0;34m\]"
@datwright
datwright / gist:1082717
Created July 14, 2011 15:52
Rails Migrations Cheat sheet
# Migration generator shortcuts.
# rails generate migration MyNewMigration
# rails generate migration add_fieldname_to_tablename fieldname:string
# rails generate model Product name:string description:text
# The set of available column types [:string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean]
# A migration is a subclass of ActiveRecord::Migration. You must implement the "up" and "down" (revert) methods.
# These are the handy methods available to a Migration:
@datwright
datwright / gist:843315
Created February 25, 2011 03:08
Setting up a Django 1.2 instance
# Go to directory where you want to create your new project directory. Project is
# called 'mysite'
django-admin.py startproject mysite
# Go into directory and start server. Port 8000 by default.
cd mysite
python manage.py runserver [port]
#change setting.py's DB-ENGINE to 'django.db.backends.sqlite3' and give the
# database a "name"
@datwright
datwright / Long remote process using screen
Created February 23, 2011 15:08
Running a long remote process using screen without having to worry about disconnecting
ssh [email protected]
screen # start new screen session
do-your-process
# Press CRTL-a, d -- detaches from new screen session
exit
ssh [email protected]
screen -r #resume previous screen session