Skip to content

Instantly share code, notes, and snippets.

View andyatkinson's full-sized avatar

Andrew Atkinson andyatkinson

View GitHub Profile
" Switch wrap off for everything
set nowrap
if has("autocmd")
" This is probably in your .vimrc already. No need to duplicate!
filetype plugin indent on
" Set File type to 'text' for files ending in .txt
autocmd BufNewFile,BufRead *.txt setfiletype text
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@saetia
saetia / gist:1623487
Last active July 16, 2024 05:56
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@bmpercy
bmpercy / transactional_fixture_disabler.rb
Created February 22, 2012 04:51
Hack to disable transactional fixtures on a per-test basis in rails 3.2
module TransactionalFixtureDisabler
def self.included(klass)
klass.teardown :restore_transactional_fixture_status
end
# call this at the top of your test if you need to disable
# transactional fixtures. this might be the case if:
# - you're testing after_commit or after_rollback callbacks
# on models
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active December 1, 2024 15:29
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@zhiyao
zhiyao / Capistrano Postgresql
Created October 30, 2012 17:36
capistrano postgresql backup, import and export to production server, reference mledom.blogspot.com/2009/11/capistrano-sync-production-to.html
require "bundler/capistrano"
namespace :db do
require 'yaml'
desc "Copy the remote production database to the local development database NOTE: postgreSQL specific"
task :pg_backup_production, :roles => :db, :only => { :primary => true } do
# First lets get the remote database config file so that we can read in the database settings
tmp_db_yml = "tmp/database.yml"
get("#{shared_path}/config/database.yml", tmp_db_yml)
@willurd
willurd / web-servers.md
Last active December 2, 2024 09:55
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@lfittl
lfittl / docker-postgres-slave.markdown
Last active May 27, 2024 15:58
Setting up a docker-ized Postgres Slave

(Note: This assumes you've already configured your master server for streaming replication)

export DATADIR=/data/postgres-9.3
export MASTER=192.168.0.1
export REPL_USER=replication
export REPL_PASSWORD=mypassword

Create a base backup:

@fphilipe
fphilipe / exclude.sql
Last active November 27, 2024 16:47
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)