Skip to content

Instantly share code, notes, and snippets.

View jbaudanza's full-sized avatar

Jonathan Baudanza jbaudanza

  • Hilokal.com
  • Seoul, South Korea
View GitHub Profile
@jbaudanza
jbaudanza / config.ru
Created February 8, 2011 21:55
Example of an asynchronous rack based app on heroku
# config.ru
#
# The Heroku architecture is based on Thin, which is based on EventMachine. This means
# you can access the EventMachine API and make use of Thin's asynchronous extension to
# the rack API.
#
# This is a simple asynchronous rack backed app that will hold a request for 4 seconds
# and respond with "Hello".
#
# In theory an app structured like this should be able to handle a huge number of
require File.join(File.dirname(__FILE__), "../spec_helper")
describe 'encode64url' do
describe "with plaintext that normally produces pluses and slashes" do
before do
@plaintext = "A string that will encode to something with a plus and a slash \xff \xfe"
Base64.encode64(@plaintext).should include('+')
Base64.encode64(@plaintext).should include('/')
end
@jbaudanza
jbaudanza / assert.coffee
Created May 14, 2011 21:12
jQuery plugin to do sanity checks on your selectors
# I live in constant fear of velociraptors, hipsters, and the risk that my jQuery
# selectors won't match the DOM at runtime.
#
# I've been using this pattern lately to assert that a jQuery object contains the
# elements that I expect. BeatLab.warn is a wrapper around the hoptoad notifier
# that sends me a warning message with a stacktrace.
#
# This is of course not a replacement for good unit tests, for which I highly
# recommend jasmine.
#
#!/bin/bash -ex
exec >> /var/log/user-data.log
# Download ubuntu packages
apt-get update
apt-get install -y ntp git-core ruby1.9.1-dev ruby1.9.1 libopenssl-ruby libxslt1-dev libxml2-dev build-essential nginx-extras postgresql mosh redis-server libpq-dev
gem install bundler foreman --ignore-dependencies --no-ri --no-rdoc
# Create app user
@jbaudanza
jbaudanza / scoot.rb
Last active December 11, 2015 18:49
This script polls the ScootNetworks API and sends a Twilio SMS when a scooter becomes available at a given garage. The script stops polling and exists after a scoot is found.
# This script polls the ScootNetworks API and sends a Twilio SMS when a scooter
# becomes available at a given garage. The script stops polling and exists
# after a scoot is found.
#
# 1. Install requirements:
#
# gem install twilio-ruby
#
# 2. Configure TWILIO_XXX vars below
#
require 'openssl'
md5 = OpenSSL::Digest::MD5.new
(1000000..9999999).each do |phone_number|
md5.reset
md5 << phone_number.to_s
md5.digest
end
@jbaudanza
jbaudanza / guildelines.md
Last active February 24, 2016 02:49
Beatlab moderator guidelines

Reasons to be banned:

  • Threating or harrassing other users
  • Posting explicit or inappropriate content
  • Flooding the chatroom with junk messages
  • Impersonating another individual (celebrity, another beatlaber, etc)
  • Using beatlab to solicit dates or girlfriends/boyfriends

Take note of how long the person has been on the site and how many tracks they’ve created. I tend to be more lenient with people that are contributors to the site than I am with passerby.

Usually we should give at least one warning before being muted. Of course an exception can be made for egregious offenses.