Skip to content

Instantly share code, notes, and snippets.

Avatar
🙅‍♀️
permanent omnishambles

Robin Howard damncabbage

🙅‍♀️
permanent omnishambles
View GitHub Profile
View belongs_to_lambda.md

An ActiveRecord conundrum

I'm going to describe a weird problem I faced when using ActiveRecord today. To protect the innocent, I'm not going to talk about the app I'm actually working on but will instead discuss a hypothetical but isomorphic database design for a clone of the popular blogging platform Tumblr.

Tumblr lets you publish various different sorts of content. We might be tempted to shove all these types in a big STI table, but the types are all quite different from one another and so we give them their own tables.

View job_2014_07.md

Hi!

We're looking for a junior to mid level Javascript and/or Ruby developer to join our team at The Exchange Group.

The Exchange Group is best known for online bike marketplace, bikeexchange.com.au, which in the last couple of years has expanded to New Zealand and Germany. We've also added tinitrader.com.au, renoexchange.com.au and furnitureexchange.com.au to the mix.

The application is primarily Ruby on Rails 3.2, which we're planning on upgrading to 4.0 in the near future. We've brought in AngularJS to several sections of the site already: our new search is entirely Angular. As our application grows, we'll be reducing our reliance on a monolithic Rails application and splitting things into UI & API implementations; this is where you'll come in.

The successful applicant will:

View rubocop.rb
#!/usr/bin/env ruby
changed = `git diff --numstat origin/master | awk '{ print $3 }' | grep -E '(\\.rb|\\.rake)$' | grep -v db/schema`
changed = changed.split("\n").select { |c| File.exist?(c) }
if changed.length > 0
system "bundle exec rubocop #{ARGV.join(' ')} #{changed.join(' ')}"
else
puts "No changes."
@mmb
mmb / pixelize.rb
Created Jan 11, 2011
convert image into retro 8-bit looking image
View pixelize.rb
require 'RMagick'
# convert image intro retro 8-bit looking image
# http://matthewm.boedicker.org/
# find NES, SNES, etc. palette image on the web
palette = Magick::ImageList.new('/tmp/Palette_NTSC.png')
img = Magick::ImageList.new('/tmp/input.jpg')
View example.rb
uri 'contacts', name: 'contacts' do
get 'contacts#index'
end
uri 'contacts/:id/addresses', name: 'contact_addresses' do
put 'contact_addresses#replace'
post 'contact_addresses#create'
delete 'contact_addresses#delete'
end
@benhoskings
benhoskings / application_controller.rb
Created Sep 1, 2011
A git ref in every response!
View application_controller.rb
class ApplicationController < ActionController::Base
before_filter {
headers['X-Refspec'] = TC::Services.refspec
}
end
@rondale-sc
rondale-sc / ruby-hough.rb
Created Sep 21, 2011
The hough transform in ruby. Only looks for straight black lines.
View ruby-hough.rb
begin
['oily_png', 'pp'].each do |g|
require g
end
rescue LoadError => e
puts "Could not load '#{e}'"; exit
end
class Hough
Convert = "/usr/local/bin/convert"
@mipearson
mipearson / GIVING_A_TALK.md
Created Dec 14, 2011
Prerequisites For Giving a Presentation at a User's Group
View GIVING_A_TALK.md

Prerequisites For Giving a Presentation at a User's Group

You've decided to get up in front of a bunch of strangers and talk about a topic for thirty to fifty minutes. You're going to convey your unique, personal experience and everybody is going to afterwards feel as if they've learned something new.

For most talks at user groups, this doesn't happen, and it's easily fixable.

You absolutely, no questions asked, need to:

  • Know what you're presenting: rehearse it to yourself, once, out loud. If that's too awkward for you it's going to be more awkward when you're back-pedalling and skipping sections in front of thirty to fifty of your peers. If you have demonstration content, test it from beginning to end, especially the bits that you assume will 'just work'.
@amouat
amouat / .conkyrc
Created Jan 6, 2012
Conky config for TODO system
View .conkyrc
#.conkyrc for TODOs
#
# Slightly modified version of basic config
#
# Adrian Mouat 2012
#
alignment top_right
background yes
border_width 1
default_color white
@jonathanclarke
jonathanclarke / Avoiding precompile if no assets change when synching to S3
Created Feb 13, 2012
Avoiding precompile if no assets change when synching to S3
View Avoiding precompile if no assets change when synching to S3
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end