Skip to content

Instantly share code, notes, and snippets.

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@douglas
douglas / update_git_repos.sh
Created October 14, 2011 15:04
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@rwest
rwest / README
Created January 9, 2012 16:42 — forked from symposion/README
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
@wting
wting / dreamhost_python_setup.sh
Created May 31, 2012 00:16
Dreamhost Python Setup script
#!/usr/bin/env bash
# Written by William Ting for the following blog post:
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/
rcfile="${HOME}/.bashrc"
version="2.7.3"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then
@petervanderdoes
petervanderdoes / filter-flow-release-start-version
Created June 5, 2012 19:12
gitflow hooks and filters for WordPress theme development
#!/bin/sh
#
# Runs during git flow release start
#
# Positional arguments:
# $1 Version
#
# Return VERSION - When VERSION is returned empty gitflow
# will stop as the version is necessary
#
@timyates
timyates / rdp.coffee
Created June 8, 2012 11:03 — forked from rhyolight/rdp.js
Ramer-Douglas-Peucker line filtering algorithm in JavaScript
findPerpendicularDistance = ( point, line ) ->
[pointX,pointY] = point[0..1]
lineStart = x: line[0][0], y: line[0][1]
lineEnd = x: line[1][0], y: line[1][1]
slope = ( lineEnd.y - lineStart.y ) / ( lineEnd.x - lineStart.x )
intercept = lineStart.y - ( slope * lineStart.x )
Math.abs( slope * pointX - pointY + intercept ) / Math.sqrt( Math.pow( slope, 2) + 1)
douglasPeucker = ( points, epsilon ) ->
maxIndex = maxDistance = 0
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 17, 2024 21:23
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@niallo
niallo / gist:3109252
Created July 14, 2012 04:54
Parse Github `Links` header in JavaScript
/*
* parse_link_header()
*
* Parse the Github Link HTTP header used for pageination
* http://developer.github.com/v3/#pagination
*/
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jenheilemann
jenheilemann / 20130822132243_change_product_long_description.rb
Created August 22, 2013 14:39
Rails migrations: String to Text and back again. It's kind of complicated to update a database column that is currently a "string" and convert it into "text." Well, it's not hard to update the column, but it can be dangerous if you need to rollback the migration - Postgresql and other databases don't like adding a limit to the column, and the `r…
class ChangeProductLongDescription < ActiveRecord::Migration
def up
# simple and straightforward
change_column :products, :long_description, :text
end
# but why cant it just be:
# change_column :product, :long_description, :string
# ???
# because effin databases don't like you, that's why.