http://robots.thoughtbot.com/implementing-multi-table-full-text-search-with-postgres
https://github.com/textacular/textacular/blob/master/lib/textacular.rb
| http://www.radford.edu/~mhtay/CPSC120/VIM_Editor_Commands.htm | |
| http://www.cyberciti.biz/faq/vi-show-line-numbers/ |
| class LocalResource | |
| attr_reader :uri | |
| def initialize(uri) | |
| @uri = uri | |
| end | |
| def file | |
| @file ||= Tempfile.new(tmp_filename, tmp_folder, encoding: encoding).tap do |f| | |
| io.rewind |
| require 'optparse' | |
| require 'optparse/time' | |
| require 'ostruct' | |
| require 'pp' | |
| class OptparseExample | |
| CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary] | |
| CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" } |
| //Within jquery you can listen to global ajax event handlers for the outcome of any ajax requests for when you want to write | |
| // your own callback from predefined ajax calls | |
| // e.g. | |
| // the below js call is in a separate js file say 'main.js' | |
| function makeAjaxCall(){ | |
| //... | |
| $.ajax({ | |
| url: 'http://something.com' | |
| }); |
| class Fizzbuzz | |
| def initialize(number) | |
| @number = number | |
| end | |
| def self.count(number) | |
| count = new(number) | |
| count.output_data[count.selector.to_s] | |
| end |
| module Pagination | |
| def paginate(page = 1, items_per_page = size, total_items = size) | |
| @page = 1 | |
| @items_per_page = items_per_page | |
| @total_items = total_items | |
| end | |
| attr_reader :page, :items_per_page, :total_items | |
| def total_pages |
| class GenericParser | |
| def parse(parser) | |
| puts "The parser class received the parse method" | |
| parser.parse | |
| end | |
| end | |
| class JSONParser | |
| def parse | |
| puts "An instance of the JSONParser receives the parse message" |
| module Search | |
| @children = [] | |
| def self.included(base) | |
| @children << base | |
| end | |
| def self.query(val) | |
| @children.each do |child| | |
| child.query(val) |
| MULTIPLE_OF_3 = ->(n){ (n % 3).zero? } | |
| MULTIPLE_OF_5 = ->(n){ (n % 5).zero? } | |
| MULTIPLE_OF_3_AND_5 = ->(n){ MULTIPLE_OF_3[n] && MULTIPLE_OF_5[n] } | |
| (1..100).each do |num| | |
| case num | |
| when MULTIPLE_OF_3_AND_5 | |
| puts "FizzBuzz" | |
| when MULTIPLE_OF_3 | |
| puts "Fizz" |