The extend method works similar to include, but unlike include, you can use it to extend any object by including methods and constants from a module. It can add class level methods - something that include can't do.
module Foo
#!/usr/bin/env ruby | |
require 'pdf/reader' # gem install pdf-reader | |
# credits to : | |
# https://github.com/yob/pdf-reader/blob/master/examples/text.rb | |
# usage example: | |
# ruby pdf2txt.rb /path-to-file/file1.pdf [/path-to-file/file2.pdf..] | |
ARGV.each do |filename| | |
PDF::Reader.open(filename) do |reader| |
#!/usr/bin/env ruby | |
require 'pdf/reader' # gem install pdf-reader | |
# credits to : | |
# https://github.com/yob/pdf-reader/blob/master/examples/text.rb | |
# usage example: | |
# ruby pdf2txt.rb /path-to-file/file1.pdf [/path-to-file/file2.pdf..] | |
ARGV.each do |filename| | |
PDF::Reader.open(filename) do |reader| |
//Constructor | |
var Person = function (name, age){ | |
//private properties | |
var priv = {}; | |
//Public properties | |
this.name = name; | |
this.age = age; | |
//Public methods |
class @Facebook | |
rootElement = null | |
eventsBound = false | |
@load: -> | |
unless $('#fb-root').size() > 0 | |
initialRoot = $('<div>').attr('id', 'fb-root') | |
$('body').prepend initialRoot |
/* Delete the tables if they already exist */ | |
drop table if exists Movie; | |
drop table if exists Reviewer; | |
drop table if exists Rating; | |
/* Create the schema for our tables */ | |
create table Movie(mID int, title text, year int, director text); | |
create table Reviewer(rID int, name text); | |
create table Rating(rID int, mID int, stars int, ratingDate date); |
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
headings = %w(id expires bytes cache_key) | |
rows = [] |
namespace :deploy do | |
desc "Hot-reload God configuration for the Resque worker" | |
task :reload_god_config do | |
sudo "god stop resque" | |
sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}" | |
sudo "god start resque" | |
end | |
end | |
# append to the bottom: |
##Requirement for HMAC secret key
var soundex = function (s) { | |
var a = s.toLowerCase().split(''), | |
f = a.shift(), | |
r = '', | |
codes = { | |
a: '', e: '', i: '', o: '', u: '', | |
b: 1, f: 1, p: 1, v: 1, | |
c: 2, g: 2, j: 2, k: 2, q: 2, s: 2, x: 2, z: 2, | |
d: 3, t: 3, | |
l: 4, |