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
| Array::arrayObjectIndexOf = (obj) -> | |
| for elem, i in @ | |
| if(angular.equals(elem, obj)) | |
| return i | |
| -1 |
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 CoreExt | |
| module PathExtension | |
| # this method recursively calls fetch with every key you provide | |
| # the last key argument is used as the default value | |
| def path(*keys) | |
| key = keys.shift | |
| case keys.length | |
| when 0 |
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
| # brew install tor / apt-get install tor | |
| # follow the instructions to start the tor server | |
| # gem install socksify | |
| require 'socksify/http' | |
| uri = URI.parse('http://rubyforge.org/') | |
| # 9050 is the tor port | |
| Net::HTTP.SOCKSProxy('127.0.0.1', 9050).start(uri.host, uri.port) do |http| |
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
| class Hash | |
| # reverses the order of a hash | |
| # { a: 100, b: 200 }.reverse => { b:200, a:100 } | |
| def reverse | |
| self.class[to_a.reverse] | |
| end | |
| end |
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 CouchbaseAttributes | |
| module ClassMethods | |
| def couchbase_attribute(name) | |
| class_eval %Q{ | |
| def #{name}=(value) | |
| Couchbase.bucket.set([couchbase_id, '#{name}'].join('::'), value) | |
| end | |
| def #{name} |
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
| Encoding.default_external = Encoding::UTF_8 | |
| Encoding.default_internal = Encoding::UTF_8 | |
| source 'https://rubygems.org' | |
| gem 'redis' | |
| gem "hiredis" | |
| gem "em-synchrony" | |
| gem 'json' |
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
| class Contact < ActiveRecord::Base | |
| state_machine :state, :initial => :imported do | |
| state :imported | |
| state :contacted | |
| state :verified | |
| state :prospect | |
| state :deleted | |
| end |
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
| require 'rubygems' | |
| require 'RMagick' | |
| class Pdf2PngConverter | |
| def initialize(*files) | |
| files.each do |file| | |
| pdf = Magick::ImageList.new(file) | |
| filename = "#{File.join(File.dirname(file), File.basename(file, '.*'))}.png" | |
| pdf[0].resize_to_fit(100,100).write(filename) | |
| # gem install smusher: |
NewerOlder