Skip to content

Instantly share code, notes, and snippets.

1-28-2015 NYC LPEP $20.16
1-29-2015 DEN $17.06
1-30-2015 Aden Food Market $11.89
1-30-2015 ZIZI LIMONA $96.65
1-31-2015 FOODTOWN $67.49
2-4-2015 NYC-TAXI $15.96
2-4-2015 DRAM $21.00
2-4-2015 BALTHAZAR $42.40
2-5-2015 DINER $31.13
2-7-2015 DOTORY $23.60
@octosteve
octosteve / closures.js
Created November 11, 2014 17:58
A quick illustration of closures in JavaScript
var InnerSchool = (function(){
function Course(name){
this.name = name;
}
function School(name){
this.name = name;
this.courses = [];
}
@octosteve
octosteve / notes.js
Created November 10, 2014 20:44
Notes from Objects In Javascript talk
// School, Student, Course
// function communicateSlogan(){
// return this.name + " : " + this.slogan;
// }
//
// var flatiron = {
// name: "The Flatiron School",
// slogan: "Learn to program, and pick locks",
// saySlogan: communicateSlogan
// };
@octosteve
octosteve / LIES
Created July 10, 2014 21:27
Lies about time to run
➜ time bin/rspec
...
Finished in 0.12155 seconds (files took 1.09 seconds to load)
3 examples, 0 failures
bin/rspec 1.38s user 0.24s system 98% cpu 1.646 total
➜ time rspec
...
Finished in 0.11989 seconds (files took 1.31 seconds to load)
>> [*1..100].reject{|num| num.odd?}
=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]
>> [*1..100].reject(&:odd?)
=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]
>> odd_proc = &:odd?
SyntaxError: (irb):43: syntax error, unexpected &
odd_proc = &:odd?
^
from /Users/StevenNunez/.rubies/ruby-2.1.1/bin/irb:11:in `<main>'
>> odd_proc = :odd?.to_proc
class Grid
attr_reader :coordinate_list
def initialize(coordinate_list)
@coordinate_list = coordinate_list
end
def find_all_matches(x, y)
find_target_pixels(x,y).each do |t_x, t_y|
if eligable_for_painting?([t_x, t_y], [x,y])
matches << [t_x, t_y]
Final Projects from BEWD 5
Flash sale app
http://intense-stream-5307.herokuapp.com/
Ten Thousand Hours
http://infinite-basin-5033.herokuapp.com
Photobooth app
http://hidden-reaches-9583.herokuapp.com/
$navbar-default-brand-color: #3c3c1d;
$navbar-default-bg: #e68f3f;
$jumbotron-bg: #ba8751;
$body-bg: #dac19e;
$panel-bg: #f4efdd;
$brand-primary: #9b2d0a;
$text-color: #491407;
$link-color: #ba8751;
$btn-primary-color: #f4efdd;
$navbar-height: 70px;
@octosteve
octosteve / find_or_create.rb
Created December 14, 2013 02:23
Joe Example
#Say we have Category and Shirt models. We have a tags join model the bind the 2 together.
# Models look like this
class Category < ActiveRecord::Base
has_many :tags
has_many :shirts, through: :tags
end
class Shirt < ActiveRecord::Base
has_many :tags
@octosteve
octosteve / mechanize.rb
Created December 11, 2013 04:50
Mechanize USPSification Station
# make sure you gem install mechanize
require 'mechanize'
# fake it like we're safari
a = Mechanize.new { |a| a.user_agent_alias = 'Mac Safari'}
# look up all mail boxes in 10001. This returns 50 results.
a.get('https://tools.usps.com/go/POLocatorAction!input.action?address=10001&radius=1000&locationTypeQ=collectionbox#paginationTop')
# a is now 'on' that page
# returns all of the location ids on the page
a.page.search('#locationID').map(&:text)
# This will probably be replaced by a model of Collection box