Skip to content

Instantly share code, notes, and snippets.

View monkstone's full-sized avatar

Martin Prout monkstone

View GitHub Profile
@monkstone
monkstone / config.cson
Created August 11, 2016 10:54
Atom-Runner configuration
"*":
...
'runner':
'scopes':
'coffee': 'coffee'
'js': 'node'
'ruby': 'jruby'
'python': 'python'
'go': 'go run'
@monkstone
monkstone / CodeListener.java
Created June 21, 2016 12:39
Code Listener in java
package org.monkstone;
import java.nio.file.WatchEvent;
interface CodeListener {
public void code_event(WatchEvent<?> event);
}
@monkstone
monkstone / pixellator.rb
Created June 15, 2016 13:35
Refined ruby pixellator
load_library :chooser
attr_reader :img, :data, :skip, :poster
###########
# Sophisticated example of file chooser.
###########
KEYS = %w(0 4 5 6 7 8 9)
def settings
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@monkstone
monkstone / extract.java
Created May 16, 2016 05:55
PApplet line 7475 or thereabouts
/**
* Return a full path to an item in the data folder as a File object.
* See the dataPath() method for more information.
*/
public File dataFile(String where) {
// isAbsolute() could throw an access exception, but so will writing
// to the local disk using the sketch path, so this is safe here.
File why = new File(where);
if (why.isAbsolute()) return why;
@monkstone
monkstone / blue_marble.rb
Last active May 11, 2016 06:23
Attempt to sequence loading of images
# Earth model with bump mapping, specular texture and dynamic cloud layer.
# Adapted from the THREE.js tutorial to processing by Andres Colubri,
# translated to JRubyArt by Martin Prout:
# http://learningthreejs.com/blog/2013/09/16/how-to-make-the-earth-in-webgl/
attr_reader :earth, :clouds, :earth_shader, :cloud_shader, :earth_rotation
attr_reader :clouds_rotation, :target_angle
IMAGES = %w(earthmap1k.jpg earthcloudmap.jpg earthcloudmaptrans.jpg earthbump1k.jpg earthspec1k.jpg).freeze
TEXTURES = %i(earth cloud alpha bump spec).freeze
@monkstone
monkstone / HCallback.java
Created April 25, 2016 13:10
Java8 Lambda with hype
package hype;
@FunctionalInterface
public interface HCallback {
public void run(Object obj);
}
@monkstone
monkstone / magnetic_field.rb
Last active April 20, 2016 12:01
magnetic_field.rb
load_library :hype
include_package 'hype'
module Hype
java_import 'hype.extended.layout.HGridLayout'
java_import 'hype.extended.behavior.HMagneticField'
java_import 'hype.extended.behavior.HSwarm'
end
attr_reader :pool, :pool_swarm, :field, :swarm
@monkstone
monkstone / MagneticField.java
Last active April 18, 2016 18:14
HYPE example translated for JRubyArt
/**
* Here is an example of a more tricky sketch to convert, first I exported to pure java (none that obfusctating processing
* crap), interestingly we can use a jdk8 lambda in place of a anonymous class for callback this is probably one way
* forward, although to be honest it may actually pay to create a JRuby extension to get more efficient operation.
*/
import processing.core.*;
import hype.*;
import hype.extended.layout.HGridLayout;
import hype.extended.behavior.HMagneticField;
@monkstone
monkstone / convert.rb
Last active April 3, 2016 06:09
Conver ruby-processing to propane
# convert.rb
VECLIBR = /\:(vecmath|fastmath)/
sketch = <<CODE
require 'propane'
class %s < Propane::App
%s
end