Skip to content

Instantly share code, notes, and snippets.

View BrianRossmajer's full-sized avatar

Brian Rossmajer BrianRossmajer

View GitHub Profile
@BrianRossmajer
BrianRossmajer / support.js
Created January 1, 2023 16:50
Support V4
const jscad = require('@jscad/modeling')
const { torus, cuboid, roundedCuboid, cylinder } = jscad.primitives
const { translate, translateX, scale, rotate, rotateY, rotateZ } = jscad.transforms
const { measureDimensions, measureCenter } = jscad.measurements
const { union, intersect, subtract } = jscad.booleans
const { hull } = require('@jscad/modeling').hulls
const getParameterDefinitions = () => [
{ name: 'body', type: 'group', caption: 'Visible Body' },
{ name: 'bulkHeight', type: 'float', initial: 14, min: 10, max: 100.0, step: 1, caption: 'Visible body height:' },
@BrianRossmajer
BrianRossmajer / support.js
Last active December 23, 2022 01:18
experimenting with openjscad.xyz
const jscad = require('@jscad/modeling')
const { torus, cuboid, roundedCuboid, cylinder } = jscad.primitives
const { translate, translateX, scale, rotate, rotateY, rotateZ } = jscad.transforms
const { measureDimensions, measureCenter } = jscad.measurements
const { union, intersect, subtract } = jscad.booleans
const { hull } = require('@jscad/modeling').hulls
const getParameterDefinitions = () => [
{ name: 'body', type: 'group', caption: 'Visible Body' },
{ name: 'bulkHeight', type: 'float', initial: 14, min: 10, max: 100.0, step: 1, caption: 'Visible body height:' },
@BrianRossmajer
BrianRossmajer / setup-pi-mqtt-rfid-keyboard-wedge-gateway.sh
Last active March 2, 2022 14:26
TinyCore Raspberry Pi minimal USB RFID reader or USB barcode reader to MQTT gateway
# Have an old Pi that would corrupt its SD cards with normal Pi OS's, so used TinyCore linux for pi instead
# which only writes to SD card when you run `filetool.sh -b` ... basically it's become more like a
# embedded microcontroller that posts to MQTT when a tag or barcode is scanned.
# after following the tinycore pi setup instructions and getting its networking going, I
tce-load -wi ntp
tce-load -wi perl5
tce-load -wo cpanm
echo /usr/local/bin/ntpdate time.chu.nrc.ca >> /opt/bootlocal.sh
echo /usr/local/bin/ntpd >> /opt/bootlocal.sh
@BrianRossmajer
BrianRossmajer / gist:f3c01ad2eff1dc23f17fc9b5c3de2df8
Last active January 3, 2019 21:01
Find the newest file in a subdirectory tree
perl -MFile::Find -e 'sub w{my $t=(stat _)[9];if ( -f _ && $t>$newest){ $newest=$t;$file=$File::Find::name;}} find(\&w,(shift or ".")); print $file," ",$newest;' <dir>
@BrianRossmajer
BrianRossmajer / gist:e82e9944d2b246587be4baa9aeac3b98
Created December 26, 2017 14:48
Using sshfs high-speed no-encryption
http://pl.atyp.us/wordpress/index.php/2009/09/file-transfer-fun/
File Transfer Fun
17 September, 2009 8:32 am
I’ve written before about the extreme usefulness of sshfs for accessing files remotely without having to install server software. It continues to be an important part of my toolbox, as does its cousin CurlFtpFS which – unlike sshfs – I can even use to mount a directory here on my web host. Of course, either becomes even more useful when combined with some easy method of synchronization. You probably have rsync already. You can also use Unison if you need bidirectional synchronization – which you generally will if you’re trying to use a single directory somewhere as a “drop box” to share between multiple machines.
I just found another sshfs trick today. If the connection between your two machines is already secure – e.g. on the same private network or connected via a secure VPN/tunnel – you might want to avoid an extra round of encryption and decryption by using the “-o directport” option to sshfs. T
@BrianRossmajer
BrianRossmajer / gist:5906386
Last active December 19, 2015 05:48
This gist tests if a bzip file is complete. Since bzip2 --test actually decompresses the file (it's a real file test) it takes time and CPU. This shell snippet just looks for the bzip2 end-of-stream marker (See http://en.wikipedia.org/wiki/Bzip2#File_format). This was helpful when I was rsync'ing a directory of large bzip2 files over an unreliab…
tail -c 12 filename.bz2 |od -t xC| sed 's/ //g' | grep -q -E '2ee48a70a120|177245385090|5dc914e14240|bb9229c28480'