Skip to content

Instantly share code, notes, and snippets.

View clover-device-list.js
const configuration = {
domain: '',
merchantId: 'private',
oauthToken: 'private'
const devicesUrl = configuration.domain +
"v3/merchants/" + configuration.merchantId +
"/devices?access_token=" + configuration.oauthToken;
onPhotoSourceReq: (request, callback)->
photos = []
$.getJSON('/api/v1/moments/photos', (moments)->
if moments.length > 0
photos = _.flatten(, (m)->
return, (p)->
return p
t2 / ssh-git-push
Last active Jan 8, 2020
Github & Bitbucket (SSH) - Port 22 Blocked
View ssh-git-push
# vi ~/.ssh/config
Port 443
Port 443
t2 / sidekiq.config
Created Feb 11, 2015
Sidekiq on AWS ElasticBeanstalk (64bit Amazon Linux 2014.09 v1.1.0 running Ruby 2.1 (Puma))
View sidekiq.config
# Original:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
mode: '000644'
content: |
EB_CONFIG_APP_LOGS=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
t2 / birthday_liker.rb
Last active Sep 23, 2016
Like and Comment on every 'Happy Birthday' post on your Facebook feed at once.
View birthday_liker.rb
require 'date'
require 'koala'
class BirthdayLiker
FACEBOOK_TOKEN = 'your_oauth_key'
BIRTHDAY_WORDS = %w(birthday bday birfday birth born)
THANKS_OPTIONS = ['Thank you!', 'Thanks!', 'Appreciate it!']
def initialize(birthdate, opts={})
t2 / guild_metaprogramming_example.rb
Last active Dec 21, 2015
Simple example of using method missing to dynamically build out an object.
View guild_metaprogramming_example.rb
# Below I have a name class. It has no properties defined. I want to be able to dynamically
# build it into what I want. This allows me to not have to write code for every scenario, I can
# let the developer decide what it should include.
class Name
ALLOWED_NAME_PARTS = %w(prefix first middle last suffix)
def initialize(&block)
self.instance_eval(&block) if block_given?
t2 / beta_invite_rake_task.rb
Created Aug 21, 2013
Beta Invite Rake Task
View beta_invite_rake_task.rb
namespace :beta_invites do
namespace :phase_one do
desc 'Send Phase 1 Beta Invites to testers.'
task :all => :environment do
BetaInvite.all.uniq{|b|}.each do |invite|
email_message = BetaInviteMail.invitation(
t2 / application.html.haml
Created Jun 1, 2013
Possible refactor using a decorator for application layout.
View application.html.haml
%title= title
= stylesheet_link_tag 'application', :media => 'all'
= stylesheet_link_tag '//'
= stylesheet_link_tag '//'
= javascript_include_tag 'application'
/[if lte IE 8]
<script src="excanvas.compiled.js"></script>
t2 / Grabber.rb
Last active Dec 16, 2015
Script to pull down images from a resource I found on Reddit
View Grabber.rb
# You will need to install nokogiri and rubyzip gems
# gem install nokogiri
# gem install rubyzip
require 'nokogiri'
require 'open-uri'
require 'zip/zip'
t2 / application.rb
Created Dec 12, 2011
Formatting Rails form elements for Twitter Bootstrap error validation
View application.rb
ActionView::Base.field_error_proc = do |html_tag, instance|
html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe
# add nokogiri gem to Gemfile
elements = Nokogiri::HTML::DocumentFragment.parse(html_tag).css "label, input"
elements.each do |e|
if e.node_name.eql? 'label'
html = %(<div class="clearfix error">#{e}</div>).html_safe
elsif e.node_name.eql? 'input'
if instance.error_message.kind_of?(Array)
html = %(<div class="clearfix error">#{html_tag}<span class="help-inline">&nbsp;#{instance.error_message.join(',')}</span></div>).html_safe