Skip to content

Instantly share code, notes, and snippets.

View rtyler's full-sized avatar

R. Tyler Croy rtyler

View GitHub Profile
@rtyler
rtyler / bootstrap-jenkins.sh
Last active November 2, 2015 15:58
A little script I'm using to stand up demonstration instances of Jenkins
#!/bin/sh
# Usage: bootstrap-jenkins.sh trusty ubuntu@some-aws-machine
install_puppet() {
wget https://apt.puppetlabs.com/puppetlabs-release-${1}.deb && \
sudo dpkg -i puppetlabs-release-${1}.deb && \
sudo apt-get update && \
sudo apt-get install -y puppet &&
task spec(type: JRubyExec) {
classpath configurations.rspec
script 'rspec'
}
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:[1.2.2,2.0)'
classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:[1.1.2,2.0)'
}
}
apply plugin: 'groovy'
apply plugin: 'com.github.johnrengelman.shadow'
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.github.jruby-gradle</groupId>
<artifactId>jruby-gradle-plugin</artifactId>
<version>0.3.0</version>
<versioning>
<latest>0.3.0</latest>
<release>0.3.0</release>
<versions>
<version>0.1.0</version>
➜ blick git:(master) ✗ rm -rf build; time ./gradlew -S jrubyPrepare
:jrubyPrepare
BUILD SUCCESSFUL
Total time: 5.223 secs
./gradlew -S jrubyPrepare 1.51s user 0.08s system 28% cpu 5.616 total
➜ blick git:(master) ✗
#
# This /tmp directory was generated by some integration tests installing thor-0.19.1.gem
#
➜ groovy-gem git:(master) ✗ GEM_PATH= GEM_HOME=/tmp/geminstallerintegrationspec2599869760798060236 irb
geminstallerintegrationspec2599869760798060236 :001 > require 'thor/version'
=> true
geminstallerintegrationspec2599869760798060236 :002 > Thor::VERSION
=> "0.19.1"
geminstallerintegrationspec2599869760798060236 :003 >
@rtyler
rtyler / helloserv.js
Created July 25, 2015 20:36
Using avatar-js to run a node hello world app from JRuby
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
@rtyler
rtyler / 0_output.log
Created July 25, 2015 19:46
Demonstrating calling into JavaScript functions from JRuby on JDK8
>> Starting mega-awesome JavaScripts
Doing with math in JavaScript gives us: 3.0
@rtyler
rtyler / gist:7d9fd30a7093c7cd362b
Created July 25, 2015 19:16
Fun with Nashorn and JRuby
➜ ~ pry
[1] pry(main)> require 'java'
=> false
[2] pry(main)> puts RUBY_PLATFORM; puts RUBY_VERSION
java
1.9.3
=> nil
[3] pry(main)> java_import 'javax.script.ScriptEngineManager'
=> [Java::JavaxScript::ScriptEngineManager]
[4] pry(main)> engine = ScriptEngineManager.new.get_engine_by_name('nashorn')
buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.github.jruby-gradle:jruby-gradle-plugin:0.4.0'
}
}
apply plugin: "com.github.jruby-gradle.base"
import com.github.jrubygradle.JRubyExec