Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Westin eimermusic

View GitHub Profile
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
@eimermusic
eimermusic / mongoid_test.rb
Created Feb 16, 2012
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
@eimermusic
eimermusic / gist:3744939
Created Sep 18, 2012
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
eimermusic / domain.rake
Created Jun 9, 2014
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 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?