Skip to content

Instantly share code, notes, and snippets.

@pallan
pallan / keybase.md
Last active September 9, 2016 02:09

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:

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
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 October 22, 2013 22:04
Passenger setup from config/environments file
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 September 22, 2013 19:33
Run this script from the root of your Redmine installation to convert from a Chiliproject installation
# 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 November 15, 2012 14:28
Nested if statements without else conditions
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 November 2, 2012 12:58
Commit-msg hook to prefix with a Chiliproject (Redmine) ID
#!/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 October 28, 2011 21:20
jQuery extension Multiple Select Toggle
// 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: '+'