Skip to content

Instantly share code, notes, and snippets.

View eimermusic's full-sized avatar

Martin Westin eimermusic

View GitHub Profile
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
@eimermusic
eimermusic / mongoid_test.rb
Created February 16, 2012 21:58
Mongoid example generating possibly excessive db queries
# Monogid Models
class Employee
include Mongoid::Document
include Mongoid::Timestamps
field :ssid, type: String
field :name, type: String
index :name
@eimermusic
eimermusic / gist:3744939
Created September 18, 2012 18:38
Tiny simple sort-action for Ember.js ArrayController content
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
eimermusic / domain.rake
Created June 9, 2014 08:22
Multi-tenant switching rake task
# runs other rake tasks with domain scoping applied.
# Like so:
# bundle exec rake domain:one TASK=namespace:task DOMAIN=customer1.example.com
# 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 Exception.new, "You must provide ENV['TASK'] and ENV['DOMAIN']" if ENV['TASK'].nil? || ENV['DOMAIN'].nil?