Skip to content

Instantly share code, notes, and snippets.

@pau1m
pau1m / svg2scad.py
Created October 11, 2024 20:39 — forked from phrz/svg2scad.py
Converts SVG path notation to OpenSCAD polygon(): supports M,L,C,Z with Bézier interpolation to points.
import string
from collections import OrderedDict
from itertools import count
# precision of output points
decimals = 2
svg = '''M0,0 L66,0 L66,140 L0,140 L0,0 Z M17.5356193,9.91374504 L7.89629934,9.91374504 L7.89629934,34.6390567 L13.9842872,34.6390567 L13.9842872,27.741635 L17.6136633,27.741635 C21.6461094,27.741635 24.6445573,27.0341777 26.6090071,25.619263 C28.5734569,24.2043483 29.555612,21.9699927 29.5554723,18.9161962 C29.5554723,15.8625389 28.5993435,13.5986987 26.687086,12.1246754 C24.7748285,10.6511862 21.7243396,9.91420937 17.5356193,9.91374504 Z M51.2530562,20.2426569 L40.4040722,20.2426569 L40.4040722,9.91374504 L34.3159446,9.91374504 L34.3159446,34.6392308 L40.4040722,34.6390567 L40.4040722,24.9118057 L51.2530562,24.9118057 L51.2530562,34.6392308 L57.3411838,34.6392308 L57.3411838,9.91374504 L51.2530562,9.91391916 L51.2530562,20.2426569 Z'''
def string_to_point_tuple(s):
@pau1m
pau1m / README.md
Created February 20, 2019 12:35 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@pau1m
pau1m / react-form-set-state-input-and-submit.js
Created December 28, 2018 13:48 — forked from stowball/react-form-set-state-input-and-submit.js
React. Form with dynamic inputs that setState for values and submit
class Form extends Component {
state = {};
renderInput = (name, type, value='') =>
<input onChange={({target}) => this.setState({[name]: target.value})} name={name} type={type} value={this.state[name] || value}/>;
handleSubmit = (evt) => {
evt.preventDefault();
send('/form', this.state);
}
const fs = require('fs')
const Tx = require('ethereumjs-tx')
const ledger = require('ledgerco')
const Web3 = require('web3')
const rlp = require('rlp');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8585"))
const metacoinJSON = require('./build/contracts/MetaCoin.json')
const bytecode = metacoinJSON.unlinked_binary
const ownerAddress = fs.readFileSync('./owner.addr', 'utf8').toString()
@pau1m
pau1m / gist:aa09497e819de410196f
Last active August 29, 2015 14:28 — forked from dustincurrie/gist:938829
Programmatically create quicktabs
<?php
function mymodule_block($op = 'list', $delta = 0, $edit = array()) {
switch($op) {
case 'list':
$blocks['mymodule_quicktabs'] = array('info' => t('[mymodule] Quicktabs'));
return $blocks;
break;
case 'view':
switch ($delta) {
@pau1m
pau1m / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
/**
* Implements hook_menu().
*/
function mymodule_menu() {
$items['mymodule/%ctools_js/add'] = array(
'page callback' => 'mymodule_node_add_modal_callback',
'page arguments' => array(1),
'access arguments' => array('access content'),
@pau1m
pau1m / index.js
Created December 29, 2012 12:16 — forked from GothAck/index.js
#!/usr/bin/env node
/*
* Parsing BIG compressed data with Node.js and SAX
* Probably some bugs, but worked fine for OpenStreetMap Great Britain bz2
* Greg Miell 2012
*/
// Simple string trim prototype extension
String.prototype.trim = function() {