Skip to content

Instantly share code, notes, and snippets.

Benedikt Deicke benedikt

Block or report user

Report or block benedikt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:867418
var Sample = function() {
var iamHidden = "you can't see me!";
this.lookInside = function() {
return iamHidden;
describe("Sample", function() {
it("should be equal", function() {
benedikt / rails.rb
Created Jul 30, 2011
Capistrano task to open a rails console on a remote server. Require this file in your deploy.rb and run "cap rails:console"
View rails.rb
# encoding: UTF-8
Capistrano::Configuration.instance(:must_exist).load do
namespace :rails do
desc "Open the rails console on one of the remote servers"
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && #{current_path}/script/rails c #{rails_env}'"
benedikt / pling.rb
Created Oct 24, 2011
Pling resque adapter
View pling.rb
Pling.configure do |config|
config.gateways.use Pling::Gateway::C2DM, { :email => '', :password => '', :source => '' }
config.adapter =
Resque.before_first_fork do
benedikt / active_model_serializers.rb
Created Mar 2, 2012
Makes mongoid and active_model_serializers play nicely together
View active_model_serializers.rb
# config/initializers/active_model_serializers.rb
Mongoid::Document.send(:include, ActiveModel::SerializerSupport)
Mongoid::Criteria.delegate(:active_model_serializer, :to => :to_a)
benedikt / gist:1977438
Created Mar 5, 2012
Protect all fields against mass assignment in a mongoid document by default
View gist:1977438
module Mongoid
module MassAssignmentSecurity
extend ActiveSupport::Concern
included do
attr_accessible nil
module Document
benedikt / spec_helper.rb
Created Apr 24, 2012
Makes spork-rails reload everything nicely
View spec_helper.rb
Spork.each_run do
if Spork.using_spork?
# This line should only be necessary when you have support files
# that use a namespace which is defined somewhere in your application.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
benedikt / projects_controller_spec.rb
Created Jul 17, 2012
I wish this would just work...
View projects_controller_spec.rb
require 'spec_helper'
describe ProjectsController do
let(:project) { double(:project) }
let(:projects) { [project] }
describe 'GET show' do
let(:params) { { :id => 1, :format => :json } }
View gist:4157740
{morekeywords={break, else, new, var, case, finally, return, void, catch, for, switch, while, continue, function, this, with, default, if, throw, delete, in, try, do, instanceof, typeof,
abstract, enum, int, short, boolean, export, interface, static, byte, extends, long, super, char, final, native, synchronized, class, float, package, throws, const, goto, private, transient,
debugger, implements, protected, volatile, double, import, public},
benedikt / gist:5859066
Last active Dec 18, 2015
Is this a mongoid bug or a feature?
View gist:5859066
Model.elem_match(:embedded => { :a => 1, :b => 2 })
# => #<Mongoid::Criteria
# selector: {"embedded"=>{"$elemMatch"=>{:a=>1, :b=>2}}}
# options: {}
# class: Model
# embedded: false>
Model.elem_match(:embedded => { :a => 1 }).elem_match(:embedded => { :b => 2 })
# => #<Mongoid::Criteria
# selector: {"embedded"=>{"$elemMatch"=>{:b=>2}}}
You can’t perform that action at this time.