Skip to content

Instantly share code, notes, and snippets.

View bernerdschaefer's full-sized avatar

Bernerd Schaefer bernerdschaefer

View GitHub Profile
Person.published
#<Mongoid::Scope:0x18e5a70
@conditions=
{:where=>{:published_at=>{"$lt"=>Mon Jul 26 11:25:19 -0500 2010}}},
@parent=Person>
Person.published.published_on(3.days.ago, 1.days.ago)
#<Mongoid::Scope:0x18e2ec4
@conditions=
{:where=>
{:published_at=>
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db('testing')
end
class User
include Mongoid::Document
has_many_related :memberships
collection.remove
class User
def doctors=(doctors)
write_attribute(:cached_doctors, doctors.map(&:attributes))
@doctors = doctors
end
def doctors
@doctors ||= read_attribute(:cached_doctors).map do |doctor|
Mongoid::Factory.build(Doctor, doctor)
end
end
Feature "User creates new pitch" do
Background do
Given "I am a normal user" do
sign_in
end
And "I visit the home page" do
visit home_path
end
end
# Store 10,000 history entries
export HISTSIZE=10000
# Don't store duplicates
export HISTCONTROL=erasedups
# Append to history file
shopt -s histappend
# Conveniently download external resources:
# fetch http://example.com/library.tar.gz
# fetch ftp://example.com/file.zip
{
:x => 1,
:y => 2
}
# Macro:
# /:x^M
# qq
# ^
# f=
[exec] g++ -o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//lib/native//Darwin/libjruby-cext.jnilib -arch i386 -arch x86_64 -dynamiclib -framework JavaVM -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/st.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/Handle.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/JLocalEnv.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/JString.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/JUtil.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/JavaException.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/Type.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/array.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/bignum.o /Users/bernerdschaefer/.rvm/repos/jruby-head/cext/src/../..//build/class.o /Us
# Set up pathogen.vim
cd ~/.vim/autoload
curl -O http://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim
vim ~/.vimrc
# add this to the top:
# runtime! autoload/pathogen.vim
# if exists('g:loaded_pathogen')
# call pathogen#runtime_prepend_subdirectories(expand('~/.vimbundles'))
# endif
mkdir ~/.vimbundles
--regex-ruby=/(^|:)([A-Z_]+) *=/\2/c,class,constant/
--regex-ruby=/(has_many|belongs_to|has_one|has_and_belongs_to_many) :([^ ]+)/\2/f,function,association/
--regex-ruby=/(named_)?scope\(? *:([^ ,]+)/\2/f,function,named_scope/
--regex-ruby=/[ \t]*event :([^ ]+)/\1/f,function,aasm_event/
--regex-ruby=/[ \t]*event :([^ ]+)/\1!/f,function,aasm_event/
--regex-ruby=/[ \t]*event :([^ ]+)/\1?/f,function,aasm_event/
@bernerdschaefer
bernerdschaefer / jruby
Created October 21, 2010 12:13
simple jruby wrapper script with jruby-jars
#!/usr/bin/env ruby
require 'rubygems'
require 'jruby-jars'
jruby = JRubyJars.core_jar_path
# => "gems/jruby-jars-1.5.3/lib/jruby-core-1.5.3.jar"
jruby_stdlib = JRubyJars.stdlib_jar_path
# => "gems/jruby-jars-1.5.3/lib/jruby-stdlib-1.5.3.jar"