Skip to content

Instantly share code, notes, and snippets.

View aergonaut's full-sized avatar

Chris Fung aergonaut

View GitHub Profile

Pokebin

  • like Pastebin but for Pokemon teams
  • anyone can access the site and create an annonymous team
    • teams get urls like: http://pokebin.io/963fc4d
    • annonymous teams persist for 1 month and then are marked for deletion
      • teams marked for deletion are deleted when they are not visited for 2 consecutive days
    • spam filters and rate limiting to curb abuse
  • users can optionally sign up to have their teams persist forever
  • JSON api: http://pokebin.io/963fc4d.json
require 'bundler/inline'
gemfile(true) do
source "http://rubygems.org"
gem "activerecord", "~> 4.2"
gem "sqlite3"
end
require "active_record"
class Circle
def initialize(radius:)
@radius = radius
end
def area
Math::PI * (@radius ** 2)
end
end
class OnlineMigration
class << self
def online(&block)
# OnlineVerifier runs the syntax inside the block. It only has methods
# defined that we agree are safe for online migrations. If you use an
# unsafe method inside the online {} block, the class won't load.
verifier = OnlineVerifier.new
verifier.instance_eval(&block)
define_method(:change, &block)
end
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development: &dev
adapter: mysql2
encoding: utf8
@aergonaut
aergonaut / README.md
Last active December 31, 2015 17:18
data_table

DataTable

Installation

Add it to your Gemfile:

gem 'data_table', :github => "coupa/data_table"
@aergonaut
aergonaut / the_truth.rb
Created December 17, 2013 19:08
"You want the truth?" "YOU CAN'T HANDLE THE TRUTH!"
describe "you" do
subject(:you) { FactoryGirl.create :you }
it "wants the truth" do
expect(you).to want_the_truth
end
it "can't handle the truth" do
expect(you.can_handle?(:truth)).not_to be_true
end
@aergonaut
aergonaut / README.md
Last active December 30, 2015 18:29
persephone

Persephone

Persephone provides a HTTP-based, RESTful web API wrapper around Capistrano tasks. The intent is to allow Capistrano tasks to be executed via web interfaces, chat bots, native applications, etc. without having to manually SSH in to a server and issue commands.

Installation

Persephone is a simple Sinatra app that is distributed as a gem.

Add the gem to your Gemfile:

@aergonaut
aergonaut / sql.rake
Last active December 26, 2015 09:39
namespace :db do
namespace :sql do
desc "Load database from SQL dump"
task :load => [:environment, :reset] do
ARGV.shift
file = ARGV.shift
name_and_extensions = file.split(".")
name = name_and_extensions.shift
extensions = name_and_extensions
# use tap to modify an object and then return it immediately
# before...
def foo
obj = Foo.new
obj.attribute = :value
obj
end
# after...
def foo