Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am pallan on github.
  • I am peerallan (https://keybase.io/peerallan) on keybase.
  • I have a public key whose fingerprint is B53D 42AA 582B C8D2 56BF 9F2D E8FC 7A53 71EE 8B3C

To claim this, I am signing this object:

View LICENSE
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
View rails_issue_13775.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
@pallan
pallan / gist:7109019
Created Oct 22, 2013
Passenger setup from config/environments file
View gist:7109019
if defined?(PhusionPassenger)
require 'phusion_passenger/rack/out_of_band_gc'
require 'phusion_passenger/public_api'
# Trigger out-of-band GC every 5 requests.
config.middleware.use PhusionPassenger::Rack::OutOfBandGc, 5
end
# NewRelic Garbage Collection Monitoring
GC::Profiler.enable
@pallan
pallan / chiliproject_to_redmine.rb
Created Sep 22, 2013
Run this script from the root of your Redmine installation to convert from a Chiliproject installation
View chiliproject_to_redmine.rb
# encoding: UTF-8
# Chiliproject to Redmine converter
# =================================
#
# This script takes an existing Chiliproject database and
# converts it to be compatible with Redmine (>= v2.3). The
# database is converted in such a way that it can be run multiple
# times against a production Chiliproject install without
# interfering with it's operation. This is done by duplicating
@pallan
pallan / gist:4078881
Created Nov 15, 2012
Nested if statements without else conditions
View gist:4078881
if a || b == d || c != n # lets check a bunch of conditions
if m <= p && a > n # we passed! ok, let's check some more
puts 'YAY' # we passed again!
end # I guess that's all we really needed
end # fine!
@pallan
pallan / gist:4001241
Created Nov 2, 2012
Commit-msg hook to prefix with a Chiliproject (Redmine) ID
View gist:4001241
#!/usr/bin/env ruby
current_branch =`git symbolic-ref HEAD`.chomp.split('/').last
issue_id = current_branch[/\d+/].to_i
commit_message = File.read(ARGV.first).chomp.strip
matches = /^[rmRM\s-]*#\d*(.*)$/.match(commit_message)
commit_message = matches[1].strip if matches
if commit_message == ''
puts "Aborting commit due to empty commit message."
@pallan
pallan / gist:1323595
Created Oct 28, 2011
jQuery extension Multiple Select Toggle
View gist:1323595
// Add a clickable plus (+) sign after a select element that when clicked
// toggles the multiple attribute on the select box
// obviously it could use some options for the toggle element, styling or
// the select size
(function($){
$.fn.extend({
multiSelectToggle : function(options){
//Settings list and the default values
var defaults = {
label: '+'
You can’t perform that action at this time.