Skip to content

Instantly share code, notes, and snippets.

class Application
include Mongoid::Document
references_many :items
references_many :templates
references_many :users, :stored_as => :array, :inverse_of => :applications
end
class User
include Mongoid::Document
class Application
include Mongoid::Document
embeds_many :items
embeds_many :templates
references_many :users, :stored_as => :array, :inverse_of => :applications
end
class User
include Mongoid::Document
#!/bin/sh -x
# hack: Merge the latest changes from the master branch into your current branch
ref=$(git symbolic-ref HEAD 2> /dev/null) || exit 0
CURRENT="${ref#refs/heads/}"
git checkout development
git pull origin development
git checkout ${CURRENT}
git rebase development
#!/bin/sh -x
# hack: Merge the latest changes from the master branch into your current branch
ref=$(git symbolic-ref HEAD 2> /dev/null) || exit 0
CURRENT="${ref#refs/heads/}"
git checkout development
git pull origin development
git checkout ${CURRENT}
git rebase development
@joslynesser
joslynesser / git-completion.bash
Created October 29, 2010 23:34
Git branch auto completion
#!bash
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@joslynesser
joslynesser / git-branch.bash
Created October 29, 2010 23:38
Always display git branch
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
BRIGHT_RED="\[\033[1;31m\]"
DULL_WHITE="\[\033[0;37m\]"
BRIGHT_WHITE="\[\033[1;37m\]"
PS1="${DULL_WHITE}\w${BRIGHT_RED} \$(parse_git_branch)${BRIGHT_WHITE}\$ "
@joslynesser
joslynesser / git-repull-ship.bash
Created November 1, 2010 02:17
Automates pulling and rebasing latest from master and shipping your changes out
#!/bin/sh -x
# repull: Merge the latest changes from the master branch into your current branch
function repull {
ref=$(git symbolic-ref HEAD 2> /dev/null) || exit 0
CURRENT="${ref#refs/heads/}"
git checkout master
git pull origin master
git checkout ${CURRENT}
git rebase master
}
POST /user_sessions.json { "email": "some@email.com", "password": "somepassword" }
=> { "user_credentials": "123abc" }
GET /case_filters/1/cases.json?user_credentials=123abc
=> [ ...cases ... ]
ruby-1.9.2-p180 :001 > p = Post.create
=> #<Post id: 1, title: nil, comments_count: 0, created_at: "2011-08-29 02:58:04", updated_at: "2011-08-29 02:58:04">
ruby-1.9.2-p180 :002 > p.comments.create
=> #<Comment id: 1, title: nil, post_id: 1, created_at: "2011-08-29 02:58:16", updated_at: "2011-08-29 02:58:16">
ruby-1.9.2-p180 :003 > p.comments.create
=> #<Comment id: 2, title: nil, post_id: 1, created_at: "2011-08-29 02:58:18", updated_at: "2011-08-29 02:58:18">
ruby-1.9.2-p180 :004 > p.reload
=> #<Post id: 1, title: nil, comments_count: 2, created_at: "2011-08-29 02:58:04", updated_at: "2011-08-29 02:58:04">
ruby-1.9.2-p180 :005 > Post.create
=> #<Post id: 2, title: nil, comments_count: 0, created_at: "2011-08-29 02:58:30", updated_at: "2011-08-29 02:58:30">
@joslynesser
joslynesser / case_export.rb
Created November 16, 2011 01:55
Basic Assistly API Case Export
# Ruby example for exporting Cases to CSV
# requires ruby version 1.9.2
# requires oauth and json gems (gem install oauth json)
require "rubygems"
require "oauth"
require "json"
require "csv"
ASSISTLY_DOMAIN = "domain.assistly.com"