Skip to content

Instantly share code, notes, and snippets.

@Elffers
Elffers / sql_vs_ar
Created March 24, 2015 19:13
SQL/Active Record querying
Benchmark.bm do |x|
x.report("sql"){ 5000.times { Person.where(id:2).pluck("created_at").first } }
x.report("sql"){ 5000.times { Person.find(2).created_at } }
end
[#<Benchmark::Tms:0x000001065b1240
@cstime=0.0,
@cutime=0.0,
@label="sql",
@real=1.558864,
@Elffers
Elffers / bug.md
Last active August 29, 2015 14:03
Issue with cast method to convert between coordinate systems

Following the instructions for converting points between different coordinate systems posted on http://daniel-azuma.com/articles/georails/part-4, I tried:

require 'rgeo'
require 'pp'

north_wa_proj4 = '+proj=lcc +lat_1=48.73333333333333 +lat_2=47.5 +lat_0=47 +lon_0=-120.8333333333333 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs'
north_wa_wkt = <<WKT
PROJCS["NAD83 / Washington North (ftUS)",

GEOGCS["NAD83",

###Computers are, in fact, pretty dumb

In our current, technology-rich age, it's easy to take for granted what technology can do. We have technology that can direct us step-by-step when we're driving, taking into account live traffic conditions, technology that can identify constellations in the night sky (even during the day), technology that can connect us into meetings being held many time zones away.

And yet, technology, at a basic level, is pretty stupid. Google Voice and Siri notwithstanding, if we tell a computer something like, "Could you hand me that book?" it would have no idea what to do, without a lot of context pre-programmed into it. If we were to anthropomorphize the computer for a minute--let's call him Bob--and tell him to hand us a book. "Where is the book?" he might first ask. "On the coffee table," you might say. "I can't hand it to you, there is a coffee mug on top of it." Bob looks at the coffee mug in puzzlement.

@Elffers
Elffers / Method.md
Last active December 27, 2015 09:49
Documentation on array and hash methods investigated by class

###Homework for 4 November 2013

####Array Method

  • delete_if

######Returns an array

Syntax: array.delete_if { | item | block }

Removes element from array if code block returns true.

@Elffers
Elffers / TechnicalReading.md
Last active December 24, 2015 02:49
Ada Application, Step 3: Technical Reading Assessment

####1. In "Laying the foundations", Ryan covers a number of steps that he'll walk through. What are they?

  • Set up subscription engine and dummy application to test its functionality. The engine will be created using the rails plugin ‘new generator.’
  • Write the first feature for the engine, which is account sign up.
  • Link the accounts to an owner, who will be responsible for admin-type actions for the account.
  • Write features to handle user sign in, sign up and sign out, with the goal of scoping resources for a given application.

####2. What's a Rails Engine?

@Elffers
Elffers / Logic Problem.md
Last active December 24, 2015 01:39
Logic Problem

###Logic Puzzle

In the year 2034, Seattle has finished building an underground metro that serves the whole city. Susannah is a native Seattleite who lives in the middle of Capitol Hill and takes the metro to the grocery store every Sunday. The metro runs right underneath Broadway Avenue. There is a single platform in the middle that allows Susannah to get on a train in either direction. Susannah's train stop is equidistant from two QFC grocery stores, the one at Broadway Market and the one at Harvard Market. She arrives at the platform at a random time every Sunday. Both trains run every 10 minutes. She doesn't care which grocery store she goes to, but she is surprised to find out that she ends up going to the QFC at Harvard Market 90% of the time. Why is Susannah ending up at one grocery store significantly more often than the other?


####1. Why is Susannah going to the Harvard Market QFC most of the time?

Susannah ends up g