Skip to content

Instantly share code, notes, and snippets.

View afair's full-sized avatar

Allen Fair afair

View GitHub Profile
@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 / 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 / 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 / tmux.cheat
Last active June 3, 2024 23:26
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 / .gitconfig
Created June 24, 2012 16:13
Git Basics
[user]
name = Your Nmae
email = [email protected]
[core]
editor = vim
[color]
diff = auto
status = auto
branch = auto
ui = auto
@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 / udata.rb
Created June 5, 2012 20:37
UData - A Ruby 1.9 Unicode Demonstration Class
#!/usr/bin/env ruby
# encoding: UTF-8
###############################################################################
# Ruby 1.9 Unicode Demonstration
###############################################################################
require 'rubygems'
require 'unicode' # gem unicode
require 'unicode_utils' # gem unicode_utils
require 'rchardet19' # gem rchardet19
@afair
afair / trails.sh
Created May 14, 2012 15:23
Script to initiate (or connect to) a tmux session running a rails project
#!/usr/bin/env bash
#
# Script to initiate (or connect to) a rails project
# tmux session.
if [[ "$1" != "" ]]; then
app=$1
APPDIR=$HOME/src/$app
cd $APPDIR
else
@afair
afair / get_mxers.rb
Created April 24, 2012 14:38
Ruby: lookup email MX servers for a domain
require 'resolv'
class Domain
def mxers(domain)
mxs = Resolv::DNS.open do |dns|
ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
end
return mxs
@afair
afair / gist:2402068
Last active September 21, 2024 21:06
Perl References for Kittens

Perl References

Simple Perl variables are called scalars. Examples of scalar values are

   $number      = 123;
   $string      = "String";
   $file_handle = open "<filename";
   $null_value  = undef;
 $instance = MyClass-&gt;new;