Skip to content

Instantly share code, notes, and snippets.

@probablykabari
probablykabari / .gitconfig
Created November 9, 2017 16:34
Git Config
[alias]
st = status -s
co = checkout
cam = commit -a -m
cim = commit -m
aliases = "!git config -l | grep alias | cut -c 7-"
ria = "!git rebase -i `git merge-base HEAD master`"
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
poh = pull --rebase origin master
mergetest = "!f(){ git merge --no-commit --no-ff \"$1\"; git merge --abort; echo \"Merge aborted\"; };f "
@probablykabari
probablykabari / .bowerrc
Last active August 29, 2015 14:22
Foundation Apps with Rails
{
"directory": "vendor/assets/bower_components"
}
@probablykabari
probablykabari / some_file_doing_stuff.rb
Created September 10, 2014 19:41
just showing some syntax stuff
# I see this a lot, and it is perfectly OK to do this
def new_cat(name, color)
cat = Cat.new
cat.name = name
cat.owner = self
cat.color = color
cat.save
end
# Here's another way to do that
@probablykabari
probablykabari / hashes_and_such.rb
Created September 3, 2014 17:52
Quick look at hash nesting
hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
hash["down"]["in-the"]["basement"] = "hello?"
hash
# => {"down"=>{"in-the"=>{"basement"=>"hello?"}}}
hash.has_key?("i-do-not")
# => false
hash.default = lambda{|h,k| h[k] = "bankai!" } # no longer a deeply nested/fun hash
@probablykabari
probablykabari / gist:3812713
Created October 1, 2012 16:04
Mongomapper sortable list
# Allow for sortable lists in mongomapper
# fairly application specific but just to show an example...
module MongoMapper; module Plugins
module SortableQuestion
extend ActiveSupport::Concern
included do
key :position, Integer, :default => 1
before_create :append_to_bottom_of_list
after_destroy :set_lower_sibling_positions
@probablykabari
probablykabari / installation.sh
Created July 30, 2012 16:11 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@probablykabari
probablykabari / sg-ruby-example.rb
Created December 15, 2011 02:45
Example of using the survey-gizmo-ruby gem
require 'survey-gizmo-ruby'
# somewhere in your app define your survey gizmo login credentials.
SurveyGizmo.setup(:user => 'you@somewhere.com', :password => 'mypassword')
# get al resources
surveys = SurveyGizmo::API::Survey.all
questions = SurveyGizmo::API::Question.all(:survey_id => 12345)
# get a single resource
@probablykabari
probablykabari / dm-rspec-transaction.rb
Created May 10, 2011 16:37
datamapper rspec transaction
config.before(:each) do
repository(:default) do
transaction = DataMapper::Transaction.new(repository)
transaction.begin
repository.adapter.push_transaction(transaction)
end
end
config.after(:each) do
repository(:default).adapter.pop_transaction.rollback
@probablykabari
probablykabari / descendant_spec.rb
Created April 7, 2011 16:47
Dynamic model creation broken in DM 1.1
require 'spec_helper'
require 'dm-core'
def create_dm_model(name)
DataMapper::Model.new(name) do
property :id, DataMapper::Property::Serial
property :name, DataMapper::Property::String
end
end
From 95c7e993f0c124f6fda4fce45452d63ede469fd3 Mon Sep 17 00:00:00 2001
From: Kabari Hendrick <kabari@gmail.com>
Date: Wed, 22 Dec 2010 13:01:51 -0600
Subject: [PATCH] git rid of strict dependency
Signed-off-by: Kabari Hendrick <kabari@gmail.com>
---
Rakefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)