Skip to content

Instantly share code, notes, and snippets.

View simonrentzke's full-sized avatar

Simon Rentzke simonrentzke

View GitHub Profile

Keybase proof

I hereby claim:

  • I am simonrentzke on github.
  • I am sren (https://keybase.io/sren) on keybase.
  • I have a public key whose fingerprint is 7275 37F3 470D 5AA2 821A 8423 86F0 8926 4E26 07DB

To claim this, I am signing this object:

Badge.all.each {|l| l.update_attributes(image: Dragonfly.app.fetch_url("http://placekitten.com/800/#{800+rand(100)}")) }
Level.all.each {|l| l.update_attributes(image: Dragonfly.app.fetch_url("https://robohash.org/#{rand(100)}?set=3")) }
@simonrentzke
simonrentzke / pr.rb
Last active November 18, 2015 21:24
#!/usr/bin/env ruby
# Dependencies
# - brew install hub
# - brew install ghi
# - ghi config --auth <gh username>
if ARGV.size != 1
puts "USAGE: ./pr.rb <issue number>"
@simonrentzke
simonrentzke / setup_edge_rails.sh
Last active August 31, 2015 00:16
Setup an Edge Rails 5 application from Scratch
mkdir rails-5-test-app
cd rails-5-test-app
touch .ruby-version
echo 'ruby-2.2.2' > .ruby-version
touch Gemfile
printf "source 'https://rubygems.org'\nruby '2.2.2'\n\n\ngem 'rails', github: 'rails/rails'\ngem 'arel', github: 'rails/arel'\ngem 'rack', github: 'rack/rack'" >> Gemfile
bundle
bundle exec rails new . --dev --force
bundle exec rails s
@simonrentzke
simonrentzke / gist:5856414
Last active September 30, 2023 03:18
Array of array subtraction
function remove_selected_from_options(arr1, arr2) {
var filtered_options = [];
for (var i=0; i < arr1.length; i++) {
var included = false;
for (var z=0; z < arr2.length; z++) {
if (arr2[z][0] == arr1[i][0]) {
included = true;
break;
}
}
@simonrentzke
simonrentzke / test.haml
Created May 7, 2013 00:20
haml template
!!! 5
%html
%head
%title= "Your Website"
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%meta{ :content => "3 days", :name => "revisit-after" }
%link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
%body
@simonrentzke
simonrentzke / mergeable models
Created October 18, 2012 10:47
Merging one record into another - take care of all associated data.
module Mergeable
def merge_associated_records_and_destroy(throwaway_object, special_cases = {})
#look for any fields that match field name
field_name_to_update = "#{self.class.to_s.downcase}_id"
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each { |file| require(file)}
message = []
models = ActiveRecord::Base.subclasses.collect
begin
models.each do |m|
if m.columns_hash["#{self.class.to_s.downcase}_id"]
@simonrentzke
simonrentzke / gist:1842486
Created February 16, 2012 06:00
Forcing Card Type with ActiveMerchant Testing
Factory.define :user_credit_card do |cc|
cc.card_type "bogus"
cc.card_number 1
cc.verification_value "123"
cc.expiration_date Time.now + 1.year
end
@simonrentzke
simonrentzke / gist:1030872
Created June 17, 2011 04:29
Cruise Control automated Heroku script.
if CruiseControl::invoke_rake_task 'spec'
puts "Pushing on heroku... [Start]"
`git push heroku master`
puts "Pushed on heroku. [Done]"
puts "Running migrations... [Start]"
`heroku rake db:migrate`
puts "Migrated... [Done]"
puts "Prepare test db... [Start]"
`heroku rake db:test:prepare`
puts "Test database ready [Done]"
To remove vendor and public directories in textmate project (if it is loading too slow).
Click [i] in the tray, and edit the root folder pattern to this:
!.*/(\.[^/]*|public|vendor|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$