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 'json' | |
require 'benchmark' | |
json = { | |
:one => { | |
:two => { | |
:three => { | |
:four => { | |
:five => { | |
:six => { |
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
# Example Keen IO API response for a count, grouped by an 'entry' field | |
keen_result = [ | |
{ | |
"entry" => "Apple", | |
"result" => 15 | |
}, | |
{ | |
"entry" => "Orange", | |
"result" => 10 | |
}, |
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
// install the 'request' package first with 'npm install request' | |
var request = require('request'); | |
// replace with your Keen IO project token | |
var projectToken = "501999234-FAKE-PROJECT-ID"; | |
// create a sample JSON event for an event collection | |
var eventCollection = "meals"; | |
var sampleEvent = { | |
username: "ralph", |
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
cd $HOME/.rbenv/plugins/ruby-build | |
git pull | |
rbenv install 2.0.0-p0 | |
rbenv local 2.0.0-p0 | |
gem install bundler -v 1.3.0.pre.8 | |
cd /path/to/ruby/app | |
# Necessary if not already 600 | |
chmod 600 $HOME/.gem/credentials |
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
# Send an event to keen.io via a GET request | |
# Useful for placing image beacons in email | |
# (Traditional POST approach is still recommended where possible) | |
require 'json' | |
require 'base64' | |
# Get a project ID and API Key from keen.io | |
project_id = "your-project-id" | |
api_key = "your-api-key" |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.darkice</string> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>KeepAlive</key> | |
<false/> |
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
# Googling for how to implement a good Paperclip id_partition for mongoid, you might find - | |
# attachment.instance.id.to_s.scan(/.{4}/).join("/") | |
# There are problems with this. Because mongoid ID's are hex strings, a 4-character string can contain | |
# 4^16 or 65536 values. Usually with id partition we're trying to make sure no directory ever holds more | |
# than 32k files, so 64k is potentially dangerous. To be safe we need to drop to 3 characters or 4096 values. | |
Paperclip.interpolates :id_partition do |attachment, style| | |
attachment.instance.id.to_s.scan(/.{3}/).join("/") | |
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
#adapt to your ORM/ODM as needed | |
#put in outermost scope of a file require'd into an IRB session | |
def self.method_missing(method_name, *args, &block) | |
User.where(username: method_name).first || super | |
end | |
# usage | |
# $ rails c | |
# >> dzello.username |
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
" This assumes one space between the symbol and the hashrocket, adjust to your needs! | |
:%s/:\([a-z]*\) =>/\1:/gi<CR> |
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
horse = new Horse() | |
horse.read({ title: "The 7 Habits of Highly Successful Horses"}) | |
horse.ebooksRead() # 1 | |
horse.smarterThan(new Horse()) # true |