Skip to content

Instantly share code, notes, and snippets.

View mguterl's full-sized avatar

Mike Guterl mguterl

View GitHub Profile
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
# 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!
#
# 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'
@trydionel
trydionel / backbone.rails.js
Created November 28, 2010 16:47
Makes Backbone.js play nicely with default Rails setup
//
// 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.
@mattwynne
mattwynne / user_helper.rb
Created December 8, 2010 19:31
Cucumber support module for helping with authentication of users.
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)
@ahoward
ahoward / net-http-debug.rb
Created December 10, 2010 20:06
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
# 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
#
@seancribbs
seancribbs / test_server.coffee
Created January 7, 2011 18:00
WIP port of Ripple's Riak::TestServer to riak-js
$ 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
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);
@ahoward
ahoward / application.js
Created January 11, 2011 00:28
flash partial
// 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);