Skip to content

Instantly share code, notes, and snippets.

View rapind's full-sized avatar

Dave Rapin rapind

View GitHub Profile
@rapind
rapind / left.rb
Created June 14, 2011 16:47
Mongoid HABTM Issue
class Left
include Mongoid::Document
field :title, :type => String
has_and_belongs_to_many :rights
end
@rapind
rapind / coupons
Created September 27, 2011 19:55 — forked from resistorsoftware/coupons
Load Groupon Codes into Shopify Discounts
# http://forums.shopify.com/categories/6/posts/42926
# This is a fairly simple mechanize script to create a few hundred or so shopify discounts from a CSV of groupon codes.
# You'll want to change all of the "changeme" values to your own.
# The script expects there to be a groupon_codes.csv in the same directory.
#
# The groupons_code.csv should look like this:
# 8m7677
# 8m6749
# 8m5398
# 8m7699
@rapind
rapind / sqs_receive.rb
Created November 3, 2011 12:40
SQS Send and Receive Test
require 'fog'
require 'yaml'
Message = Struct.new(:idx, :body, :sent_at)
@lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
# You need to create an amazon aws account to setup an SQS queue and get the access and secret key.
QUEUE_URL = 'https://queue.amazonaws.com/446249531791/test_queue'
ACCESS_KEY = 'change_me'
@rapind
rapind / hack.sh
Created April 11, 2012 14:43 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2359777/hack.sh | sh
#
@rapind
rapind / additional_install_notes
Created July 11, 2012 02:31
brew install homebrew/dupes/vim
warning: vim.googlecode.com certificate with fingerprint 65:a0:a7:8d:8f:48:eb:13:5c:81:3c:47:2d:6b:73:c4:7e:ea:61:5f not verified (check hostfingerprints or web.cacerts config setting)
clang: warning: argument unused during compilation: '-no-cpp-precomp'
clang: warning: argument unused during compilation: '-no-cpp-precomp'
Undefined symbols for architecture x86_64:
"_ruby_errinfo", referenced from:
_error_print in if_ruby.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [vim] Error 1
make: *** [first] Error 2
@rapind
rapind / example.rb
Created August 11, 2012 17:42
NSCodable Module for RubyMotion serializable / NSCode -able classes
# This is an example of using the NSCodable module.
class Post
include NSCodable
attr_accessor :id, :message
end
# Create a new post.
post = Post.new(:id => 4, :message => 'Some random message')
# List of environments and their heroku git remotes
ENVIRONMENTS = {
:staging => 'myapp-staging',
:production => 'myapp-production'
}
namespace :deploy do
ENVIRONMENTS.keys.each do |env|
desc "Deploy to #{env}"
task env do
@rapind
rapind / spirals_on_a_plane.rb
Last active December 22, 2015 11:59
Recursion is so 2012.
# The only true solution to the "Turn this array into a snake" test.
class Array
def motherfucking_spiral
[ 1, 2, 3, 4,
12, 13, 14, 5,
11, 16, 15, 6,
10, 9, 8, 7 ]
end
end
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2EG5UiCIn4e/iECf3K5IwJsXwtSz0qZ1fXXlvUVvF4hHfsWOeX4vXqtX4jLiu1h1Zpyqa0bJeXtkQDF3U/aT+Ez/Y6qBBo5ONdkAsNHWdmYvfkcQ+HBCd3HSd3nGjR1xTShZbEWakCt/yO+tSw7HWgIgQYVPJ+kHvfkBvw10Z7aLc3+WM0Hg8BmQIl6YKLKzhEQjdq1x81Q6OKMO5Vqmb61eE8TSr+ISEqzUjg9gAkT3qyF0CegXw0b3/wIpvhtCpYh9QpWi87JqMfWqNvARH4ciIcj+T/6HeB+aOVhtYv5Q+X84GcyNBErbYqFfzbomAgeqzv2Ag+kIUfNrJSfwF rapind@rapindesk
@rapind
rapind / test.html
Last active August 29, 2015 14:08
Tell the parent frame your size after loading.
<script>
window.onload = function() {
parent.postMessage('height:' + document.body.scrollHeight, "*");
};
</script>