Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'dm-core'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
class Sale
include DataMapper::Resource
property :id, Serial
require 'rubygems'
require 'dm-core'
require 'dm-aggregates'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
class Retailer
include DataMapper::Resource
time psql feedstitch_development -qt -c 'SELECT entries.* FROM entries INNER JOIN group_entries ON entries.id = group_entries.entry_id WHERE (group_entries.group_id IN (SELECT id FROM groups WHERE user_id = 1)) ORDER BY entries.published_at DESC LIMIT 10000' &> /dev/null
time mysql feedstitch_development -e 'SELECT entries.* FROM entries INNER JOIN group_entries ON entries.id = group_entries.entry_id WHERE (group_entries.group_id IN (SELECT id FROM groups WHERE user_id = 1)) ORDER BY entries.published_at DESC LIMIT 10000' &> /dev/null
require 'rubygems'
require 'curb'
c = Curl::Easy.new("http://bit.ly/g5Fml")
c.follow_location = true
c.max_redirects = 5
location = nil
c.on_header do |d|
class ApplicationController < ActionController::Base
include Mongolytics::Tracker
end
;(function($) {
$.fn.gistify = function() {
return this.each(function() {
this.innerHTML = 'Loading Gist '+this.id;
$.getJSON("http://gist.github.com/"+ this.id +".json?callback=?", function (gist) {
$('#'+gist.repo).replaceWith(gist.div);
});
});
}
})(jQuery);
track_all_stats # tracks all actions
track_view_stats # tracks index, show
track_change_stats # tracks create, update, destroy
track_stats_for :new, :edit, :show, :destroy # track any action mix, other actions
Mongolytics.stats_for_path user_path(@user) # using the path helper (not url helper)
Mongolytics.stats_for_keys :users, :show # using the controller and action
@tpitale
tpitale / gist:189115
Created September 18, 2009 15:39
In Place NGINX upgrade
curl -O http://sysoev.ru/nginx/nginx-0.7.62.tar.gz
tar zxvf nginx-0.7.62.tar.gz
cd nginx-0.7.62
sudo /usr/local/nginx/sbin/nginx -V
./configure --with-http_ssl_module --add-module=/usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/nginx
sudo make install clean
OLDPID=`cat /usr/local/nginx/logs/nginx.pid`
sudo kill -USR2 $OLDPID
sudo kill -WINCH $OLDPID
sudo kill -QUIT $OLDPID
Garb::Session.login('username', 'password')
class Report
include Garb::Resource
metrics :pageviews
end
Garb::Account.all.each do |account|
profile = account.profiles.first