Skip to content

Instantly share code, notes, and snippets.

@ggayan
ggayan / Gemfile
Created Jul 31, 2013
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
View Gemfile
source 'http://rubygems.org'
gem 'nio4r', github: 'celluloid/nio4r', branch: 'master'
gem 'celluloid-io'
gem 'celluloid-redis'
View README.md

Installs ruby-2.0.0-p195 on ubuntu via checkinstall so it's in your package manager and you can remove it.

Quick install:

curl -L https://gist.github.com/ggayan/5637565/raw/5835fe8ae3efb2c96c75c59ada2b1ecbe123bcfb/ruby-2-install-ubuntu.sh | bash -s
@ggayan
ggayan / UnderscoreCodec.groovy
Created Feb 14, 2010
Grails codec that allows to manipulate underscores inside strings
View UnderscoreCodec.groovy
//codec must be created inside grails-app/utils named like *Codec.groovy
class UnderscoreCodec {
static encode = {target->
target.replaceAll(" ", "_")
}
static decode = {target->
target.replaceAll("_", " ")
}
View Grails Bash completion (tested on OSX, Grails 1.2)
#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 Feb 13, 2010
Some guides to model m:n relationships in grails using lists(for sorting) or not
View ManyToManyModelingWithGrails.groovy
//Domain classes...
class Team {
String name
static hasMany = [memberships:Membership]
static constraints = {}
}
class Player {
String name
@ggayan
ggayan / .gitconfig
Created Feb 13, 2010
git config reminder
View .gitconfig
[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 Oct 29, 2009
Groovy code for parsing emails from a string
View parseEmail.groovy
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'