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"
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
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
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}']);
View gen_cert.rb
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
josevalim / lint_test.rb
Created Feb 7, 2012
Custom AMo model for forms
View lint_test.rb
class LintTest < ActiveSupport::TestCase
include ActiveModel::Lint::Tests
class Model
# model.to_model
include ActiveModel::Conversion
# Implements Model.model_name
extend ActiveModel::Naming
perliedman / README.markdown
Created Mar 26, 2012 — forked from jrust/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)
View README.markdown

This is a fork of a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

  • Support for delaying the lookup (good for preventing too many AJAX requests)
  • Some fixes regarding the data fed to the onselect callback

For the proper source, and other examples, please see the original gist and the extended version

Example showing off all the above features

phil-monroe / rails_c_cap.rb
Created Jun 16, 2012
Capistrano task to remotely connect to rails console
View rails_c_cap.rb
# Based off of
desc "Remote console on the production appserver"
task :console, :roles => ENV['ROLE'] || :web do
hostname = find_servers_for_task(current_task).first
puts "Connecting to #{hostname}"
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && cd #{current_path} && bundle exec rails c #{rails_env}'"
maccman / app.rb
Created Jul 6, 2012
Sinatra Async UI chat
View app.rb
#!/usr/bin/env ruby
# coding: utf-8
require 'sinatra'
set :server, 'thin'
set :sessions, true
streams = {|k, v| k[v] = [] }
helpers do
def session_id
avinasha / Gemfile
Created Jul 18, 2012
Platform dependent gems
View Gemfile
group :production, :test, :cucumber, :staging do
gem 'rb-inotify', :require => false
group :test, :development, :cucumber do
gem 'rb-fsevent', :require => false