Skip to content

Instantly share code, notes, and snippets.

# http://www.6blog.us/2013/02/is-polymorphism-faster-in-ruby/
#
# Testing the speed of polymorphism in Ruby. This program is based on the Wikipedia article:
# http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming
#
# To run: ruby main.rb <number of runs to time (optional)>
# Example: ruby main.rb 5
class Animal
def initialize(name)
@smholloway
smholloway / generate-alias-for-jekyll-post
Created January 31, 2014 05:07
Generate alias entries for Jekyll posts. This is
# Seth Holloway - https://github.com/smholloway
#
# The Jekyll Alias Generator, https://github.com/tsmango/jekyll_alias_generator,
# is a handy way to create meta refresh redirects from an old URL pattern to the
# new. This is helpful when changing blog formats as it helps maintain search
# engine rankings. Unfortunately, you have to create your own alias entries.
# With over 400 posts, I had # to automate it! This script will find all
# Markdown files in your _posts directory then generate an alias entry under the
# title attribute.
#
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9dyHjrrdDHBMNIUe+4HFDcVvR3FYLPCNjXmEDjGb28P4lQgRVKj5x29ao3BonE9PkPLz7KxULDIMQI7yg263SlbP1lXIuXsbHu+nEd9QZBlOwPTffWZHz547DqnOinFmxfZ/TJZhGNGqEd8DPm8uLP95Udn4XtEnrWRw/jxCdzROUA9JxqSNNyXp8OYH0L36tlHzWqHMLXh5H1dlcDsXQsO6xFA2sN0VQDHEo06z3YeOR8YmjLW3KK7D9ZkVis7+KcvfNAIJEq+QFLyCoUnyMuTOZ1tvDcAu23+Y7pUrqakUWlIYUlXNUmYI8A78SGQpBVKoIeFsStDwutDB+QXM3

Keybase proof

I hereby claim:

  • I am smholloway on github.
  • I am sethholloway (https://keybase.io/sethholloway) on keybase.
  • I have a public key whose fingerprint is 3613 037C 0F80 E273 62F9 4E31 856E 6BAB B0CB A24D

To claim this, I am signing this object:

@smholloway
smholloway / check_for_yaml_vulnerability
Created April 17, 2014 18:03
Psych YAML vulnerability on Heroku
# Built from https://gist.github.com/markpundsack/4506402
`heroku list`.split("\n").each do |app|
app = app.strip
# Some "heroku apps" lines have === formatting for grouping. They're not apps.
next if app[0..2] == "==="
# Some are appended by owner emails
app = app.split(" ")[0].to_s.strip
{
"authenticator": {
"consumer": {
"key": "key"
},
"created": "2015-01-01 10:10:10",
"id": "12345678-1234-4123-8123-123456789abc",
"modified": "2015-01-01 10:10:10",
"name": "authenticator"
},
{
"authenticator": {
"consumer": {
"key": "key"
},
"created": "2015-01-01 10:10:10",
"id": "12345678-1234-4123-8123-123456789abc",
"modified": "2015-01-01 10:10:10",
"name": "authenticator"
},
import toopher
# Create an API object using your credentials
api = toopher.ToopherApi("<your consumer key>", "<your consumer secret>")
# Step 1 - Pair with their phone's Toopher app
pairing_status = api.pair("pairing phrase", "[email protected]")
import toopher
# Create an API object using your credentials
api = toopher.ToopherApi("<your consumer="" key="">", "<your consumer="" secret="">")
# Authenticate a log in
auth = api.authenticate(pairing_status.id, "my computer")
# Once they've responded you can then check the status
auth_status = api.get_authentication_status(auth.id)
import com.toopher.*;
// Create an API object using your credentials
ToopherApi api = new ToopherApi("<your consumer key>", "<your consumer secret>");
// Step 2 - Authenticate a log in
AuthenticationStatus auth = api.authenticate(pairing.id, "my computer");
// Once they've responded you can then check the status
AuthenticationStatus status = api.getAuthenticationStatus(auth.id);