Skip to content

Instantly share code, notes, and snippets.


Benedikt Deicke benedikt

View GitHub Profile
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
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 / 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)
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
benedikt / appsignal.rb
Last active Oct 12, 2018
Sidekiq Queue Sizes in AppSignal
View appsignal.rb
# Be sure to also enable minutely probes. For example by setting APPSIGNAL_ENABLE_MINUTELY_PROBES=true
require 'sidekiq/api'
class Appsignal::SidekiqProbe
def call
Sidekiq::Queue.all.each do |queue|
Appsignal.set_gauge("sidekiq.queues.#{}", queue.size)
benedikt /
Last active Jan 4, 2016
Setting up AppSignal on Shelly Cloud

Setting up AppSignal on Shelly Cloud

To set up AppSignal on Shelly Cloud, you first have to add both the dotenv-rails and the appsignal gem to your Gemfile. Make sure that the dotenv-rails gem is the very first gem in your Gemfile as it will set up important environment variables as soon as it is required.

# Gemfile

source ''

gem 'dotenv-rails'
benedikt / array_each.rb
Created Oct 23, 2013
In Rubinius, the `Array#each` method does not enumerate elements that are added while enumerating. Is this intentional or a bug?
View array_each.rb
array = [1, 2]
array.each { |n| array << n * 2; break if n > 10 }
# ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
# => [1, 2, 2, 4, 4, 8, 8, 16, 16, 32]
# rubinius 2.1.1 (2.1.0 be67ed17 2013-10-18 JI) [x86_64-darwin12.5.0]
# => [1, 2, 2, 4]
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}}}
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},