This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# A complete URL-shortening web application, written in Ruby/Sinatra. Run it | |
# from the command line, and then visit http://localhost:4567/ | |
# | |
# Or to run it under apache/passenger, you'll need a config.ru file with the | |
# following contents: | |
# | |
# require 'tinyurl' | |
# run Sinatra::Application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_data = {} | |
post_data[:name] = 'Title for my link' | |
post_data[:link] = 'http://path.to/my/link' | |
post_data[:caption] = 'A caption' | |
post_data[:description] = 'A description' | |
post_data[:picture] = 'http://path.to/myimage.jpg' | |
post_data[:actions] = { :name => 'My site name', :link => 'http://link.to/my/site'}.to_json | |
client.post("feed", nil, post_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name FB phonebook Exporter | |
// @namespace elleestcrimi | |
// @include https://www.facebook.com/friends/edit/?sk=phonebook* | |
// ==/UserScript== | |
var $; | |
// Add jQuery | |
(function() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
BUNDLE_WITHOUT: "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+module Sunspot | |
+ # monkey patch for Sunspot v 1.1.1 to add support for solr "start" query parameter | |
+ # we can now optionally add a :start number to offset search results | |
+ # in this scenario, we want the first 3 results for the carousel, and then 5 more | |
+ # the code as is requires the start to be set to 3 and the per_page to 8 for this to work | |
+ # a better solution would be to modify the per_page= method but I was unable to do this | |
+ # with alias_method_chain, BF 12/6 | |
+ module Query | |
+ class Pagination | |
+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Macros | |
module Serializer | |
# usage | |
# include Macros::Serializer | |
# e.g. a field named :metadata must be a Hash | |
# serializer :metadata, Hash | |
def self.included(host_class) | |
# field must be a symbol |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modeled off the Physical / Service / Logical layers | |
# advocated by http://enterpriserails.chak.org/full-text/chapter-3-organizing-with-modules | |
module Logical | |
class ARModelName | |
PHYSICAL = ARModel | |
attr_accessor :physical | |
private :physical | |
def initialize(physical) | |
@physical = physical.is_a?(PHYSICAL) ? physical : PHYSICAL.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NameSpace | |
module MyClass | |
def self.included(host_class) | |
host_class.instance_eval do | |
has_one :thing | |
attr_accessible :something | |
validate :foo | |
extend ClassMethods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see http://devblog.avdi.org/2011/05/30/null-objects-and-falsiness/ | |
class NullObject | |
def to_a; []; end | |
def to_s; ""; end | |
def to_f; 0.0; end | |
def to_i; 0; end | |
def tap; self; end | |
def nil?; true; end | |
def present?; false; end | |
def empty?; true; end |
OlderNewer