Skip to content

Instantly share code, notes, and snippets.


Aaron Cruz mraaroncruz

View GitHub Profile
BrianTheCoder / Gemfile
Created Oct 23, 2009
an example of full text search in postgres using datamapper
View Gemfile
source ""
source ""
bundle_path "gems"
gem "dm-core"
gem "dm-migrations"
gem "dm-sweatshop"
gem "data_objects"
gem "do_postgres"
tansengming / crawl.rake
Created Oct 29, 2009
Rake task to crawl you rails app for broken links
View crawl.rake
# Use this to look for broken links in your app.
# crawls the development server http://localhost:3000
# Suggestion: Also check to make sure that intentional 404s
# are handled gracefully by app.
task :crawl => :environment do
require 'anemone'
root = 'http://localhost:3000'
options = {:discard_page_bodies => true, :verbose => true}
EmmanuelOga / r191.txt
Created Dec 26, 2009
curb, typhoeus, net:http, em-http quick benchmark
View r191.txt
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
curb (
em-http-request (0.2.5)
eventmachine (0.12.10)
typhoeus (0.1.13)
user system total real Memory (Kb)
4kb std
0.000000 0.000000 3.010000 ( 22.408594) 24,484
View nginx.conf
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
ged / copyfrom.rb
Created Sep 28, 2010
Example of how to use COPY FROM from Ruby with the 'pg' library. The last two edits are demonstrating the error case and the successful case.
View copyfrom.rb
#!/usr/bin/env ruby
require 'pg'
require 'stringio'
$stderr.puts "Opening database connection ..."
conn = PGconn.connect( :dbname => 'test' )
conn.exec( <<END_SQL )
swaroopch / flask-boilerplate-tmux.bash
Created Dec 5, 2010
A command that scripts a tmux session
View flask-boilerplate-tmux.bash
function flask-boilerplate-tmux
cd $BASE
tmux start-server
tmux new-session -d -s flaskboilerplate -n model
presidentbeef / rubychat.rb
Created Jan 6, 2011
Simple Ruby chat with GServer
View rubychat.rb
require 'gserver'
class ChatServer < GServer
def initialize *args
#Keep a list for broadcasting messages
@chatters = []
#We'll need this for thread safety
foysavas / helpers.rb
Created Jan 31, 2011
Carrierwave, DataMapper, & Sinatra starring in "Imagine the Possibilities"
View helpers.rb
def is_ajax_request?
if respond_to? :content_type
if request.xhr?
daz / gist:818065
Last active Sep 24, 2015
Google Analytics Rails helper
View gist:818065
# <%= google_analytics 'UA-XXXXXX-XX' %>
# </body>
# application_helper.rb
module ApplicationHelper
def google_analytics(id)
content_tag :script, :type => 'text/javascript' do
"var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#{id}']);
collegeman /
Created Mar 9, 2011
Turn an Ubuntu 10.04 linode into a StatsD/Graphite server
# install git
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
# download the Node source, compile and install it
git clone
cd node
sudo make install
# install the Node package manager for later use