Skip to content

Instantly share code, notes, and snippets.

View jberkel's full-sized avatar

Jan Berkel jberkel

View GitHub Profile
package com.soundcloud.adc.models;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* Represents a Track from Soundcloud. As this is an example app, the model is pretty basic
*
*/
private String getResponse(HttpURLConnection conn){
InputStream is = null;
try
{
is = conn.getInputStream();
int ch;
StringBuffer sb = new StringBuffer();
while( ( ch = is.read() ) != -1 ) {
sb.append( (char)ch );
NoMethodError: undefined method `monitor' for Runner:Module
./spec/runner_spec.rb:54: Runner.monitor - should fail when a 2 second command doesn't change a file within 0.5 second
./spec/runner_spec.rb:53
/Users/jan/.rvm/gems/ruby-1.8.7-p302@workers/gems/em-spec-0.2.1/lib/em-spec/../ext/fiber18.rb:16:in `initialize'
/Users/jan/.rvm/gems/ruby-1.8.7-p302@workers/gems/em-spec-0.2.1/lib/em-spec/../ext/fiber18.rb:16:in `new'
/Users/jan/.rvm/gems/ruby-1.8.7-p302@workers/gems/em-spec-0.2.1/lib/em-spec/../ext/fiber18.rb:16:in `initialize'
/Users/jan/.rvm/gems/ruby-1.8.7-p302@workers/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `call'
/Users/jan/.rvm/gems/ruby-1.8.7-p302@workers/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/Users/jan/.rvm/gems/ruby-1.8.7-p302@workers/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
./spec/runner_spec.rb:9
@jberkel
jberkel / gist:615032
Created October 7, 2010 12:35
store apks in da cloud
#!/usr/bin/env ruby
require 'aws/s3'
require 'erb'
require 'cgi'
require 'json'
class CloudAPK
include AWS::S3
hit = VSL_stats->cache_hit - copy.cache_hit;
miss = VSL_stats->cache_miss - copy.cache_miss;
hit /= lt;
miss /= lt;
if (hit + miss != 0) {
ratio = hit / (hit + miss);
myexp(&a1, ratio, &n1, 10);
myexp(&a2, ratio, &n2, 100);
myexp(&a3, ratio, &n3, 1000);
}
ABI=32
BUILD_DATE=2010-04-13 16:41:42 +0000
BUILD_HOST=SunOS pkgsrc-gcc 5.11 snv_89 i86pc i386 i86pc
CATEGORIES=www
CC_VERSION=gcc-4.4.2
CFLAGS=-O -I/usr/include
CMAKE_ARGS=
CONFIGURE_ARGS=--localstatedir=/var/db --prefix=/opt/local --build=i386-sun-solaris2 --host=i386-sun-solaris2 --mandir=/opt/local/man
CONFIGURE_ENV=VCC_CC="gcc -fpic -shared -o %o %s" PTHREAD_CFLAGS=\ -D_REENTRANT PTHREAD_LDFLAGS= PTHREAD_LIBS=-lpthread\ -lrt PTHREADBASE=/usr LIBTOOL="libtool " INSTALL_INFO= MAKEINFO=/tmp/pkgsrc/www/varnish/work/.tools/bin/makeinfo AWK=/opt/local/bin/nawk CAT=/usr/bin/cat ac_cv_path_CAT=/usr/bin/cat CHMOD=/usr/bin/chmod CMP=/bin/cmp CP=/bin/cp DIFF=/bin/diff ECHO=echo ac_cv_path_ECHO=echo EGREP=/opt/local/bin/gegrep ac_cv_path_EGREP=/opt/local/bin/gegrep SETENV=/usr/bin/env ENV_PROG=/usr/bin/env ac_cv_path_ENV=/usr/bin/env FALSE=false ac_cv_path_FALSE=false FIND=/opt/local/bin/gfind GREP=/opt/local/bin/ggrep ac_cv_path_GREP=/opt/local/bin/ggrep HOSTNAME=/bin/hostname LN=/usr/bin/ln LS=/usr/bin/ls MKDIR=/u
Scenario: Looking at my follower tab should reset the counter # features/user_counters.feature:35
Given I am followed by one person # features/step_definitions/activity_stream_steps.rb:114
When I look at my public profile # features/step_definitions/web_steps.rb:22
And I click on the "new follower" tab # features/step_definitions/user_counters_steps.rb:18
private method `params_filters=' called for #<HoptoadNotifier::Notice:0x0000010a361da8> (NoMethodError)
/Users/jan/.rvm/gems/ruby-1.9.1-p378/gems/hoptoad_notifier-2.3.5/lib/hoptoad_notifier/notice.rb:322:in `also_use_rack_params_filters'
/Users/jan/.rvm/gems/ruby-1.9.1-p378/gems/hoptoad_notifier-2.3.5/lib/hoptoad_notifier/notice.rb:98:in `initialize'
/Users/jan/.rvm/gems/ruby-1.9.1-p378/gems/hoptoad_notifier-2.3.5/lib/hoptoad_notifier.rb:134:in `new'
/Users/jan/.rvm/gems/ruby-1.9.1-p378/gems/hoptoad_notifier-2.3.5/lib/hoptoad_notifier.rb:134
sub vcl_fetch {
# Enable grace period
set beresp.grace = 1h;
# Add X-Cacheable header to track cache miss reasons
if (beresp.http.Set-Cookie) {
set beresp.http.X-Cacheable = "NO:Set-Cookie";
} elseif (beresp.http.Pragma ~ "no-cache") {
set beresp.http.X-Cacheable = "NO:Pragma=no-cache";
} elseif (beresp.http.Pragma ~ "no-store") {
$ curl -I http://cache.vfestival.com/
HTTP/1.1 200 OK
Server: Apache/2.2.3 (CentOS)
Last-Modified: Thu, 12 Aug 2010 19:11:26 GMT
ETag: "38f2da8-f982-21fa1380"
Content-Type: text/html; charset=utf-8
Content-Length: 63874
Date: Thu, 12 Aug 2010 19:16:11 GMT
X-Varnish: 831898916 831898856
Age: 107

Ruboto - JRuby on Android

In recent years the Ruby language has become very popular for developing web based applications, largely driven by the success of the now ubiquitous Ruby on Rails framework.

Ruby developers usually name dynamic typing, the compact yet expressive syntax and powerful abstraction mechanisms as strong points of the language, allowing the user to write elegant code in a short amount of time.

The goal of the [Ruboto / JRuby on Android][1] project is to build the necessary framework and infrastructure to make Ruby a viable option for Android development. The talk will present some of the challenges faced during this process and show that Ruby can be a valuable additional tool for Android developers.

Bio