Skip to content

Instantly share code, notes, and snippets.

View kennym's full-sized avatar

Kenny Meyer kennym

View GitHub Profile
<component name="libraryTable">
<library name="libs">
<CLASSES>
<root url="jar://$PROJECT_DIR$/libs/android-support-v4.jar!/" />
<root url="jar://$PROJECT_DIR$/libs/androidannotations-api-2.7.1.jar!/" />
<root url="jar://$PROJECT_DIR$/libs/acra-4.5.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/libs/google-play-services_lib/gen" />
---
http_interactions:
- request:
method: get
uri: https://api.twitter.com/1.1/account/verify_credentials.json
body:
encoding: US-ASCII
string: ""
headers:
Accept:
@kennym
kennym / rails_templates.rb
Last active December 20, 2015 14:39
Add FactoryGirl
gem "figaro"
gem_group :development do
gem "guard"
gem "guard-rspec"
gem "guard-livereload"
end
gem_group :test do
gem "shoulda-matchers"
module Magic
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def method_added(name)
puts "instance method '#{name}' added"
end
def singleton_method_added(name)
@kennym
kennym / scraper.rb
Created May 2, 2013 19:26
Craigslist scraper
require 'airbrake'
require 'debugger'
module Craigslist
module Scraper
MAX_DEPTH = (Rails.env.development? or Rails.env.test?) ? 1 : 5
def self.scrape_category(category)
agent = Mechanize.new { |settings|
settings.user_agent_alias = "Linux Firefox"
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})"
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)
@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
@kennym
kennym / file1.m
Created November 16, 2012 02:01
example 2
pod 'SSPullToRefresh', {:git => '[email protected]:kennym/sspulltorefresh.git'}
@kennym
kennym / file1.m
Created November 16, 2012 02:00
example
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
dispatch_release(_animationSemaphore);
#endif