Skip to content

Instantly share code, notes, and snippets.

View kattrali's full-sized avatar

Delisa kattrali

View GitHub Profile
@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) {
@kattrali
kattrali / pretty.rb
Created August 12, 2011 15:40
Skinning Redcar, one widget at a time
# Open in Redcar
# Run Plugins > Execute > Eval Current Tab (in Redcar itself)
# (This is a terrible hack)
require 'java'
def init
make_pretty
Redcar.app.add_listener(:window_added) do |win|
make_pretty
@kattrali
kattrali / pretty_gutter.rb
Created September 1, 2011 13:20
small aesthetic changes to the redcar line numbers and annotations area
# Run via Redcar menu > Plugins > Execute > Eval Current Tab (within Redcar)
include Redcar
def get_swt_color hex_value
Swt::Graphics::Color.new(
ApplicationSWT.display,
hex_value[1,2].hex,
hex_value[3,2].hex,
hex_value[5,2].hex