Skip to content

Instantly share code, notes, and snippets.

View jpablobr's full-sized avatar

Pablo Barrantes jpablobr

View GitHub Profile
@jpablobr
jpablobr / oo.sh
Created July 19, 2011 18:17
OO support functions
#!/bin/bash
# ---------------------------------------------------------------------------
# OO support functions
# Kludged by Pim van Riezen <[email protected]>
# ---------------------------------------------------------------------------
DEFCLASS=""
CLASS=""
THIS=0
@jpablobr
jpablobr / curl_rest_api_tester.sh
Created June 2, 2011 23:59
Curl REST API tester
#!/bin/bash
AUTH="user:password"
BASE="http://url.com/"
METHOD=$1
DEST="$BASE$2"
XML=$3
# or
# JSON=$3
# make sure args were passed
@jpablobr
jpablobr / gist:972748
Created May 14, 2011 23:20
rails-template.rb
# Delete unnecessary files
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm -f public/javascripts/*"
# Download JQuery
run "curl -L http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js > public/javascripts/jquery.js"
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
@jpablobr
jpablobr / gist:948374
Created April 29, 2011 14:27 — forked from tmm1/gist:329682
EM Chat Server Demo
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
class String
def bold
"\033[1m#{self}\033[0m"
end
end
=> Booting WEBrick
=> Rails 3.0.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-04-08 12:13:22] INFO WEBrick 1.3.1
[2011-04-08 12:13:22] INFO ruby 1.9.2 (2010-12-25) [x86_64-linux]
[2011-04-08 12:13:22] INFO WEBrick::HTTPServer#start: pid=6213 port=3000
cache: [GET /refinery/] miss
cache: [GET /refinery/] miss
@jpablobr
jpablobr / add_encryptable_to_users.rb
Created April 5, 2011 15:40
[DEVISE] upgrade to 1.2
# [DEVISE] From version 1.2, there is no need to set your encryptor to
# bcrypt since encryptors are only enabled if you include :encryptable
# in your models. To update your app, please:
# 1) Remove config.encryptor from your initializer;
# 2) Add t.encryptable to your old migrations;
# 3) [Optional] Remove password_salt in a new recent migration. Bcrypt
# does not require it anymore.
# $ rails g migration AddEncryptableToUsers
OrderMailer.class_eval do
def confirm(order, resend = false)
@subject = (resend ? "[RESEND] " : "")
@subject += Spree::Config[:site_name] + ' ' + 'Order Confirmation #' + order.number
@body = {"order" => order}
@recipients = order.email
@from = Spree::Config[:order_from]
@bcc = order_bcc
@sent_on = Time.now
@content_type = "multipart/mixed"
@jpablobr
jpablobr / email.rb
Created March 25, 2011 01:04
Displays Sendgrid statistics for Heroku apps
class Heroku::Command::Sendgrid < Heroku::Command::Base
def test_email
app = extract_app
vars = heroku.config_vars(app)
to = ''
args.each do |arg|
key, value = arg.split("=")
to = value if key == "to"
end
# See also:
# Fine-tuning tab completion in Bash,
# http://codesnippets.joyent.com/posts/show/1690
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
export IFS=$' \t\n'
help fc
jQuery(function () {
var cache = {},
url = "/posts/autocomplete",
lastXhr;
jQuery("#SearchFormInputId").autocomplete({
minLength: 2,
delay: 125,
html: true,
source: function(request, response) {
var term = request.term;