Skip to content

Instantly share code, notes, and snippets.

@ggayan
ggayan / Gemfile
Created July 31, 2013 21:28
Code for reproducing ERROR -- : RedisActor: CLEANUP CRASHED! IOError: selector is closed with celluloid-redis nio4r v0.4.6 produces a segfault. For running the example use bundle && bundle exec ruby app.rb
source 'http://rubygems.org'
gem 'nio4r', github: 'celluloid/nio4r', branch: 'master'
gem 'celluloid-io'
gem 'celluloid-redis'
@ggayan
ggayan / README.md
Last active December 17, 2015 16:19 — forked from ngauthier/README.md
@ggayan
ggayan / UnderscoreCodec.groovy
Created February 14, 2010 00:06
Grails codec that allows to manipulate underscores inside strings
//codec must be created inside grails-app/utils named like *Codec.groovy
class UnderscoreCodec {
static encode = {target->
target.replaceAll(" ", "_")
}
static decode = {target->
target.replaceAll("_", " ")
}
#export GRAILS_VERSION="$(ls -lhr $HOME/.grails | egrep -i '1\.' | head -1 | gawk '{print $9 }')"
export GRAILS_VERSION=`cat $GRAILS_HOME/build.properties | grep "^grails.version=" | awk -F= '{ print $2 }' | tr -d '\r' | tr -d '\n'`
_get_domain_classes(){
find ./grails-app/domain -iname *.groovy 2> /dev/null | tr \\n ' ' | sed 's/\.groovy//g' | sed 's/\.\/grails-app\/domain\///g' | tr '/' \.
}
_get_tests(){
find ./test -iname *.groovy 2> /dev/null | sed 's/\.\/test\/integration\///g' | sed 's/\Tests.groovy//g' | tr '/' \.
}
@ggayan
ggayan / ManyToManyModelingWithGrails.groovy
Created February 13, 2010 23:26
Some guides to model m:n relationships in grails using lists(for sorting) or not
//Domain classes...
class Team {
String name
static hasMany = [memberships:Membership]
static constraints = {}
}
class Player {
String name
@ggayan
ggayan / .gitconfig
Created February 13, 2010 21:55
git config reminder
[core]
autocrlf = input
excludesfile = ~/.gitignore_global
editor = e -w
pager = less -FRSX
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
[color]
branch = auto
diff = auto
@ggayan
ggayan / parseEmail.groovy
Created October 29, 2009 22:03
Groovy code for parsing emails from a string
def parseEmailsFromString(String emails) {
//adapted from http://www.regular-expressions.info/email.html
return emails?.findAll(/(?i)\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b/)
}
//And a simple test:
void testParseEmailAddressFromString() {
String email1 = 'john@unittest.com'