Skip to content

Instantly share code, notes, and snippets.

View colinsurprenant's full-sized avatar

Colin Surprenant colinsurprenant

View GitHub Profile
@colinsurprenant
colinsurprenant / ant_test.txt
Created August 11, 2014 07:00
adapteva parallella jffi
test:
[junit] Running com.kenai.jffi.ClosureTest
[junit] Tests run: 35, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.424 sec
[junit] Running com.kenai.jffi.ForeignTest
[junit] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.438 sec
[junit] Running com.kenai.jffi.InvokerTest
[junit] Tests run: 13, Failures: 12, Errors: 0, Skipped: 0, Time elapsed: 0.678 sec
[junit] Test com.kenai.jffi.InvokerTest FAILED
[junit] Running com.kenai.jffi.JSR292Test
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.723 sec
@colinsurprenant
colinsurprenant / Gemfile
Last active August 29, 2015 14:04
binary encoded strings problem in JRuby<->Java.
source "https://rubygems.org"
gem "protobuf"
@colinsurprenant
colinsurprenant / scratchpad.txt
Created April 25, 2014 16:30
logstash examples
input { stdin {} }
filter {}
output {
stdout {
codec => rubydebug
}
}
@colinsurprenant
colinsurprenant / encoding.rb
Created March 16, 2014 19:16
Ruby encoding inconsistencies
# encoding: utf-8
puts "\nusing #{RUBY_DESCRIPTION}"
puts '"123"' + "\t\t=> " + "123".encoding.to_s
puts '"#{123}"' + "\t=> " + "#{123}".encoding.to_s
puts '"#{123.to_s}"' + "\t=> " + "#{123.to_s}".encoding.to_s
puts '123.to_s' + "\t=> " + 123.to_s.encoding.to_s
@colinsurprenant
colinsurprenant / Dockerfile
Last active August 29, 2015 13:57
JRuby on Ubuntu 13.04 Dockerfile
FROM colinsurprenant/ubuntu-raring-amd64:latest
MAINTAINER Colin Surprenant <[email protected]>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update; apt-get upgrade -y; apt-get install -y git-core wget curl build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev libgdbm-dev libffi-dev libxml2-dev libxslt1-dev libncurses5-dev libfuse2
# Fake a fuse install for openjdk-7 - see https://github.com/dotcloud/docker/issues/514
RUN (cd /tmp ; apt-get download fuse; dpkg-deb -x fuse_* .; dpkg-deb -e fuse_*; rm fuse_*.deb; echo -en '#!/bin/bash\nexit 0\n' > DEBIAN/postinst; dpkg-deb -b . /fuse.deb; dpkg -i /fuse.deb)
@colinsurprenant
colinsurprenant / Vagrantfile
Created March 3, 2014 18:20
Vangrantfile and Ansible playbook.yml for basic Elasticsearch and Logstash install
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
config.vm.synced_folder "./", "/vagrant", :disabled => true
# AWS EC2 config
#
# $ vagrant up ec2 --provider=aws
#
# - make sure you correctly configure your AWS settings below
@colinsurprenant
colinsurprenant / docker_clean.sh
Created February 25, 2014 20:21
clean docker repositoty
# remove stopped containers
docker rm $(docker ps -a -q)
# remove untagged images
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
@colinsurprenant
colinsurprenant / module_instance_var.rb
Last active August 23, 2018 19:58
Ruby module instance variables
module SomeModule
module_function
def some_value; @some_value end
def some_value= v; @some_value = v end
end
SomeModule.some_value
# => nil
SomeModule.some_value = 1
SomeModule.some_value
@colinsurprenant
colinsurprenant / comparator.rb
Last active January 2, 2016 18:28
Measuring different Java interface implementation strategies using JRuby.
require 'java'
require 'benchmark'
java_import "java.util.Comparator"
java_import "java.util.Collections"
# dummy Comparable object
class O
include Comparable
attr_reader :id
def initialize(id); @id = id; end
@colinsurprenant
colinsurprenant / ubuntu_image.sh
Created November 27, 2013 21:06
Docker Ubuntu raring 13.04 image creation
sudo debootstrap raring raring > /dev/null
cd raring
# prevent init scripts from running during install/update
echo $'#!/bin/sh\nexit 101' | sudo tee usr/sbin/policy-rc.d > /dev/null
# see https://github.com/dotcloud/docker/issues/446#issuecomment-16953173
sudo chmod +x usr/sbin/policy-rc.d
# shrink the image