Skip to content

Instantly share code, notes, and snippets.

View kattrali's full-sized avatar

Delisa kattrali

View GitHub Profile
@kattrali
kattrali / classpath.groovy
Created October 27, 2010 18:24
A sample configuration file for loading the groovy class path for better syntax checking in redcar (with some grails mixed in). Save as [project]/.redcar/classpath.groovy
// classpath retriever for all jars in project "lib" folder and compiled classes in project
def GRAILS_VERSION = '1.3.7'
def redcar_config = new File(getClass().protectionDomain.codeSource.location.path).parentFile
def project = redcar_config.parentFile
def classpath = []
def home = System.getProperty("user.home")
def cache = new File(home+File.separator+".ivy2"+File.separator+"cache")
@kattrali
kattrali / lucene output
Created October 30, 2010 15:48
after searching a huge repo
Exception in thread "Thread-10" java.lang.OutOfMemoryError: Java heap space
at org.jruby.util.ByteList.<init>(ByteList.java:91)
at org.jruby.util.io.ChannelStream.readall(ChannelStream.java:365)
at org.jruby.RubyIO.readAll(RubyIO.java:2825)
at org.jruby.RubyIO.read(RubyIO.java:2641)
at org.jruby.RubyIO.read(RubyIO.java:3327)
at org.jruby.RubyIO$s_method_multi$RUBYINVOKER$read.call(org/jruby/RubyIO$s_method_multi$RUBYINVOKER$read.gen:65535)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrTwoOrThreeBlock.call(JavaMethod.java:548)
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:160)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:66)
@kattrali
kattrali / non_modal.rb
Created December 23, 2010 20:18
Non-modal pop-up dialog in JRuby/SWT
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.custom.StyleRange
class KeyListener
def initialize(shell)
@shell = shell
end
def key_pressed(e)
package com.sporkmonger.rmud.swt.custom;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.LineStyleEvent;
import org.eclipse.swt.custom.LineStyleListener;
import org.eclipse.swt.custom.StyleRange;
module Redcar
class REPL
class Tab < Redcar::EditTab
...
def update_cursor_size
if widget = edit_view.controller.mate_text.get_text_widget
caret = Swt::Widgets::Caret.new(widget, Swt::SWT::NONE)
@kattrali
kattrali / whazzup.rb
Created January 26, 2011 11:57 — forked from cyberfox/whazzup.rb
Asks for status every 15-25 minutes to track where time goes. Traps USR2 to wake and prompt for status. Designed for Linux, works on OS X, needs tweaks for Windows. Uses JRuby, since it's the only easy-to-get cross-platform UI toolkit for Ruby.
require "java"
java_import javax.swing.JOptionPane
class Whazzup
def initialize(file = "#{ENV['HOME']}/snippets.txt")
@snippets ||= open(file, 'ab')
log('[Starting up (ruby)]')
thread_loop = Thread.current
/**
* jQuery.support.cssProperty
* To verify that a CSS property is supported (or any of its browser-specific implementations)
*
* @param string p - css property name
* [@param] bool rp - optional, if set to true, the css property name will be returned, instead of a boolean support indicator
*
* @Author: Axel Jack Fuchs (Cologne, Germany)
* @Date: 08-29-2010 18:43
*
#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 '/' \.
}
@kattrali
kattrali / hotswap.json
Created February 25, 2011 07:46
A sample hotswap configuration file for grails projects for use with Redcar editor. Save as [project]/.redcar/hotswap.json and change the project name as appropriate
{
"patterns" : [
{
"pattern" : "(.*)\\/my_project\\/grails-app\\/(services|controllers)\\/(.*)(Service|Controller)\\.groovy",
"1" : {
"link" : "$1 + '/my_project/grails-app/domain/' + $3 + '.groovy'",
"name" : "Model"
},
"2" : {
"link" : "$1 + '/my_project/grails-app/views/' + (a = $3.split('/').last.split(//); a[0] = a[0].downcase; a.join) + '/CURRENT_WORD.gsp'",
@kattrali
kattrali / _Events.groovy
Created March 11, 2011 16:36
groovy script for adding Notify OSD alerts to grails events. Save as ~/.grails/scripts/_Events.groovy
// Documentation on Event hooks: http://grails.org/doc/latest/guide/4.%20The%20Command%20Line.html#4.3%20Hooking%20into%20Events
// Inspiration: http://www.anyware.co.uk/2005/2007/05/02/grails-script-notifications-via-growl/
Ant = new AntBuilder()
eventStatusFinal = { msg ->
notifySend(msg)
}
void notifySend(String message) {