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
| # An example of using ngram analysis in ElasticSearch with the Tire rubygem | |
| # ========================================================================== | |
| # The original, raw example: https://gist.github.com/988923 | |
| require 'rubygems' | |
| require 'tire' | |
| require 'yajl/json_gem' | |
| class URL | |
| def initialize(attributes={}) |
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
| # put this file in lib/ and include it from an initializer | |
| module HstoreAccessor | |
| def self.included(base) | |
| base.extend(ClassMethods) | |
| end | |
| module ClassMethods | |
| def hstore_accessor(hstore_attribute, *keys) | |
| serialize hstore_attribute, ActiveRecord::Coders::Hstore |
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 coffee | |
| # Call the program with: coffee phantom.coffee http://url.to/screengrab | |
| phantom = require 'phantom' # npm install phantom | |
| child_process = require 'child_process' | |
| url = process.argv[2] | |
| createScreenshot = (page, filename) -> |
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
| if Rails.env.production? | |
| Braintree::Configuration.environment = Rails.env.staging? ? :sandbox : :production | |
| Braintree::Configuration.merchant_id = ENV["braintree_merchant_id"] | |
| Braintree::Configuration.public_key = ENV["braintree_public_key"] | |
| Braintree::Configuration.private_key = ENV["braintree_private_key"] | |
| else | |
| Braintree::Configuration.environment = :sandbox | |
| Braintree::Configuration.merchant_id = "<super secret>" | |
| Braintree::Configuration.public_key = "<super secret>" | |
| Braintree::Configuration.private_key = "<super secret>" |
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 Filter | |
| include FormObject | |
| # Proc because Date.yesterday changes every day :) | |
| attribute :from, Date, default: Proc.new { Date.yesterday } | |
| attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day } | |
| end | |
| # in controller | |
| @filter = Filter.new(params[:filter]) |
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
| <html> | |
| <head> | |
| <script type="text/javascript" charset="utf-8"> | |
| var FB = function(){ | |
| //defaults and accessors | |
| var initialized = false, | |
| loggedIn = null, | |
| shouldSucceed = true, | |
| uid = '12345'; |
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
| body { -webkit-transform: rotate(10deg); } | |
| body { -webkit-animation: blur 30s infinite; } | |
| img { -webkit-transform: rotate(180deg); } | |
| body, p, body p, body div p { font-family: 'Comic Sans MS', cursive !important; } | |
| p:before { content: "YOLO "; } | |
| p:nth-child(2) { display:none !important; } | |
| #-webkit-web-inspector { -webkit-transform:rotate(180deg); } | |
| #-webkit-web-inspector .toolbar-item.close-left { display:none !important; } | |
| html { -webkit-animation: rainbow 8s infinite; } | |
| @-webkit-keyframes blur { |
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
| // http://www.w3.org/TR/dom/ | |
| // http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers | |
| // https://developer.mozilla.org/en-US/docs/DOM/MutationObserver | |
| var MutationObserver = (function () { | |
| var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''] | |
| for(var i=0; i < prefixes.length; i++) { | |
| if(prefixes[i] + 'MutationObserver' in window) { | |
| return window[prefixes[i] + 'MutationObserver']; | |
| } | |
| } |
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
| (function(uustats){ | |
| uustats.sdev = function(series) { | |
| return Math.sqrt(uustats.variance(series)); | |
| }; | |
| uustats.variance = function(series) { | |
| var t = 0, squares = 0, len = series.length; | |
| for (var i=0; i<len; i++) { |