Skip to content

Instantly share code, notes, and snippets.

View jpablobr's full-sized avatar

Pablo Barrantes jpablobr

View GitHub Profile
# What's the output of this program?
# Compare Ruby 1.8 to 1.9.
def fl; lambda { return 1 }.call; 2; end
def fp; proc { return 1 }.call; 2; end
def fPn; Proc.new { return 1 }.call; 2; end
puts fl
puts fp
puts fPn
#!/usr/bin/env ruby
# To install:
# about:config
# create a new boolean network.protocol-handler.external.txmt with value true
# create a new string network.protocol-handler.app.txmt with value path to the script
require 'rubygems'
require 'cgi'
require 'uri'
#!/bin/bash
scp ~/.ssh/id_rsa.pub $1:~
ssh $1 "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod -R 600 ~/.ssh/* && cat ~/id_rsa.pub >> ~/.ssh/authorized_keys && rm ~/id_rsa.pub"
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@jpablobr
jpablobr / js-class.js
Created November 20, 2010 21:40
JavaScript class
var MyClass = (function () {
// private static
var fooBar = 1;
// constructor
var cls = function () {
// private
var id = fooBar++;
var name = 'baz';
@jpablobr
jpablobr / ruby-libnotify-config
Created January 2, 2011 12:57
ruby-libnotify config setup
# Config for installing
# https://github.com/vargolo/ruby-libnotify.git
prefix=/home/jpablobr/.rvm/rubies/ruby-1.9.2-p136@app
site-ruby=$prefix/lib/ruby/site_ruby/1.9.1
ruby-prog=$prefix/bin/ruby
ruby-path=$prefix/bin/ruby
make-prog=make
site-ruby-common=$prefix/lib/ruby/site_ruby
@jpablobr
jpablobr / test-services-via-curl.sh
Created January 7, 2011 13:01
test-services-via-curl
#!/usr/env bash
RESULT=`curl -ipost -s http://service.com/api/users -pname=Jhon+Doe -pid=12`
if [[ $RESULT =~ 'jhon-doe' ]]
echo "Test Create: Success. Got: $result"
else
echo "Test Create: Failure. Got: $result"
endif
#!/bin/bash
#
# Author: Josh Frye <joshfng>
# Licence: MIT
#
# Contributions from: Wayne E. Seguin <wayneeseguin@gmail.com>
#
# To run:
# sudo apt-get -y install curl && curl https://github.com/joshfng/railsready/raw/master/railsready.sh >> railsready.sh && chmod a+x railsready.sh && ./railsready.sh
# The script will ask if you want to build Ruby from source or install RVM
@jpablobr
jpablobr / fdswap.sh
Created January 24, 2011 15:05
File Description Swapper
#!/bin/bash
#
#
# Usage: <old logfile> <new logfile> [ optional pids ]
# ./swap.sh /var/log/logfile /tmp/logfile [pids]
#
# Author: Robert McKay <rob...@mckay.com>
# Date: Tue Aug 14 13:36:35 BST 2007
# url: http://bit.ly/eEYfp5
var dickbar = function() {
var opts = {
"symbol" : "&#10026;",
"font-size": "64px",
"color": "#eee",
"time": 3000
};
if(window.dickbar && window.dickbarOptions) {
var d = window.dickbarOptions;
if(d["font-size"]) opts["font-size"] = d["font-size"];