Skip to content

Instantly share code, notes, and snippets.

View kennym's full-sized avatar

Kenny Meyer kennym

View GitHub Profile
@kennym
kennym / database.yml
Created April 18, 2012 14:19
AW-ETL configuration
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
/* Some CSS here */
<% unless Rails.env.test? %>
@import "font-awesome";
<% end %>
/* More CSS here */
module ApplicationHelper
def git_version
require 'grit'
repo = Grit::Repo.new(Rails.root + '.git')
# For the sake of brevity just display the first 6 chars of the commit id
last_commit = repo.commits.first.id[0..5]
#{last_commit}
end
end
@kennym
kennym / file1.erb
Created September 8, 2012 21:16
application.html.erb
<footer class="clearfix">
<p>Created by <a href="mailto:kenny@kennymeyer.net">Kenny Meyer</a>
<% cache do %>
(HEAD: <%= git_version %>)
<% end %>
</p>
</footer>
@kennym
kennym / file1.sh
Created September 8, 2012 21:26
git rev-parse HEAD
git rev-parse HEAD
@kennym
kennym / file1.m
Created November 16, 2012 02:00
example
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
dispatch_release(_animationSemaphore);
#endif
@kennym
kennym / file1.m
Created November 16, 2012 02:01
example 2
pod 'SSPullToRefresh', {:git => 'git@github.com:kennym/sspulltorefresh.git'}
@kennym
kennym / convert.rb
Created January 18, 2013 01:33
Convert Ruboto wiki entries to Jekyll entries
#!/usr/bin/env ruby
#
# Convert old jekyll release announcements to jekyll.
#
# Copies newly generated entries to `build/`
#
# 1. git clone git://github.com/ruboto/ruboto.wiki.git
# 2. cd ruboto.wiki
# 3. Run this script
class VideoValiadtor < ActiveRecord::Validator
def validate(record)
# This regex will match YouTube and Vimeo videos
regex = /^http:\/\/(?:.*?)\.?(youtube|vimeo)\.com\/watch\?[^#]*v=(\w+)|(\d+)/
# Use it as follows:
#
# "http://www.youtube.com/watch?v=AZDAIgwbXk4".match(regex)
# >> #<MatchData "http://www.youtube.com/watch?v=AZDAIgwbXk4" 1:"youtube" 2:"AZDAIgwbXk4" 3:nil>
#
# "http://vimeo.com/60555406".match(regex)
class EmailValidator < ActiveModel::Validator
EMAIL_ADDRESS_QTEXT = Regexp.new '[^\\x0d\\x22\\x5c\\x80-\\xff]', nil, 'n'
EMAIL_ADDRESS_DTEXT = Regexp.new '[^\\x0d\\x5b-\\x5d\\x80-\\xff]', nil, 'n'
EMAIL_ADDRESS_ATOM = Regexp.new '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+', nil, 'n'
EMAIL_ADDRESS_QUOTED_PAIR = Regexp.new '\\x5c[\\x00-\\x7f]', nil, 'n'
EMAIL_ADDRESS_DOMAIN_LITERAL = Regexp.new "\\x5b(?:#{EMAIL_ADDRESS_DTEXT}|#{EMAIL_ADDRESS_QUOTED_PAIR})*\\x5d", nil, 'n'
EMAIL_ADDRESS_QUOTED_STRING = Regexp.new "\\x22(?:#{EMAIL_ADDRESS_QTEXT}|#{EMAIL_ADDRESS_QUOTED_PAIR})*\\x22", nil, 'n'
EMAIL_ADDRESS_DOMAIN_REF = EMAIL_ADDRESS_ATOM
EMAIL_ADDRESS_SUB_DOMAIN = "(?:#{EMAIL_ADDRESS_DOMAIN_REF}|#{EMAIL_ADDRESS_DOMAIN_LITERAL})"
EMAIL_ADDRESS_WORD = "(?:#{EMAIL_ADDRESS_ATOM}|#{EMAIL_ADDRESS_QUOTED_STRING})"