Skip to content

Instantly share code, notes, and snippets.

View afair's full-sized avatar

Allen Fair afair

View GitHub Profile
@afair
afair / gist:2911107
Created June 11, 2012 16:32
Ruby 1.8 Unicode Examples
#!/usr/bin/env ruby
# encoding: UTF-8 # 2nd line, says file has Unicode data and names
#####################################################################
# Ruby 1.8 Unicode Demonstration
#####################################################################
# Enable Unicode Support, or start with: ruby -Ku
$KCODE = "UTF-8"
@afair
afair / .gitconfig
Created June 24, 2012 16:13
Git Basics
[user]
name = Your Nmae
email = you@example.com
[core]
editor = vim
[color]
diff = auto
status = auto
branch = auto
ui = auto
@afair
afair / tmux.cheat
Last active October 11, 2023 13:48
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New new -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@afair
afair / bash.cheat
Created August 27, 2012 20:23
Bash Scripting Quick Reference
==========================================
BASH SCRIPTING ==========================================
========================================== TEST COMMAND
==========================================
Invoke: bash [options] file
Shebang: #!/usr/bin/env bash Test: test expression
In script: [ expression ]
========================================== Alternate: [[ espression ]]
LOOP Does not split string words
========================================== Does not expand pathglobs*
@afair
afair / tm.sh
Last active April 19, 2024 22:59
Tmux rails session wrapper script
#!/usr/bin/env bash
################################################################################
# Script to initiate (or connect to) a tmux session
###############################################################################
# Starts session and returns, or attaches to existing session name and exits.
function tm_session { # session name
#echo tmux start-server
tmux start-server
#echo tmux has-session -t $1
@afair
afair / gist:3803895
Last active August 7, 2023 07:43
PostgreSQL and Pgpool Architecture

Hey! I saw this has been indexed by the search engines. It is a first draft of a post I ended up publishing on my blog at: Scaling PostgreSQL With Pgpool and PgBouncer

Thanks for stopping by!

PostgreSQL and Pgpool Architecture

@afair
afair / RotateNumber.vim
Created November 26, 2012 16:52
Rotates vim line number setting from [On -> Relative -> Off], set to <Leader>n
" vimscript function to rotate line number setting from [On -> Relative -> Off], set to <Leader>n
" Author: Allen Fair, 2012
" License: Public Domain
function RotateNumber()
if &l:number
let &l:number=0
let &l:relativenumber=1
echom "Line Numbers"
elseif &l:relativenumber
@afair
afair / curl reference.md
Last active February 11, 2024 05:54
Curl command reference with most used options. No overwhelming man page.

Curl Reference

Use the curl command line tool from your terminal window to access web pages, resources, and API's. This swiss-army knife of the internet also supports many more protocols and tools.

Command format

curl [options] URL

The complete, offical reference page is here.

@afair
afair / JsonMessages.js
Last active December 21, 2015 01:09
JSON Messages - From a Philly.rb lightning talk I gave on August 13, 2013.
var talk = {
title: "JSON Messaging: From REST and Beyond",
by: { name: "Allen Fair",
twitter: "@allenfair" },
event: { organization: "Philly.rb",
when: "August 12, 2013 23:00 UDT",
style: "☇ Lightning" },
@afair
afair / gist:9648839
Created March 19, 2014 19:01
Factory Girl Basics
FactoryGirl.define do
factory :user do # class:User, aliases:[:name1, :name2]
name "Ruby"
date_of_birth { 21.years.ago } # Blocked called lazily at request time
association_factory_name
association :commenter, factory: :user, attrib:"value"
factory(:admin_user) do # Inheritance
admin true
end