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
# open-uri vs rio | |
require 'rubygems' | |
require 'open-uri' | |
require 'rio' | |
require 'benchmark' | |
n = 500 | |
Benchmark.bm do |x| | |
x.report { for i in 1..n; open("http://localhost:4000/robots.txt?b#{i}").to_a; 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
var RemoteAndRemove = $.klass({ | |
request:function(add) { | |
var url = $(this.element).url; | |
var element = $(this.element); | |
$.post(url,{authenticity_token: AUTH_TOKEN, complete: function(){ element.remove()} }); | |
}, | |
onclick:function(){ | |
this.request(); | |
} |
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
#!/usr/bin/env ruby19 | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
# EDIT POST_RECEIVE_URL | |
POST_RECEIVE_URL = 'http://hostname:8910/repository-name/push' | |
old_head, new_head, ref = STDIN.gets.split |
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
#!/usr/bin/env ruby | |
# | |
# This is the post receive script for git and integrity. Copy | |
# this script into the hooks directory of your gitosis managed | |
# repository and run 'chmod 750 post-receive'. Then your project | |
# will be run the integrity tests each time someone pushes to | |
# the master branch. | |
# | |
# This version relies on wget. wget will run in background. | |
APP_NAME = "app.name.on.integrity" |
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
marcus@TAOX:~/Projects/cancao-ecom master$ rake db:migrate --trace | |
(in /Users/marcus/Projects/cancao-ecom) | |
/Users/marcus/Projects/cancao-ecom/vendor/plugins/integration/tasks | |
** Invoke db:migrate (first_time) | |
** Invoke environment (first_time) | |
** Execute environment | |
Loading haml-edge gem. | |
Warning: Error loading /Users/marcus/Projects/cancao-ecom/app/models/product.rb | |
Warning: Error loading /Users/marcus/Projects/cancao-ecom/app/models/sale.rb | |
Warning: Error loading /Users/marcus/Projects/cancao-ecom/app/models/shipping_discount.rb |
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
Rails CMS alternatives | |
====================== | |
Active projects: | |
--------------- | |
adva-cms | |
repo: http://github.com/svenfuchs/adva_cms/ | |
site: http://adva-cms.org/ | |
Last update: 11/24/09 | |
"the cutting edge Rails CMS platform" |
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
#!/bin/bash | |
# run with: curl -s http://gist.github.com/265272.txt | bash | |
set -e | |
localdir=$HOME/.mongodb | |
datadir=$localdir/data | |
conf=$localdir/mongod.conf | |
agentdir=$HOME/Library/LaunchAgents | |
agent=$agentdir/org.mongodb.mongod.plist |
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
file 'Gemfile', <<-GEMS | |
source 'http://gemcutter.org' | |
gem "rails", "3.0.0.beta3" | |
gem "bson_ext" | |
gem "mongoid", "2.0.0.beta4" | |
gem "haml", "3.0.0.rc.2" | |
gem "compass", "0.10.0.rc4" | |
gem "inherited_resources" | |
group :test do |
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
class Address | |
include Mongoid::Document | |
belongs_to :user, :inverse_of => :addresses | |
belongs_to :venue, :inverse_of => :venues | |
field :street, :type => String | |
field :city, :type => String | |
field :state, :type => String | |
field :zip, :type => Integer |
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
module MultiParameterAttributes | |
def filter_time(attributes, name) | |
attrs = attributes.collect do |key, value| | |
if key =~ /^#{Regexp.escape(name.to_s)}\((\d+)(\w)\)$/ | |
[$1.to_i, value.send("to_#$2")] | |
end | |
end.compact.sort_by(&:first).map(&:last) | |
Time.zone.local(*attrs) unless attrs.empty? | |
end |
OlderNewer