Skip to content

Instantly share code, notes, and snippets.

View derencius's full-sized avatar
🍀
Wish me luck, I'm fixing my bugs

Marcus Derencius derencius

🍀
Wish me luck, I'm fixing my bugs
  • Ubatuba, São Paulo, Brazil
View GitHub Profile
@derencius
derencius / open-uri vs rio
Created August 22, 2008 23:30
A simple benchmark between open-uri and rio
# 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 }
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();
}
#!/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
#!/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"
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
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"
#!/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
@derencius
derencius / mongoid-heroku.rb
Created May 7, 2010 04:53 — forked from ivanacostarubio/mongoid-heroku.rb
rails3 mongoid template
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
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
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