Skip to content

Instantly share code, notes, and snippets.

View daveworth's full-sized avatar
🔬
Science!

David E Worth daveworth

🔬
Science!
View GitHub Profile
@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

@monokrome
monokrome / gist:1218955
Created September 15, 2011 10:06
Homebrew / PostgreSQL Setup Information
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.0/static/install-procedure.html
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@henrik
henrik / example_spec.rb
Created February 16, 2012 18:55
Testing Draper decorators with real helpers, including URL helpers.
require "spec_helper"
# :draper_with_helpers is necessary for the Draper objects
# to access real helpers, including URL helpers, in the spec.
describe MyDecorator, "#foo", :draper_with_helpers do
# This is necessary for the spec itself to use URL helpers
# like some_path().
include Rails.application.routes.url_helpers
@cjolly
cjolly / pg.sh
Last active July 25, 2022 20:16
Use homebrew to upgrade to postgres on OSX
newpg=9.6.1 # set to new PG version number
oldpg=`pg_config --version | cut -d' ' -f2`
# PG 96. upgrades the readline to v7, which breaks anything linked against readline v6, like ruby via ruby-build.
# I *think* this should prevent it from installing v7. But if weird shit happens with various rubies,
# you'll have to reinstall them.
brew pin readline
# Stop current Postgres server
brew services stop postgresql
1.9.3p194 :001 > 1==1?"one":"not one"
=> "one"
1.9.3p194 :002 > def one
1.9.3p194 :003?> 1
1.9.3p194 :004?> end
=> nil
1.9.3p194 :005 > 1==one?"one":"not one"
SyntaxError: (irb):5: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
1==one?"one":"not one"
1.9.3p194 :006 > 1==one ? "one":"not one"
@stevenharman
stevenharman / _dev_badge.html.slim
Created October 17, 2012 18:45
A simple badge that shows your Rails environment.
/ In app/views/shared/
#dev-badge
span= Rails.env
span It ain't production!
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 17, 2024 14:20
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: