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| 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: |
| class ActionView::Helpers::FormBuilder #:nodoc: | |
| def autocomplete_field(method, source, options = {}) | |
| @template.autocomplete_field(@object_name, method, source, objectify_options(options)) | |
| end | |
| end |
| #!/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 = [] |
| /* 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); |
| class @Facebook | |
| rootElement = null | |
| eventsBound = false | |
| @load: -> | |
| unless $('#fb-root').size() > 0 | |
| initialRoot = $('<div>').attr('id', 'fb-root') | |
| $('body').prepend initialRoot |
| vi ~/.bash_aliases | |
| python | |
| >>> 2.7.0 | |
| alias python=python3 | |
| >>> 3.4.3 |
| //Constructor | |
| var Person = function (name, age){ | |
| //private properties | |
| var priv = {}; | |
| //Public properties | |
| this.name = name; | |
| this.age = age; | |
| //Public methods |
| #!/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| |