Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
<type label="Single precision" length="0" sql="FLOAT" quote=""/>
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/>
@jessieay
jessieay / ActiveRecord Cheat Sheet v1
Created July 17, 2012 19:55
Active Record cheat sheet with examples of queries I've needed most so far
ActiveRecord cheat sheet / EXAMPLES
INSTALL
=======
$ gem install activerecord
in GEMFILE: gem ‘activerecord’
REQUIRE
=======
require ‘active_record’
@jessieay
jessieay / refactoring.rb
Created July 27, 2012 23:55
REFACTORING :)
def value
@values = 0
Post.find(self.id).votes.each do |vote|
if vote.vote_value == nil
vote.vote_value = 0
else
@values += vote.vote_value
end
end
@jessieay
jessieay / git
Created October 3, 2012 18:55
thoughtbot Git Process
BEFORE: start trajectory story
* run specific tests wrote (eg: rspec spec/decorators/event_decorator_spec.rb:5)
rake
git status
git diff
@jessieay
jessieay / vim
Created October 4, 2012 18:48
VIM vommands
hjkl - move around
:#,#d - deletes between two lines, eg: :10,12d deletes lines 10 through 12
x - delete character
o - insert on next line
O - insert on preceding line
a - insert after cursor
i - go into insert mode
w - move to beginning of next word (also W for whitespace delimited word)
e - move to end of word (also E for whitespace delimited words)
b - move backward to start of word (also B)
@jessieay
jessieay / merge.rb
Created June 21, 2013 16:35
custom paperclip processor - lives in lib/paperclip_processors
module Paperclip
class Merge < Processor
def initialize file, options = {}, attachment = nil
super
@format = File.extname(@file.path)
@basename = File.basename(@file.path, @format)
@files = attachment.instance.files
end
def make
require 'spec_helper'
describe RecommendationHelper, '#user_name' do
it 'returns the name if the user has a name' do
user = create(:user)
user.stubs(:name).returns('Jane Doe')
ask = create(:ask, user: user)
user_name = user_name(ask)
@jessieay
jessieay / gist:7489216
Created November 15, 2013 18:25
Restoring local database from Heroku
$ heroku pgbackups:capture --expire --app APP_NAME
$ curl -o latest.dump `heroku pgbackups:url --app APP_NAME`
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -d DEVELOPMENT_DATABASE_NAME latest.dump
@jessieay
jessieay / spec for field entry
Last active December 29, 2015 18:59
field entry spec
require 'spec_helper;
describe FieldEntry, '#to_hash' do
it 'returns the correct hash format' do
field_entry = FieldEntry.new("room",["a","b,"c"]).to_hash
expect(field_entry).to eq { name: 'room', values: [ "a", "b", "c"] }
end
end
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.015 000.015: --- VIM STARTING ---
000.132 000.117: Allocated generic buffers
000.599 000.467: locale set
000.606 000.007: window checked
001.068 000.462: inits 1
001.076 000.008: parsing arguments