Skip to content

Instantly share code, notes, and snippets.

View hrobeers's full-sized avatar

Hans Robeers hrobeers

View GitHub Profile
@hrobeers
hrobeers / bossManyToMany.erl
Last active December 20, 2015 18:09
Code to try many-to-many mapping with boss_db
Part = bossSandbox_part:new(id, "Part 1", "File 1", "Guid 1").
Asm = bossSandbox_assembly:new(id, "Assembly 1").
Part:save().
Asm:save().
P = boss_db:find_first(bossSandbox_part).
A = boss_db:find_first(bossSandbox_assembly).
Link = bossSandbox_partassembly:new(id, P:id(), A:id()).
Link:save().
@hrobeers
hrobeers / bossSandboxMockDB.erl
Last active December 20, 2015 20:49
Code to fill the bossSandbox mock DB
Part1 = part:new(id, "Part 1", "{file: 1}", "6fd84g3zx", erlang:now(), erlang:now()).
Asm1 = assembly:new(id, "Assembly 1", erlang:now(), erlang:now()).
{ok, P1} = Part1:save().
{ok, A1} = Asm1:save().
timer:sleep(1000).
Part2 = part:new(id, "Part 2", "{file: 2}", "s6d8fg7gr", erlang:now(), erlang:now()).
Asm2 = assembly:new(id, "Assembly 2", erlang:now(), erlang:now()).
{ok, P2} = Part2:save().
{ok, A2} = Asm2:save().
@hrobeers
hrobeers / gist:110db0a7d4e1a1c907c7
Created February 9, 2015 20:26
WriteStlToString
// Get the polyData object to write
vtkSmartPointer<vtkPolyData> polydata = polyData();
vtkSmartPointer<vtkSTLWriter> stlWriter =
vtkSmartPointer<vtkSTLWriter>::New();
#if VTK_MAJOR_VERSION <= 5
stlWriter->SetInput(polydata);
#else
stlWriter->SetInputData(polydata);
{"foil":{"history":[],"layerCount":6,"outline":{"area":0.0075541228622360655,"height":0.1,"path":[["M",0,0],["C",32.1909839,-63.06534,140.7988859,-227.155744,269.500718,-228.968964],["C",296.158458,-229.344534,336.987478,-220.894644,340.609098,-194.481404],["C",342.964838,-177.300378,269.209258,-156.23082,247.101578,-124.0841],["C",199.7571979,-55.2408,226.879918,-13,232.879918,0]],"sweep":0.72123963587739,"uuid":"{332b1de1-40b7-4b62-8b62-f261459d3144}"},"profile":{"symmetry":"Symmetric","thicknessRatio":1,"topProfile":{"cont":[0,1,0],"path":[["M",0,0],["C",-0.7973325173393278,-38.44668892785932,127.23264139117433,-73.35296904484017,361.0792383645382,-73.93534393137202],["C",712.9901941467928,-74.81174797400323,1207.8759716711122,-6.185557024727501,1235.6814732167798,0]]},"uuid":"{dd88cfd2-805e-4f23-beeb-24a3bd219028}"},"thick":0.01,"thickness":{"topProfile":[["M",0,-30],["C",0,-30,300,-30,300,0]],"uuid":"{31f91e08-b353-4d72-ae76-f642dca24898}"},"uuid":"{b3ea71cf-9d29-4037-9dd0-c5ee3b8e9b3c}"}}
// Parameters
length = 10;
rocker_curve = 3;
$fn = 100;
dia=length/PI;
include<rocker.scad>
// pic 11: intersect
@hrobeers
hrobeers / board.scad
Created October 22, 2015 07:42
Second attempt at using Malaroo's techique in OpenSCAD
// Parameters
length = 10;
rocker_curve = 3;
thick_rot = 7;
$fn = 100;
include<rocker.scad>
include<outline.scad>
//hexcut(5, 3, 10, 10);
module hexcut (radius, depth, height, width) {
for (i = [0:ceil(height/(radius*2))]) {
for (j = [0:ceil(width/(radius*2))]) {
x = i*radius*2;
y = j*radius*1.75;
translate([x+(j%2*radius),y,0])
rotate([0,0,30])
@hrobeers
hrobeers / json_float_precision.cpp
Last active November 15, 2015 10:02
reduce json floating point precision to reduce size
// reduce json floating point precision to reduce size
#include <iostream>
#include <string>
#include <regex>
#include <vector>
const std::string foil = "{\"foil\":{\"history\":[],\"layerCount\":6,\"outline\":{\"area\":0.0094394211977858536,\"height\":0.10000000000000001,\"path\":[[\"M\",0,0],[\"C\",-0.8090161000000009,-1.065339999999992,146.79888589999996,-14.155744000000027,159.50071800000001,-92.968964000000028],[\"C\",328.158458,-105.34453400000007,441.98747800000001,-231.89464399999997,445.60909800000002,-144.481404],[\"C\",340.96483799999999,-107.30037800000002,411.20925799999998,-72.230819999999994,411.10157800000002,-73.084100000000007],[\"C\",173.75719790000005,-73.240800000000007,353.8799179999998,-1,353.87991799999986,0]],\"sweep\":0.96055560932291262,\"uuid\":\"{76d2a5ae-8d14-4617-8b6a-122401df6f20}\"},\"profile\":{\"botProfile\":[[\"M\",0,0],[\"C\",0,0,-26,69,114,34],[\"C\",91,9,300,0,300,0]],\"symmetry\":\"Asymmetric\",\"thickness\":0.01,\"thicknessRatio\":1.0249374147947978,\"topProfile\":[[\"
@hrobeers
hrobeers / gist:214b2a7199875c477f13f48e5f675c4a
Last active February 3, 2021 10:39
Generate compressed and uncompressed bitcoin addresses from a private key with bitcore.
var bitcore = require("bitcore-lib");
var Buffer = require("buffer").Buffer;
var value = new Buffer.from("test", "utf8");
var hash = bitcore.crypto.Hash.sha256(value);
// Compressed Key (nu skool)
var bn = bitcore.crypto.BN.fromBuffer(hash);
var privateKey = new bitcore.PrivateKey(bn);
@hrobeers
hrobeers / fork-watch.py
Created July 14, 2017 07:34
Prints the percentage of version 2 blocks in last 100 blocks
#! /usr/bin/python3
from peercoin_rpc import Client
number_of_blocks = 100
ppcnode = Client(testnet=True, username="testnet", password="testnetpw", ip="localhost", port=8888)
last_block_hash = ppcnode.getblockhash(ppcnode.getblockcount())
block_versions = []