Skip to content

Instantly share code, notes, and snippets.

View brianjlandau's full-sized avatar

Brian Landau brianjlandau

  • Walnut Creek, CA
View GitHub Profile

Martin DeMello's Gooey Challenge

Original URL: http://hackety.org/2008/06/12/martinDemellosGooeyChallenge.html

June 12th 12:57
by why

Martin DeMello:

One of the most interesting facets of a desktop GUI system is how easy it makes it to go off the beaten track, particularly how well you can add “first class” components to the system. (Using ‘first class’ here to mean ‘on an equal footing with the widgets supplied by the toolkit’). Also, as a ruby programmer, I’d naturally rather not drop down into C (or Java) to do this.

@brianjlandau
brianjlandau / gist:176754
Created August 28, 2009 02:59 — forked from defunkt/gist:162444
Rails Capistrano deploy using git as our deployment strategy. You'll need git version >=1.5.6.6 on your server for this to work.
# you'd obviously have more settings somewhere
set :scm, :git
set :repository, "[email protected]:defunkt/github.git"
set :branch, "origin/master"
set :migrate_target, :current # this tells capistrano where to run the migration. otherwise it would try to use the latest release directory (/path/to/app/releases/2012XXXXXXXXX)
set :use_sudo, false
set :ssh_options, {:forward_agent => true} # so you can checkout the git repo without giving the server access to the repo
set :rails_env, 'production'
# These are here to override the defaults by cap
@brianjlandau
brianjlandau / deep_freeze.rb
Created September 2, 2009 16:05
Deep freeze for enumerable objects in Ruby
module Enumerable
def deep_freeze
unless self.is_a? String
frozen = self.dup.each do |key, value|
if (value.is_a?(Enumerable) && !value.is_a?(String))
value.deep_freeze
else
value.freeze
end
end
@brianjlandau
brianjlandau / A Costly Parade.markdown
Created September 14, 2009 14:56
An archive of _why's blog post on the "Zed Shaw Fiasco" http://hackety.org/2008/11/21/aCostlyParade.html

A Costly Parade

by why the lucky stiff

Adam Wiggins: First, Rubyists love elegance.

Daniel Lyons:Every programmer worth a damn thinks they love elegance.

Rubyists love life. Boy, I tell you. They love humans. They love cars!! They looooooove dishes of real, actual food. You don’t even know. Airplanes in mid-air, refueling? They love that!

require 'test/unit'
require 'mocha'
require 'shoulda'
class Snowflake
def execute_something
system "/bin/ls -A1 ~"
end
end
@brianjlandau
brianjlandau / jquery.benchmark.js
Created November 30, 2009 19:41
A useful function for benchmarking a block of code and displaying the results on the page. *Depends on jQuery
// based on methodology developed by PPK:
// http://www.quirksmode.org/blog/archives/2009/08/when_to_read_ou.html
(function($){
$.benchmark = function(times, result_selector, func){
var startTime = new Date().getTime();
while (times != 0){
func();
times--;
}
Library Simple Test Loop Test Compiled Test
jQote 0.6906 1.001
jQuery template 0.548 3.782
mustache.js 0.5738 1.052
nano 0.5284 3.6514
Srender 0.6666 0.9622
Tempest 0.5474 4.6568 0.5694
Underscore 0.68 0.9846 0.5298
jquery_templates 0.725 1.0572
microtmpl 0.7842 1.0082 0.7564
(function($) {
$.fn.disable = function(){
return this.attr('disabled', 'disabled');
};
$.fn.enable = function(){
return this.removeAttr('disabled');
};
})(jQuery);
@brianjlandau
brianjlandau / flagable.rb
Created January 21, 2010 18:24
acts_as_flagable
module ActiveRecord
module Acts
module AsFlagable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_flagable(options, flagable_column = 'flags')
unless flagable?
# To be used with acts_as_paranoid
module ActiveRecord
module RecoverDuplicate
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def recover_deleted_duplicate_on(*attributes)