Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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’
<?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 / gist:3042429
Created July 3, 2012 19:44
ex university- DB
<?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 / First Twilio app
Created June 29, 2012 04:21
sends text messages using twilio gem
require 'twilio-ruby'
class Texter
def initialize
@account_sid = 'xxx'
@auth_token = 'xxx'
@client = Twilio::REST::Client.new(@account_sid, @auth_token)
@from = 'xxx'
end
@jessieay
jessieay / Madlibs funtimes
Created June 28, 2012 04:15
Madlibs funtimes!
puts "Welcome to console mad libs! First you'll enter 21 words, then you'll get a fun story, made by you!"
puts
goodAnswer = false
while (not goodAnswer)
puts "Are you ready to play? Type in 'yes' to begin."
ready = gets.chomp.downcase
if (ready == 'yes')
goodAnswer = true
else
@jessieay
jessieay / Sudoku v1, incomplete
Created June 26, 2012 16:53
Sudoku solver with everything but final solve method working
class Board
def initialize(board_input)
@board_array = []
board_input.split(//).each_with_index do |cell, index|
@board_array << Cell.new(cell, index)
end
end
def find_box(cell_id)
@jessieay
jessieay / Array#collect rewrite
Created June 25, 2012 19:57
Redefinition of array.collect
class Array
def new_collect
result = []
self.each do |index|
result << yield(index)
end
result
end