Skip to content

Instantly share code, notes, and snippets.

View mraaroncruz's full-sized avatar
🏃‍♂️

Aaron Cruz mraaroncruz

🏃‍♂️
View GitHub Profile
@BrianTheCoder
BrianTheCoder / Gemfile
Created October 23, 2009 20:05
an example of full text search in postgres using datamapper
source "http://gems.github.com"
source "http://gemcutter.org"
bundle_path "gems"
gem "dm-core"
gem "dm-migrations"
gem "dm-sweatshop"
gem "data_objects"
gem "do_postgres"
@EmmanuelOga
EmmanuelOga / r191.txt
Created December 26, 2009 22:42
curb, typhoeus, net:http, em-http quick benchmark
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]
curb (0.6.2.1)
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
presidentbeef / rubychat.rb
Created January 6, 2011 08:02
Simple Ruby chat with GServer
require 'gserver'
class ChatServer < GServer
def initialize *args
super
#Keep a list for broadcasting messages
@chatters = []
#We'll need this for thread safety
@daz
daz / gist:818065
Last active September 24, 2015 22:18
Google Analytics Rails helper
# <%= 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}']);
# 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?"
else
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
josevalim / lint_test.rb
Created February 7, 2012 21:16
Custom AMo model for forms
class LintTest < ActiveSupport::TestCase
include ActiveModel::Lint::Tests
class Model
# model.to_model
include ActiveModel::Conversion
# Implements Model.model_name
extend ActiveModel::Naming
@perliedman
perliedman / README.markdown
Created March 26, 2012 12:17 — forked from jrust/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)

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
phil-monroe / rails_c_cap.rb
Created June 16, 2012 00:49
Capistrano task to remotely connect to rails console
# Based off of https://gist.github.com/1115513
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}'"
end
@maccman
maccman / app.rb
Created July 6, 2012 18:04
Sinatra Async UI chat
#!/usr/bin/env ruby
# coding: utf-8
require 'sinatra'
set :server, 'thin'
set :sessions, true
streams = Hash.new {|k, v| k[v] = [] }
helpers do
def session_id
@avinasha
avinasha / Gemfile
Created July 18, 2012 10:08
Platform dependent gems
group :production, :test, :cucumber, :staging do
gem 'rb-inotify', :require => false
end
group :test, :development, :cucumber do
gem 'rb-fsevent', :require => false
end