Skip to content

Instantly share code, notes, and snippets.

View muloka's full-sized avatar
💖
I may be slow to respond.

Muloka muloka

💖
I may be slow to respond.
View GitHub Profile
@muloka
muloka / gist:809637
Created February 3, 2011 15:41
Reducing Friction by Chris Wanstrath
"...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,
@muloka
muloka / Super Simple Chat Server
Created January 17, 2011 20:46
Taken from Introduction to Node: Ryan Dahl
// 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) {
// 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);
});
# 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>"
@muloka
muloka / webapp.rb
Created November 16, 2010 21:41 — forked from igrigorik/webapp.rb
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