Skip to content

Instantly share code, notes, and snippets.

oelmekki /
Created Dec 30, 2015
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix:
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

wvengen /
Last active Mar 5, 2021
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

ymjing / Monaco for
Last active Feb 15, 2021
Powerline-patched Monaco for Windows and OSX
View Monaco for

Powerline-patched Monaco for Windows and OSX

This font is manually patched with Fontforge. It includes the glyphs from DejaVu Sans Mono for Powerline.

I recommend DirectWrite-patched VIM builds. I'm using KaoriYa's build (


Add the following lines to your .vimrc/_vimrc:

View instrumentation.rb
# config/initializers/instrumentation.rb
# Subscribe to grape request and log with Rails.logger
ActiveSupport::Notifications.subscribe('grape.request') do |name, starts, ends, notification_id, payload| '[API] %s %s (%.3f ms) -> %s %s%s' % [
(payload[:response_status] || "error"),
payload[:x_organization] ? "| X-Org: #{payload[:x_organization]}" : "",
staltz /
Last active Jun 22, 2021
The introduction to Reactive Programming you've been missing
thebucknerlife /
Last active Apr 1, 2021
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault


codingfoo / deploy.rb
Created Mar 11, 2014
Rails 4 Capistrano 2 local assets precompile
View deploy.rb
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :app, :except => { :no_release => true } do
system("bundle check"); exit if $? != 0
system("RAILS_ENV=#{stage} bundle exec rake assets:precompile"); exit if $? != 0
servers = find_servers :roles => :web, :except => { :no_release => true }
run <<-CMD.compact
cp -- #{shared_manifest_path.shellescape} #{current_path.to_s.shellescape}/assets_manifest#{File.extname(shared_manifest_path)}
hwdsl2 /
Last active Jun 20, 2021
IPsec VPN Server Auto Setup Script for Ubuntu and Debian
yannleretaille / validate-selectize-fields.js
Last active May 2, 2020
How to validate selectize.js comboboxes with the jQuery validation plugin
View validate-selectize-fields.js
//How to validate selectize.js comboboxes with the jQuery validation plugin
//selectize.js: (brianreavis/selectize.js)
// (jzaefferer/jquery-validation)
//configure jquery validation
//the default ignore selector is ':hidden', the following selectors restore the default behaviour when using selectize.js
//:hidden:not([class~=selectized]) | selects all hidden elements, but not the original selects/inputs hidden by selectize
//:hidden > .selectized | to restore the behaviour of the default selector, the original selects/inputs are only validated if their parent is visible
//.selectize-control .selectize-input input | this rule is not really necessary, but ensures that the temporary inputs created by selectize on the fly are never validated
huacnlee / grape_runtime_log.rb
Last active Jul 3, 2016
Output request time spend and parameters in log for Grape
View grape_runtime_log.rb
require 'grape'
class API < Grape::API
before do
@log_start_t = " Parameters: #{params.to_hash.except("route_info")}"
after do
@log_end_t =