Skip to content

Instantly share code, notes, and snippets.

@Kallin
Kallin / Config.groovy
Created June 22, 2012 18:07
Config.groovy
grails.plugins.springsecurity.providerNames = [
'samlAuthenticationProvider',
'daoAuthenticationProvider',
'anonymousAuthenticationProvider',
'rememberMeAuthenticationProvider']
module Elasticsearcher
module QuerybuilderAdapter
def self.included base
base.extend ClassMethods
end
module ClassMethods
QUERYBUILDER_TO_ELASTIC_RANGES = {
'before' => 'lt',
@Kallin
Kallin / branch_clean.rb
Created February 27, 2015 17:14
delete selected branches in ruby
delete_branches = [
'branch_a',
'branch_b',
'branch_c',
]
delete_branches.each do |branch|
system "git branch -D #{branch}"
system "git push origin --delete #{branch}"
end
@Kallin
Kallin / fibber.rb
Created March 22, 2016 21:39
adnan's a fibber
@fibs = {
0 => 0,
1 => 1,
}
def fib(n)
cached_result = @fibs[n]
return cached_result if cached_result
new_result = fib(n-1) + fib(n-2)
class Vegetable
attr_accessor [
:rarity
]
def ferment
# let's make some vegetable jam!
end
def find_descendants(person)
descendants = []
children = person[:children]
if children
descendants << children
children.each do |child|
descendants << find_descendants(child)
def find_descendants(person)
descendants = []
stack = person[:children]
until stack.empty?
current_node = stack.pop
children = current_node[:children]
if children
children.each do |child|
def num_to_digits(num)
digits = []
until num == 0
digits << num % 10
num = num / 10
end
digits
#!/usr/bin/env ruby
current_branch = `git symbolic-ref --short HEAD`.chomp
if current_branch != "master"
if $?.exitstatus == 0
puts "WARNING: You are on branch #{current_branch}, NOT master."
else
puts "WARNING: You are not on a branch"
end
puts
#!/usr/bin/env ruby
current_branch = `git symbolic-ref --short HEAD`.chomp
if current_branch != "master"
if $?.exitstatus == 0
puts "WARNING: You are on branch #{current_branch}, NOT master."
else
puts "WARNING: You are not on a branch"
end
puts