Skip to content

Instantly share code, notes, and snippets.

Michael van Rooijen mrrooijen

Block or report user

Report or block mrrooijen

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
@mrrooijen
mrrooijen / lib_utils_coders_marshal.rb
Last active Aug 29, 2015
Marshal serializer for ActiveRecord 4.
View lib_utils_coders_marshal.rb
module Coders
class Marshal
attr_reader :klass
def initialize(klass)
@klass = klass
end
def load(data)
@mrrooijen
mrrooijen / api_base_controller.rb
Last active Aug 29, 2015
Ember.js + Rails API setup with header-based API key and API version configuration.
View api_base_controller.rb
class Api::BaseController < ActionController::Base
protect_from_forgery with: :null_session
before_action :unauthorized_if_signed_out
layout false
def current_user
@current_user ||= (
authenticate_or_request_with_http_token do |token, options|
User.find_by(api_key: token)
end
@mrrooijen
mrrooijen / resque_stale_worker_cleaner.rb
Last active Aug 29, 2015
Prune stale Resque workers.
View resque_stale_worker_cleaner.rb
class ResqueStaleWorkerCleaner
SLOWEST_JOB = (ENV["SLOWEST_JOB"] || 30).to_i # minutes
def call
Resque.workers.each do |worker|
worker.unregister_worker if old_worker?(worker)
end
end
private
@mrrooijen
mrrooijen / out-of-memory.sh
Last active Aug 29, 2015
Dokku Information
View out-of-memory.sh
echo 1 > /proc/sys/vm/overcommit_memory
@mrrooijen
mrrooijen / Git-Ignore
Created Jul 29, 2009
Git Ignore File for my Capistrano recipe
View Git-Ignore
# Author: Michael van Rooijen
# Description:
# If you are using my Capistrano Recipe, be sure to add these lines to your .gitignore file.
# It will prevent problems when deploying incase your generated the all.js/all.css, assets, database.yml etc.
# Assets and Database yaml should be stored in the "shared" section of the application, not inside the actual application with every release.
.DS_Store
log/*.log
tmp/**/*
config/database.yml
@mrrooijen
mrrooijen / nginx
Created Jul 29, 2009
A script to enable easy start/stop functionality for the NginX Web Server.
View nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@mrrooijen
mrrooijen / jQuery-Plugin-Template.js
Created Jul 29, 2009
A jQuery Plugin Template.
View jQuery-Plugin-Template.js
(function($){
/**
* jQuery PluginName
*
* @plugin {PluginName}
* @description {PluginDescription}
*
* @changelog
* @{mm/dd/yyyy} {version} {author} {changedescription}
View Paperclip-Simple-Template.rb
# Inside the model.rb
has_attached_file :image,
:url => "/assets/images/:style/:id.:basename.:extension",
:path => ":rails_root/public/assets/images/:style/:id.:basename.:extension",
:styles => {
:small => '50x45#',
:medium => '150x150',
:large => '300x300'
}
View Rails - Remove Form Error Decorations.rb
# Place this line below in your environment.rb to remove the Form Error Decorations that display when the form validation failed.
ActionView::Base.field_error_proc = proc { |input, instance| input }
View CodeRay-Railscasts-like-CSS.css
.CodeRay {
background-color: #232323;
border: 1px solid black;
font-family: 'Courier New', 'Terminal', monospace;
color: #E6E0DB;
padding: 3px 5px;
overflow: auto;
font-size: 12px;
margin: 12px 0;
}
You can’t perform that action at this time.