Skip to content

Instantly share code, notes, and snippets.

View jrunning's full-sized avatar

Jordan Running jrunning

View GitHub Profile
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@nukemberg
nukemberg / knife.sh
Created June 28, 2011 07:51 — forked from ches/knife
bash completion for Chef's knife command (updated for 0.10)
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
@andyfowler
andyfowler / .vimrc
Created September 5, 2011 18:08
Swap iTerm2 cursors in vim insert mode when using tmux
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
@mxswd
mxswd / classdiagram.gv
Created September 21, 2011 01:13
Class Diagram / ERD Graphviz example. Compile with `dot -Tpdf diagram.gv > diagram.pdf`
digraph models_diagram {
graph[overlap=false, splines=true]
"Venue" [shape=record, label="{\
Venue|name :string\l\
}"]
"User" [shape=record, label="{User|\
email :string\l\
password :string\l\
}"]
@brendanhay
brendanhay / tmux-copy-mode-osx.md
Created February 8, 2012 14:15
Tmux, copy-mode, and OSX shenanigans.

Copy, with line wrapping!

If you've been trying to copy/paste text from a multi-pane tmux session with the mouse, you've probably been pretty pissed at the blissful ignorance a terminal application has of the rodent in your hand.

The alternative, which is quote-unqoute native copy/pasting using copy-mode takes a bit to get used to. So this is one solution for copying and pasting lines from a session with correct line wrapping behaviour, albeit keyboard only.

Disclaimer

Since copy-mode has similar concepts of marks, regions, and temp buffers to Emacs .. you'll probably find it straight forward if you're familar with Emacsen. For people using vi-mode in tmux, the same still applies but obviously the default key bindings will differ alot from what I show below.

@sporkd
sporkd / question.rb
Created February 15, 2012 23:33
Using arel matches_any
class Question < ActiveRecord::Base
# UGLY
def self.starts_with(*strings)
# Big loop to build something like this...
where("wording LIKE ? OR wording LIKE ? OR wording LIKE ?", 'blah%', 'blaah%', 'blaaah%')
end
# PURDY
def self.starts_with(*strings)
strings = strings.map { |s| s+'%' }
@jrunning
jrunning / mysql-coalesce-wtf.sql
Last active August 11, 2020 08:41
MySQL COALESCE() silently casts its return to the type of subsequent non-NULL arguments
-- The MySQL docs say COALESCE() "returns the first non-NULL value in the list,
-- or NULL if there are no non-NULL values." This turns out not to be true.
-- If the value to be returned is an integer, COALESCE() first casts it to
-- the type of a subsequent non-NULL argument. ಠ_ಠ
mysql> SELECT 0 = '',
-> COALESCE(0, '') = '',
-> COALESCE(0, ''),
-> COALESCE(0, NULL),
-> COALESCE(0, 98.6, NULL),
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@itspriddle
itspriddle / setup-git-bundler-merge-driver
Last active August 13, 2018 08:41
This script makes git automatically run `bundle install` when a merge conflict with Gemfile.lock occurs. Run it once per project to setup `.gitattributes` and `.gitconfig`
#!/usr/bin/env bash
# Usage: setup-git-bundler-merge-driver
# Help: Configures git to use a custom merge driver to resolve Gemfile.lock
# merge conflicts.
if [ ! -f Gemfile ]; then
echo 'No `Gemfile` found! Aborting'
exit 1
fi
@jrunning
jrunning / get-your-shit-together-protip-2014.md
Last active January 2, 2016 12:29
My Very Best Get-Your-Shit-Together Protip For 2014

My Very Best Get-Your-Shit-Together Protip For 2014

TL;DR

Take pictures of your important documents (driver's license, passport, birth certificate, etc.) and store them securely with an app that will sync to your computers and mobile devices.

Do this now