This file contains 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
#!/usr/bin/env ruby | |
$: << File.dirname(__FILE__)+'/lib' | |
require 'goliath' | |
require 'em-synchrony/em-http' | |
# | |
# Here's an example of how to make an asynchronous request in the middleware, | |
# and only proceed with the response when both the endpoint and our middleware's | |
# responses have completed. |
This file contains 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
/* use like | |
$ javac Go2.java | |
$ java -client Go2 | |
$ java -server Go2 | |
*/ | |
public class Go2 { |
This file contains 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
// Copyright 2011 Google Inc. All rights reserved. | |
// Use of this source code is governed by the Apache 2.0 | |
// license that can be found in the LICENSE file. | |
package guestbook | |
import ( | |
"http" | |
"io" | |
"os" |
This file contains 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
HTTP/1.1 200 OK | |
Server: Sun-Java-System-Web-Server/7.0 | |
Date: Mon, 07 Dec 2009 07:25:34 GMT | |
P3p: policyref="http://www.sun.com/p3p/Sun_P3P_Policy.xml", CP="CAO DSP COR CUR ADMa DEVa TAIa PSAa PSDa CONi TELi OUR SAMi PUBi IND PHY ONL PUR COM NAV INT DEM CNT STA POL PRE GOV" | |
Cache-control: public | |
Set-cookie: JROUTE=W2VMz2yu926eYGvP; Path=/ | |
X-powered-by: JSP/2.1 | |
Set-cookie: JSESSIONID=80765ae114eab08df95a11208c62; Path=/ | |
Content-type: text/html;charset=UTF-8 | |
Via: 1.1 https-www |
This file contains 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
require 'jruby' | |
module Serialize | |
def self.serialize(obj) | |
baos = java.io.ByteArrayOutputStream.new | |
oos = java.io.ObjectOutputStream.new(baos) | |
oos.write_object(JRuby.reference(obj)) | |
oos.close | |
This file contains 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
# Ruby 1.9.3 | |
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bench/bench_fiber_ring.rb 5 100 1000 | |
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0] | |
bench/bench_fiber_ring.rb:23: warning: mismatched indentations at 'end' with 'def' at 21 | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.155022) | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153985) | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153822) | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.152370) | |
100 fibers / 1000 passes: 0.160000 0.000000 0.160000 ( 0.155857) |
This file contains 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
# Adapted from https://github.com/kilim/kilim/blob/master/examples/kilim/examples/SimpleTask.java | |
import "kilim.Mailbox" | |
import "kilim.Pausable" | |
import "kilim.Task" | |
class ExampleTask < Task | |
def initialize | |
@mailbox = Mailbox.new | |
end |
This file contains 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
" Name: focus.vim | |
" Author: Alan MacDougall <smoke@alanmacdougall.com> | |
" License: Public Domain | |
" | |
" Focus on a single column of text, showing it in a distraction-free format. | |
" Save this as ~/.vim/scripts/focus.vim (or whatever you please), and invoke | |
" it with :source <filename>. Of course, you could certainly hook that up to a | |
" :command, or a macro, or a Vimscript function... | |
" collapse current splits and divide screen in three |
This file contains 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
import com.cloudera.crunch._ | |
import com.cloudera.scrunch._ | |
class ScrunchWordCount { | |
def wordCount(inputFile: String, outputFile: String) = { | |
val pipeline = new Pipeline[ScrunchWordCount] | |
pipeline.read(from.textFile(inputFile)) | |
.flatMap(_.toLowerCase.split("\\W+")) | |
.filter(!_.isEmpty()) | |
.count |
This file contains 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
# Additional methods for Goliath::TestHelper to make simple Goliath testing | |
# simple. You might need the other syntax for testing gnarly stuff, but I've | |
# yet to need it. To use, just include this in your spec_helper.rb. | |
# | |
# Your spec must respond to #api and return the Goliath API class to test. | |
# | |
# @example | |
# describe MyAPI do | |
# let(:api) { MyAPI } | |
# describe "GET /" do |