Skip to content

Instantly share code, notes, and snippets.

View craftoid's full-sized avatar

Martin Schneider craftoid

View GitHub Profile
@craftoid
craftoid / machine.js
Created October 19, 2020 19:01
Generated by XState Viz: https://xstate.js.org/viz
const onetwothree = Machine({
id: 'modulo three',
initial: 'one',
states: {
one: {
on: {
inc: 'two',
dec: 'three'
}
@craftoid
craftoid / function-node.js
Last active June 22, 2020 01:09
Payload for multipart/form posts using the Node-RED request node
msg.headers = {
"Content-Type": "multipart/form-data"
};
msg.payload = {
'image' : {
'value': msg.payload,
'options': {
'filename': 'image.jpg'
}
let FormData = require('form-data');
let fs = require('fs');
let form = new FormData();
form.append('image', fs.createReadStream('/tmp/image.jpg'));
form.submit('http://max-image-resolution-enhancer.codait-prod-41208c73af8fca213512856c7a09db52-0000.us-east.containers.appdomain.cloud/model/predict', function(err, res) {
if (err) throw err;
res.pipe(fs.createWriteStream('/tmp/scaled.png'));
});
@craftoid
craftoid / welcome-to-machine-learning-with-colaboratory.ipynb
Created April 28, 2020 12:03
Welcome to Machine Learning with Colaboratory
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@craftoid
craftoid / index.html
Created July 12, 2017 18:34
Resizable DIV
<!DOCTYPE html>
<!--
resizable div // simulating a resizable window // bitcraftlab 2017
-->
<html>
@craftoid
craftoid / thue_morse_folding_3.pde
Created October 6, 2016 23:19
Yet another turtlewalk of the Thue-Morse Sequence, creating the Koch-Curve.
// @bitcraftlab 2016
boolean animate = true;
int dir = 1;
int iter = 5;
int n = 0;
int steps;
void setup() {
@craftoid
craftoid / thue_morse_folding_2.pde
Created October 6, 2016 23:16
Another turtlewalk based on the Thue-Morse-Sequence
// @bitcraftlab 2016
boolean animate = true;
int dir = 1;
int iter = 5;
int n = 0;
int steps;
void setup() {
@craftoid
craftoid / thue_morse_folding.pde
Created October 6, 2016 23:14
A Turtlewalk based on the Thue-Morse-Sequence
// @bitcraftlab 2016
boolean animate = true;
int dir = 1;
float a = PI/3;
int iter = 5;
int n = 0;
int steps;
@craftoid
craftoid / binary_digit_folding.pde
Created October 6, 2016 16:40
Turtlewalk made from the Binary Digits of consecutive Numbers.
// @bitcraftlab 2016
import processing.pdf.*;
int iter = 6;
int steps = 1 << (2 * iter);
float d = 2048.0 / steps;
float a = PI/2;
@craftoid
craftoid / Download_Vera_Molnar.pde
Created December 8, 2015 13:32
a litte script to download and view the images of the fantastic Vera Molnar without flash...
// a litte script to download and view the images
// of the fantastic Vera Molnar without flash...
String domain = "http://www.veramolnar.com";
String output = "images";
for (int year = 1939; year <= 2012; year++) {
// download xml file
String[] lines = loadStrings(domain + "/xml/" + year + ".xml");