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"
@tansengming
tansengming / crawl.rake
Created October 29, 2009 07:57
Rake task to crawl you rails app for broken links
# 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
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
# 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 {
server 127.0.0.1:8098;
@ged
ged / copyfrom.rb
Created September 28, 2010 15:45
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.
#!/usr/bin/env ruby
require 'pg'
require 'stringio'
$stderr.puts "Opening database connection ..."
conn = PGconn.connect( :dbname => 'test' )
conn.exec( <<END_SQL )
DROP TABLE IF EXISTS logs;
@swaroopch
swaroopch / flask-boilerplate-tmux.bash
Created December 5, 2010 07:00
A command that scripts a tmux session
#!/bin/bash
function flask-boilerplate-tmux
{
# https://github.com/swaroopch/flask-boilerplate
BASE="$HOME/code/flask-boilerplate"
cd $BASE
tmux start-server
tmux new-session -d -s flaskboilerplate -n model
@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
@foysavas
foysavas / helpers.rb
Created January 31, 2011 18:12
Carrierwave, DataMapper, & Sinatra starring in "Imagine the Possibilities"
def is_ajax_request?
if respond_to? :content_type
if request.xhr?
true
else
false
end
else
false
end
@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}']);
@collegeman
collegeman / setup-statsd.sh
Created March 9, 2011 16:12
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 https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
# install the Node package manager for later use