This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# layout_helper.rb | |
module LayoutHelper | |
def headjs | |
["/javascripts/jquery.js","/javascripts/rails.js","/javascripts/application.js"] | |
end | |
def headjs_show | |
"<script type='text/javascript'> | |
head.js('#{headjs.join('\',\'')}'); | |
</script>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just | |
// put a "data-behaviors" attribute on your view elements, and then assign callbacks | |
// for those named behaviors via Behaviors.add. | |
var Behaviors = { | |
add: function(trigger, behavior, handler) { | |
document.observe(trigger, function(event) { | |
var element = event.findElement("*[data-behaviors~=" + behavior + "]"); | |
if (element) handler(element, event); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: http://camp.nodejs.org/videos/session-01_introduction_to_node-ryan_dahl.html | |
// Handles TCP connections | |
net = require('net'); | |
// define global variables | |
people = [] | |
// create tcp server | |
s = net.createServer(function(socket) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"...if there's one thing I've learned from Rails, it's to get the hell out of | |
the way and let people focus on the task at hand. | |
Reduce friction. | |
Newton's first law of motion, as commonly written, makes two statements: an | |
object at rest tends to stay at rest and an object in motion tends to stay in | |
motion. It's often referred to as the Law of Inertia. | |
And inertia, for those who don't remember or didn't take high school physics, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code, create, and share | |
- create solutions to sore points | |
- reduce friction, stream line processes | |
- create projects that scratch an itch or ease some pain | |
- start contributing to official documentation efforts | |
- focus more on community and less on yourself | |
Remember, Code talks. | |
- Talk (and read) less, Code More | |
- If you want to run your own business, code is the perfect way to find cofounders and employees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (functionName, container){ | |
var index; | |
function log(){ | |
console.log(index); | |
} | |
function iterate(){ | |
log(); | |
if(index>1) setTimeout(iterate, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// functional | |
var logCar = function (obj){ | |
return function(){ | |
"I'm a" + obj.color + " " + obj.make; | |
} | |
} | |
// Example call for functional version: | |
logCar({ color: 'blue', make: 'BMW' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var logCar = function (obj){ return "I'm a" + obj.color + " " + obj.make; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Write a class to support the following code: | |
var Person = function(name) { this.name = name; } | |
var thomas = new Person('Thomas'); | |
var amy = new Person('Amy'); | |
thomas.name // --> "Thomas" | |
// 2. Add a getName() method to all Person objects, that outputs |
OlderNewer