Skip to content

Instantly share code, notes, and snippets.

View kattrali's full-sized avatar

Delisa kattrali

View GitHub Profile
@kattrali
kattrali / code_package_view_shame.rb
Created July 19, 2012 20:48
This code parses directories into Java package structure. Its even recursive!
# from https://github.com/kattrali/redcar-code-package-view/blob/master/lib/code_package_view.rb#L43
def self.package_directory(adapter,base_path,path,nodes=[],path_name=File.basename(path))
has_excluded_dirs = false
has_files = false
Dir["#{path.to_s}/*/"].map do |a|
unless File.basename(a) =~ /^\./ # exclude hidden dirs from being packaged
excluded = false
Preferences.excluded_patterns.each do |ex|
if a =~ /#{ex}/ and not excluded
class MyGroupedListController < UIViewController
attr_accessor :posts
attr_accessor :sections
class TableViewSection
attr_accessor :title
attr_accessor :items
def initialize(params={})
@title = params[:title]
@kattrali
kattrali / a.md
Created June 29, 2012 12:52 — forked from rkh/a.md

This allows you to use the following video streaming services outside of the US from your Mac without having to use a proxy or VPN, so no big bandwidth issues:

  • Netflix
  • Hulu / HuluPlus
  • CBS
  • ABC
  • MTV
  • theWB
  • CW TV
  • Crackle
@kattrali
kattrali / gist:3004803
Created June 27, 2012 15:22 — forked from maddockpa/gist:3004769
Ajax and jquery get request
// target request:
// http://nominatim.openstreetmap.org/reverse?format=xml&lat=40.004&lon=-82.862&MaxResponse=1&zoom=17&accept-language=en-us&addressdetails=1
var getMyData = (function() {
var lat = document.forms[0].lat.value;
var lng = document.forms[0].lon.value;
return {format:"xml",lat:lat,lng:lng,MaxResponse:1,zoom:17,"accept-language":"en-us",addressdetails:1};
})
var submitForm = function() {
@kattrali
kattrali / edit_view_swt.rb
Created May 26, 2012 19:32
redcar/plugins/edit_view_swt/lib/edit_view_swt.rb
#how grammar is set
def update_grammar(new_mirror)
title = new_mirror.title
contents = new_mirror.read
first_line = contents.to_s.split("\n").first
# @mate_text is a MateText object (see javamateview project)
grammar_name = @mate_text.set_grammar_by_first_line(first_line) if first_line
unless grammar_name
grammar_name = @mate_text.set_grammar_by_filename(title)
@kattrali
kattrali / bridge.rb
Created May 8, 2012 22:26 — forked from andreif/bridge.rb
bridgesupport
require "hpricot"
require "fileutils"
module BridgeSupport
class Parser
def initialize(path_from, path_to)
@doc = open(path_from) {|f| Hpricot(f).search('signatures').first}
if @doc and @doc.children
FileUtils.mkdir_p File.dirname(path_to)
o = open(path_to, 'w')
@kattrali
kattrali / scope_finder.rb
Created September 27, 2011 13:44
finding the proper grammar for a given scope in a Redcar tab
module Redcar
class Comment
java_import 'com.redcareditor.mate.Grammar'
# Find a map of comment symbols for a grammar, using the a tab's cursor scope
def self.find_by_scope tab
# doc.cursor_scope is returned as space-delimited string of applicable
# scopes, from most general, to most specific. For example,
# in an erb file, the top scope would be something like 'text.html.ruby',
@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
@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 / _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) {