Skip to content

Instantly share code, notes, and snippets.

View eimermusic's full-sized avatar

Martin Westin eimermusic

View GitHub Profile
eimermusic / domain.rake
Created June 9, 2014 08:22
Multi-tenant switching rake task
View domain.rake
# runs other rake tasks with domain scoping applied.
# Like so:
# bundle exec rake domain:one TASK=namespace:task
# bundle exec rake domain:all TASK=namespace:task
namespace :domain do
desc 'Run a rake task ENV[TASK] on a single domain ENV[DOMAIN]'
task :one => :environment do
raise, "You must provide ENV['TASK'] and ENV['DOMAIN']" if ENV['TASK'].nil? || ENV['DOMAIN'].nil?
eimermusic / gist:3744939
Created September 18, 2012 18:38
Tiny simple sort-action for Ember.js ArrayController content
View gist:3744939
App.UsersController = Ember.ArrayController.extend({
sortProperties: ['name'],
sortAscending: true,
reSort: function(sortBtnValue) {
var sortProperty = this.get('sortProperties')[0];
if (sortProperty == sortBtnValue) {
if (this.get('sortAscending')) {
this.set('sortAscending', false);
} else {
eimermusic / mongoid_test.rb
Created February 16, 2012 21:58
Mongoid example generating possibly excessive db queries
View mongoid_test.rb
# Monogid Models
class Employee
include Mongoid::Document
include Mongoid::Timestamps
field :ssid, type: String
field :name, type: String
index :name
View savon_mime_support_patch_example.rb
require 'rubygems'
require 'mail'
require 'savon'
# I needed to send "SOAP with Attachments" and found soap4r too horrible.
# Since I saw no support for it in Savon I tried to hack something together
# to see if it could be done. I share that messy code here
# this is updated for Savon 0.8.1