Skip to content

Instantly share code, notes, and snippets.

View matschaffer's full-sized avatar
🧡

Mat Schaffer matschaffer

🧡
View GitHub Profile
@matschaffer
matschaffer / rack_cgi.rb
Created August 17, 2009 13:16
A basic Rack::CGI implementation.
require 'open3'
require 'pathname'
module Rack
class CGI
def initialize(script)
@script = Pathname.new(script)
end
def call(env)
/**
* Helper to return the fallback as a string if the provided attribute is null or empty.
* @param attribute The desired attribute
* @param fallback The value to use if the attribute is null or an empty string.
* @return String representation of either attribute or the default
*/
protected String attributeWithFallback(Object attribute, Object fallback) {
Object selected;
if (attribute == null || StringUtils.isEmpty(attribute.toString())) {
require 'pathname'
class Buildr::Eclipse::ClasspathEntryWriter
alias :_src :src
def src arg
if arg.respond_to?(:partition)
files, sources = arg.partition { |dep| dep.is_a?(String) && Pathname.new(dep).file? }
lib files
_src sources
else
require 'lib/patch/buildr/eclipse'
repositories.remote << "http://www.ibiblio.org/maven2"
repositories.remote << "http://repository.codehaus.org"
def property(name)
java.lang.System.getProperty name
end
SWT_LIB = ENV['SWT_LIB'] || case property "os.name"
js> load('ejs.js')
js> ;
js> var world="world";
js> var template='hello <%= world %>';
js> print(template);
hello <%= world %>
js> var compiler = EjsCompiler(source);
js: "<stdin>", line 7: uncaught JavaScript runtime exception: ReferenceError: "source" is not defined.
at <stdin>:7
18:40 schapht@matschaffer: ~/Downloads/jruby-rack (master)
> mvn eclipse:eclipse
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building JRuby-Rack
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<properties>
<jruby>${settings.localRepository}/org/jruby/jruby-complete/1.3.1/jruby-complete-1.3.1.jar</jruby>
</properties>
jQuery.fn.dataWithoutTriggering = jQuery.fn.data;
jQuery.fn.data = function(key, value) {
var r = this.dataWithoutTriggering(key, value);
if (typeof(value) != "undefined") {
this.trigger('data', [key, value]);
}
return r;
};
var sys = require('sys'),
buffer = '{"props":{"name":"blogs","allow_mult":false,"big_vclock":50,"chash_keyfun":{"mod":"riak_util","fun":"chash_std_keyfun"},"linkfun":{"mod":"raw_link_walker_resource","fun":"mapreduce_linkfun"},"n_val":3,"old_vclock":86400,"small_vclock":10,"young_vclock":20},"keys":["joe","bob","4KuXdR9WKW0p45ORqKbElZBaK45","frank"]}';
sys.p(JSON.parse(buffer));
sys.puts("Worked fine.");
require.paths.unshift('express/lib');
require('express');
sys.p(JSON.parse(buffer));
var sys = require('sys'),
buffer = '{"keys":[1,2,3]}';
sys.p(JSON.parse(buffer));
sys.puts("Before keys extension worked fine.");
function extend (obj, props) {
Object.getOwnPropertyNames(props).forEach(function(prop){
var descriptor = Object.getOwnPropertyDescriptor(props, prop)
descriptor.enumerable = false