Skip to content

Instantly share code, notes, and snippets.

View geemus's full-sized avatar

Wesley Beary geemus

View GitHub Profile
module Base
module_function
BASE_CHARACTERS = '0123456789BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz'
def encode(int)
str = ''
while int > 0
character = int % BASE_CHARACTERS.length
int = int / BASE_CHARACTERS.length
str = BASE_CHARACTERS[character..character] + str
# Optimized regex for finding urls
# Top level domain list from: http://data.iana.org/TLD/tlds-alpha-by-domain.txt
/(?:^|\s)(?:http[s]?:\/\/)?(?:www\.)?([-a-zA-Z_\.]*\.(?:a(?:[cdfgilmnoqtuwxz]|e(?:ro)?|r(?:pa)?|s(?:ia)?)|b(?:[abdefghjmnorstvwyz]|i(?:z)?)|c(?:[cdfghiklmnruvxyz]|a(?:t)?|o(?:m|op)?)|d(?:[ejkmoz])|e(?:[cegrstu]|du)|f(?:[ijkmor])|g(?:[abdefghilmnpqrstuwy]|ov)|h(?:[kmnrtu])|i(?:[delmoqrst]|n(?:fo|t)?)|j(?:[emp]|o(?:bs)?)|k(?:[eghimnprwyz])|l(?:[abcikrstuvy])|m(?:[acdeghklmnpqrstvwxyz]|il|o(?:bi)?|u(?:seum)?)|n(?:[cfgilopruz]|a(?:me)?|e(?:t)?)|o(?:m|rg)|p(?:[aefghklmnstwy]|r(?:o)?)|q(?:a)|r(?:[eosuw])|s(?:[abcdeghijklmnortuvyz])|t(?:[cdfghjklmnoptvwz]|el|r(?:avel)?)|u(?:[agksyz])|v(?:[aceginu])|w(?:[fs])|xn--(?:0zwm56d|11b5bs3a9aj6g|80akhbyknj4f|9t4b11yi5a|deba0ad|g6w251d|hgbk6aj7f53bba|hlcj6aya9esc7a|jxalpdlp|kgbechtv|zckzah)|y(?:[etu])|z(?:[amw]))(?:[\/]?|(?:[\/]??[-a-zA-Z_\.\/?=&]*)))(?:[,\!\.\?])?(?:\s|$)/iu
@geemus
geemus / Gemfile
Created November 22, 2010 22:45
fog - resume uploading example
source "http://rubygems.org"
gem 'fog'
@geemus
geemus / 0_rackspace.rb
Created December 6, 2010 07:46
fog or: How I Learned to Stop Worrying and Love the Cloud (examples)
server_data = compute.create_server(
1,
49
).body['server']
until compute.get_server_details(
server_data['id']
).body['server']['status'] == 'ACTIVE'
end
@geemus
geemus / fog_virtualbox.rb
Created March 14, 2011 21:08
simple example of using virtualbox
require 'fog'
compute = Fog::Compute.new(:provider => 'VirtualBox')
server = compute.servers.create(:name => 'lucid', :os => 'Ubuntu')
medium = compute.mediums.create(:device_type => :hard_disk, :location => '/Users/geemus/geemus/virtualbox_poc/lucid.vmdk', :read_only => false)
storage_controller = server.storage_controllers.create(:bus => :sata, :name => 'sata')
storage_controller.attach(medium, 0)
@geemus
geemus / see also
Created August 16, 2011 15:10
vim installation
# on ubuntu, ensure appropriate ruby-dev is also installed
hg clone https://vim.googlecode.com/hg/ vim
cd vim
./configure --enable-multibyte --enable-rubyinterp
make && make install
@geemus
geemus / addendum.markdown
Created September 1, 2011 20:26
API - Assumptions Probably Incorrect
@geemus
geemus / gist:1248281
Created September 28, 2011 15:45
2012 Fukuoka Ruby Award Competition

Details on the competition: http://www.myfukuoka.com/events/2012-fukuoka-ruby-award-competition

Outline

Explain briefly functions and feature.

fog provides a consistent, simple interface to many cloud services. Whether utilizing computing, DNS, storage or other cloud resources, fog's simple interface helps new users get started quickly and easily, find the best provider for their needs, and migrate easily when those needs change. Because of it's open source license and the community built around it, fog also allows for quick extension of its interface when new cloud products and features are released.

@geemus
geemus / heroku.md
Created October 12, 2011 22:17
heroku style guide

TODO empty arrays and/or nil values (see apps:info)

General Guidelines

  • Use full sentences, including punctuation.
  • Labels should be provided where needed in the form of 'Labels labels:'.
  • Commands should have one newline between the header and body and another after the body.
  • Alpha-sort arrays before display and display labeled data in alpha-sorted key order.
@geemus
geemus / compact.md
Created April 3, 2012 13:20
markdownish styleguide
$ heroku help apps:create
## Usage:
   heroku apps:create [NAME]
## Description:
   create a new app
## Options:
   --addons ADDONS
      a comma-delimited list of addons to install
   -b, --buildpack BUILDPACK

a buildpack url to use for this app