Skip to content

Instantly share code, notes, and snippets.

View tekwiz's full-sized avatar

Travis D. Warlick, Jr. tekwiz

View GitHub Profile
@tekwiz
tekwiz / S3Snippets.rb
Created September 2, 2009 16:25
Ruby Snippets for S3
require 'rubygems'
require 'aws/s3'
require 'activesupport'
S3_KEY_ID = ''
S3_ACCESS_KEY = ''
BUCKET = ''
# Connect
AWS::S3::Base.establish_connection!(
@tekwiz
tekwiz / CloudFilesSnippets.rb
Created September 2, 2009 16:29
Ruby Snippets for CloudFiles
require 'rubygems'
require 'cloudfiles'
require 'activesupport'
CF_USERNAME = ''
CF_API_KEY = ''
CONTAINER = ''
# Connect
cf = CloudFiles::Connection.new(CF_USERNAME, CF_API_KEY)
@tekwiz
tekwiz / mate-gem
Created April 25, 2010 18:00
Opens a gem and its direct dependencies in text mate
#!/usr/bin/env ruby
# Opens the source code for a gem and the gem's direct dependencies in textmate.
#
# When this is mature it will be added to [Dionysus](http://github.com/tekwiz/dionysus).
#
# TODO add banner and better docs to option parser
# TODO add --quiet flag to suppress dependency not found warnings
# TODO add recursive dependencies (e.g. failure: `mate-gem rails 3.0.0.beta3` does not load activemodel
# since that is a dependency of activerecord)
state_machine User do
state :new
state :normal
state :locked
end
state_machine Membership do
state :new
state :active
state :inactive
@tekwiz
tekwiz / 1 Overview.md
Created May 24, 2011 17:40
Gemfile.lock Platform Conflicts

Problem: Gemfile.lock was generated on Windows machine (mingw), but on the OS X machine, the mingw gems are removed from the lockfile (and the platform "unknown" is added).

Bundler Version: All developers on are on bundler 1.0.13
Ruby Version: 1.8.7-p174 (OS X) and 1.8.7-p330 (Windows)
RVM Version: 1.2.4 (OS X), no RVM on Windows
Bundle Config: no settings

@tekwiz
tekwiz / bundler_git_path_fix.rb
Created May 27, 2011 20:25
Fix Bundler with git repo gems in the system path
module Bundler
module Source
class Git < Path
def path
@install_path ||= begin
if Bundler.requires_sudo?
Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope)
else
Bundler.install_path.join(git_scope)
end
class Semaphore
def initialize(limit)
@main, @internal = Mutex.new, Mutex.new
@mutexes = limit.times.collect { Mutex.new }
end
def synchronize
# create the mutex variable for scope
# grab the current thread for sleeping if necessary later
mutex, thread = nil, Thread.current
@tekwiz
tekwiz / circuit_formats.rb
Created October 2, 2012 17:01
Circuit Formats
module Circuit
FORMAT_EXT_REGEXP = /\.([^\.]+)$/
module Validators
silence_warnings do
SLUG_REGEXP = /\A(?:[-_!~*'()a-zA-Z\d:@&=+$,]|%[a-fA-F\d]{2})*(?:;(?:[-_!~*'()a-zA-Z\d:@&=+$,]|%[a-fA-F\d]{2})*)*\Z/
end
class SlugValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
@tekwiz
tekwiz / README.md
Last active December 10, 2015 21:18
Fixer for iWeb problems

IWFixer

The iwfixer.js file contents should be appended at the very bottom of the iWebSite.js script in the iWeb application. This will then become minified with the iWebSite.js file when any iWeb site is published.

Compatibility

This is only known to work with iWeb 3.0; however, only the

@tekwiz
tekwiz / 0-AWS_S3_Snippets.md
Last active December 11, 2015 00:18
S3 Website Bucket Policy