Skip to content

Instantly share code, notes, and snippets.

View monkstone's full-sized avatar

Martin Prout monkstone

View GitHub Profile
@monkstone
monkstone / install_jruby.sh
Last active November 14, 2018 07:04
Install JRuby-9.2.4.0
#!/usr/bin/env bash
JRUBY_URL="https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.4.0/jruby-dist-9.2.4.0-bin.tar.gz"
printf "Downloading JRuby from:-\n%s\n" "$JRUBY_URL"
wget "$JRUBY_URL"
printf "Change directory to /opt\n"
CURRENT=$PWD
cd "/opt"
sudo tar xzvf "${CURRENT}/jruby-dist-9.2.4.0-bin.tar.gz"
sudo update-alternatives --install /usr/bin/jruby jruby /opt/jruby-9.2.4.0/bin/jruby 51
sudo update-alternatives --install /usr/bin/jirb jirb /opt/jruby-9.2.4.0/bin/jirb 51
@monkstone
monkstone / Boundary.java
Last active October 29, 2018 06:47
Boundary from RShape
import geomerative.RPoint;
import geomerative.RShape;
public class Boundary extends RShape {
static Boundary createBoundingRectangle(float x, float y, float w, float h) {
Boundary rect = new Boundary();
rect.addMoveTo(x, y);
rect.addLineTo(x + w, y);
@monkstone
monkstone / Boundary.java
Last active October 28, 2018 19:01
RShape and Boundary
import geomerative.RPoint;
import geomerative.RShape;
public class Boundary extends RShape {
static Boundary createBoundingRectangle(float x, float y, float w, float h) {
Boundary rect = new Boundary();
rect.addMoveTo(x, y);
rect.addLineTo(x + w, y);
rect.addLineTo(x + w, y + h);
What is JRubyArt?
JRubyArt allows you to code processing sketches in regular ruby (it supersedes ruby-processing for processing-3.0+).
Vanilla processing is essentially Java with an antlr pre-processor to make writing code simpler (in the processing ide).
JRubyArt is able to emulate the simplicity of vanilla processing, by using JRuby to load regular processing jars into a ruby runtime environment.
JRuby is an implementation of the Ruby programming language atop the Java Virtual Machine, written largely in Java (which is under continuous development cf jython).
import java.util.HashMap;
public class TerrainHeight{
public HashMap<Integer, Float> terrain;
public TerrainHeight(){
terrain = new HashMap<>();
}
public void storeHeight(int x, int y, float value){
`uname -m | sed -e 's/i[3456678]86/i386/'`
yields
armv7l ie. armv7(letter 'l')
@monkstone
monkstone / terreno.rb
Created October 12, 2018 15:30
Terrain Sketch on Raspberry PI
attr_reader :terrain, :rows, :columns, :mover
WIDTH = 1400
HEIGHT = 1100
SCL = 30
def settings
size 800, 800, P3D
end
@monkstone
monkstone / config.yml
Last active September 2, 2018 06:38
JRubyArt config for RaspberryPI
---
PROCESSING_ROOT: /home/pi/processing-3.4
JRUBY: false
sketchbook_path: /home/pi/sketchbook
template: bare
MAX_WATCH: 32
sketch_title: JRubyArt Static Sketch
width: 600
height: 600
@monkstone
monkstone / README.html
Last active November 16, 2018 11:23
Set up a local gem environment on RaspberryPi, install jruby and install gems
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>auto_install_picrate</title>
<style>.markdown-preview:not([data-use-github-style]) { padding: 2em; font-size: 1.2em; color: rgb(171, 178, 191); background-color: rgb(40, 44, 52); overflow: auto; }
.markdown-preview:not([data-use-github-style]) > :first-child { margin-top: 0px; }
.markdown-preview:not([data-use-github-style]) h1, .markdown-preview:not([data-use-github-style]) h2, .markdown-preview:not([data-use-github-style]) h3, .markdown-preview:not([data-use-github-style]) h4, .markdown-preview:not([data-use-github-style]) h5, .markdown-preview:not([data-use-github-style]) h6 { line-height: 1.2; margin-top: 1.5em; margin-bottom: 0.5em; color: rgb(255, 255, 255); }
.markdown-preview:not([data-use-github-style]) h1 { font-size: 2.4em; font-weight: 300; }
.markdown-preview:not([data-use-github-style]) h2 { font-size: 1.8em; font-weight: 400; }
@monkstone
monkstone / Manifest.mf
Last active June 11, 2018 06:08
Environment Implementation-Version: 2.3.2 Implementation-Build: 2.3-bmanual-20180302 Implementation-Branch: processing
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.10.1
Created-By: 1.8.0_152-b16 (Oracle Corporation)
Application-Name: Java Bindings for OpenGL
Specification-Title: Java Bindings for OpenGL API Specification
Specification-Version: 2.3
Specification-Vendor: JogAmp Community
Implementation-Title: Java Bindings for OpenGL Runtime Environment
Implementation-Version: 2.3.2
Implementation-Build: 2.3-bmanual-20180302