This file contains hidden or 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
| <!DOCTYPE html> | |
| <!-- Helpful things to keep in your <head/> | |
| // Brian Blakely, 360i | |
| // http://twitter.com/brianblakely/ | |
| --> | |
| <head> | |
| <!-- Disable automatic DNS prefetching. | |
This file contains hidden or 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
| # support for using named routes from the console | |
| # | |
| # files: lib/railsext.rb | |
| # | |
| module Kernel | |
| private | |
| def use_named_routes_in_the_console! options = {} | |
| include ActionController::UrlWriter | |
| options.to_options! |
This file contains hidden or 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
| # | |
| # I was asked for an example of code that was DRY, but still had an | |
| # instance of Connascence of Algorithm going on. | |
| # | |
| # Consider the following code. I think most people would agree that | |
| # the code is fairly DRY in the sense that there is no duplicated | |
| # code. | |
| # | |
| require 'digest/sha1' |
This file contains hidden or 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
| // | |
| // Backbone.Rails.js | |
| // | |
| // Makes Backbone.js play nicely with the default Rails setup, i.e., | |
| // no need to set | |
| // ActiveRecord::Base.include_root_in_json = false | |
| // and build all of your models directly from `params` rather than | |
| // `params[:model]`. | |
| // | |
| // Load this file after backbone.js and before your application JS. |
This file contains hidden or 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
| module UserHelper | |
| attr_accessor :current_user | |
| class Credentials < Struct.new(:email, :password) | |
| def self.parse(arg) | |
| return arg if arg.is_a?(Credentials) | |
| new(arg) | |
| end | |
| def initialize(credentials) |
This file contains hidden or 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
| BEGIN { | |
| require 'net/http' | |
| Net::HTTP.module_eval do | |
| alias_method '__initialize__', 'initialize' | |
| def initialize(*args,&block) | |
| __initialize__(*args, &block) |
This file contains hidden or 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
| # file: tmpdir_block.rb | |
| # | |
| # this code extends ruby's built-in Dir.tmpdir to accept a block. when passed | |
| # a block the calling process will automatically create and chdir into the | |
| # tmpdir before running the the block. example | |
| # | |
| # require 'tmpdir_block' | |
| # | |
| # Dir.tmdir do | |
| # |
This file contains hidden or 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
| $ node ts.js | |
| 10 Jan 15:01:23 - prepared | |
| 10 Jan 15:01:24 - started | |
| PUT /riak/airlines/KLM | |
| 10 Jan 15:01:24 - saved | |
| 10 Jan 15:01:24 - cleared | |
| GET /riak/airlines/KLM | |
| 10 Jan 15:01:24 - not found! it works |
This file contains hidden or 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
| App.pulse = function(){ | |
| var element = arguments[0]; | |
| var options = arguments[1] || {}; | |
| var n = options.n || App.pulse.n; | |
| var speed = options.speed || App.pulse.speed; | |
| element = jq(element); | |
| element.fadeout = function(){ element.fadeTo(speed, 0.33, element.fadein); }; | |
| element.fadein = function(){ element.fadeTo(speed, 1.00); --n > 0 && element.fadeout(); }; | |
| var id = setTimeout( element.fadeout, speed ); | |
| return(id); |
This file contains hidden or 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
| // add a flash message | |
| // | |
| App.flash = function(msg, options){ | |
| options = options || {}; | |
| var flash = jQuery('.flash'); | |
| var template = App.templates['flash-list-item']; | |
| var data = {'message' : msg}; | |
| var message = jQuery.tmpl(template, data); |