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 / test.json
Created June 27, 2019 09:25
test_json
[
{
"id": 0,
"hash": "853644d7-12d3-4378-b329-aed939ff5a48",
"title": "ea adipisicing quis veniam eiusmod fugiat",
"description": "Culpa ullamco laborum deserunt reprehenderit sit aute amet. Esse nisi minim dolore laboris occaecat adipisicing anim adipisicing velit id aliquip est commodo. Eu excepteur amet consequat sint. Ullamco reprehenderit irure culpa cupidatat minim excepteur fugiat occaecat ex esse consequat.\r\n"
},
{
"id": 1,
"hash": "967919fc-735f-4851-a505-4c2b817e7582",
@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);
}
@pau1m
pau1m / accounts.ts
Created June 15, 2018 07:41
Ethereum account generation from seed
const Web3: any = require('web3'); // tslint:disable-line:variable-name
const bip39: any = require('bip39');
const hdkey: any = require('ethereumjs-wallet/hdkey');
const web3: any = new Web3();
export class Accounts {
private seed: string;
constructor(seed: string) {
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 / createDefaultAccounts.js
Created November 15, 2017 11:15
Handy script for generating Ethereum accounts (json files) from Mnemonic
//const argv = require('minimist')(process.argv.slice(2));
const Web3 = require("web3")
let web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
console.log(web3)
let bip39 = require("bip39")
let hdkey = require('ethereumjs-wallet/hdkey')
let mnemonic = "weather cancel symptom owner lumber bitter bread butter dice trial shrug glance"
let hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic))
// Set to m/44'/60'/0' for ledger nano s hardware wallet compatibilty
0x5432a7a0d8b228166f41f305942ffbfed97bb2d8
0x34e8D99893CcA9a593D905fb9aB07E1E20C0157D
0x1313734d2d6625173278978ddaa7b63400462745