This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the grok method - shows a list of "interesting" methods for an object | |
# usage - "hello".grok | |
# => ["%", "*", "+", "<<", "[]", "[]=", "all?", "any?", ...] | |
class Object | |
def grok | |
(self.methods - Object.new.methods).sort | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Object.tap method for Ruby 1.8 as defined at | |
# http://ciaranm.wordpress.com/2008/11/30/recursive-lambdas-in-ruby-using-objecttap/ | |
if not Object.respond_to? :tap | |
class Object | |
def tap | |
yield self | |
self | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code comes from http://www.darronschall.com/weblog/2007/11/actionscript-3-singleton-redux.cfm | |
*/ | |
// in SingletonExample.as | |
package com.thefifthcircuit.util { | |
public class SingletonExample { | |
public var foo:String; | |
private static const inst:SingletonExample = new SingletonExample(SingletonLock); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example showing how to use Remember (http://github.com/jpignata/remember) | |
# to serialize a bayes classifier made with the "classifier" gem. This would | |
# be useful to share a Bayes classifier across server instances. | |
# | |
# This seems to be similar, but more rudimentary, to functionality found in | |
# Maglev and jruby-maglev, the ability to share globals across interpreters. | |
require 'rubygems' | |
require 'xattr' | |
require 'moneta' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/projects/jruby ➔ gem install com.lowagie.itext-rtf | |
Successfully installed bouncycastle.bcmail-jdk14-138-java | |
Successfully installed bouncycastle.bcprov-jdk14-138-java | |
Successfully installed bouncycastle.bctsp-jdk14-138-java | |
Successfully installed com.lowagie.itext-rtf-2.1.7-java | |
4 gems installed | |
Installing ri documentation for bouncycastle.bcmail-jdk14-138-java... | |
Installing ri documentation for bouncycastle.bcprov-jdk14-138-java... | |
Installing ri documentation for bouncycastle.bctsp-jdk14-138-java... | |
Installing ri documentation for com.lowagie.itext-rtf-2.1.7-java... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def to_rows(column_length, padding = true) | |
i = 0 | |
array = [] | |
while i < self.size | |
chunk = self[i..(i + column_length - 1)] | |
chunk << [] while chunk.size < column_length if padding | |
array << chunk | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thefifthcircuit.nancy { | |
import flash.net.URLLoader; | |
import flash.net.URLRequest; | |
import flash.net.URLVariables; | |
import flash.net.URLRequestMethod; | |
import flash.events.Event; | |
import flash.events.IOErrorEvent; | |
public class Nancy { | |
private var host: String; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def blank? | |
self.nil? || (self.respond_to?(:empty?) && self.empty?) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.Sprite; | |
import flash.net.Socket; | |
import flash.events.Event; | |
import flash.events.IOErrorEvent; | |
import flash.events.ProgressEvent; | |
public class SocketSample extends Sprite { | |
private var socket:Socket; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.Sprite; | |
import flash.net.Socket; | |
import flash.events.Event; | |
import flash.events.IOErrorEvent; | |
import flash.events.ProgressEvent; | |
public class SocketAMFExample extends Sprite { | |
private var socket:Socket; | |
OlderNewer