Skip to content

Instantly share code, notes, and snippets.

View jfarmer's full-sized avatar
🐢

Jesse Farmer jfarmer

🐢
View GitHub Profile

There is an image of a school growing up in my mind all the time; a school where some actual and literal constructive activity shall be the centre and source of the whole thing, and from which the work should always be growing out in two directions — one the social bearings of that constructive industry, the other the contact with nature which supplies it with its materials.

— John Dewey to Alice Chipman Dewey and children, November 1st, 1894, John Dewey Papers

I stumbled across this quote while reading The Metaphysical Club, a fantastic book about the birth and evolution of the Pragmatic tradition in the United States. What struck me most was that it an almost perfect reflection of how I thought about our work at Dev Bootcamp.

One of the most common questions about Dev Bootcamp I got from students, press, and other entrepreneurs is somethi

Questions

How do I get it to return per line, isn't that the point of this exercise? For instance, how would I get it to return each value, such as line 35's list "total = 0" on one line, next "total = 0 + 11", next line "total = 11+22".

I could not find a way to do it like, 'running_total = return item[0], return item[0] + item[1]...item[i]'.

First, it's good that you understand what you need to do and are referring to the last item of the list as item[i]. Keep in mind that if the list is in the variable list then to get the item at, say, index 10, we want list[10], not item[10]. Imagine if you could write code like this:

def sum(list)
@jfarmer
jfarmer / LICENSE
Last active August 29, 2015 14:01
A very simple REPL. Copyright 2014 CodeUnion, Inc.
Copyright (C) 2014 CodeUnion, Inc. (http://codeunion.io)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@jfarmer
jfarmer / rot_n_jesse.rb
Last active August 29, 2015 14:05 — forked from Katzy/ROTN
def rot_n_char(char, rot_by)
fail ArgumentError, "First argument must be a 1-letter String (got `#{char}')" unless char.length == 1
case char
when ('a'..'z')
((char.ord - 'a'.ord + rot_by) % 26 + 'a'.ord).chr
when ('A'..'Z')
((char.ord - 'A'.ord + rot_by) % 26 + 'A'.ord).chr
else
char
SELECT p.*
FROM projects AS p
JOIN genres_projects AS gp
ON (gp.project_id = p.id)
JOIN genres AS g
ON (gp.genre_id = g.id)
WHERE g.name IN ('Drama', 'Comedy')
GROUP BY p.id
# Method name: item_counts
# Input: An arbitrary array
#
# Returns: A hash where every item is a key whose value is the number of times
# that item appears in the array
#
# Prints: Nothing
# Version 0.1
# ====================================================
require 'rubygems'
require 'sinatra'
set :environment, :production
disable :run, :reload
get '/' do
"Hey"
end
run Sinatra::Application
Backtrace: /usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/parser.rb:535:in `process'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/parser.rb:15:in `parse'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/service.rb:19:in `post'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/session.rb:511:in `post_without_logging'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/session.rb:522:in `post'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/logging.rb:27:in `log_fb_api'
/usr/local/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/logging.rb:27:in `log_fb_api'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/session.rb:521:in `post'
/usr/local/lib/ruby/gems/1.8/gems/facebooker-1.0.29/lib/facebooker/session.rb:179:in `secure!'
callback same
url different
api key different
secret different
var inject = function(iterable, initial, func) {
var cur = initial
for(var i = 0;i < iterable.length;i++) {
cur = func(cur, iterable[i])
}
return cur
}
var map = function(arr, func) {
return inject(arr, [], function(memo, val) {