Skip to content

Instantly share code, notes, and snippets.

View hackergrrl's full-sized avatar
🌱

Kira Oakley hackergrrl

🌱
View GitHub Profile
#!/bin/bash
# bail if no semver is given
if [ $# -eq 0 ]; then
echo 'USAGE: npp patch|minor|major'
exit 1
fi
# ensure all deps are present
# XXX: depends on "npm i -g dependency-check" being installed
/**
* @param {Number} px - Player X
* @param {Number} py - Player Y
* @param {Number} pvx - Player Velocity-X
* @param {Number} pvy - Player Velocity-Y
* @param {Number} tx - Turret X
* @param {Number} ty - Turret Y
* @param {Number} ts - Turret Projectile Speed
**/
function getProjVel (px, py, pvx, pvy, tx, ty, ts) {
@hackergrrl
hackergrrl / index.html
Created July 28, 2020 18:29
Voice recognition in the browser with webkitSpeechRecognition (chrom{e,ium} only)
<body>
<p class="output">output will appear here</p>
</body>
<script>
var recognition = new webkitSpeechRecognition();
// use a pre-defined grammar
//var grammar = '#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | linen | magenta | maroon | moccasin | navy | olive | orange | orchid | peru | pink | plum | purple | red | salmon | sienna | silver | snow | tan | teal | thistle | tomato | turquoise | violet | white | yellow ;'
//var speechRecognitionList = new webkitSpeechGrammarList();

mapeo sync

current mechanism

PEER                                                          PEER
 ||                                                            ||
 ||------- handshake offer ----->                              ||
 ||                                                            ||
 ||                                 <----- handshake offer ----||
// example of using 'hypercore-sync-partial-feeds' module
var Sync = require('hypercore-sync-partial-feeds')
var Corestore = require('corestorage')
var cores1 = new Corestore(ram)
var cores2 = new Corestore(ram)
// TODO: populate cores
@hackergrrl
hackergrrl / notes.md
Last active October 26, 2019 16:37
thinking about upgrades & versioning

upgrades & versioning

  • there are two rough stages of software that come to mind:
    1. given an experimental/in-dev tool, you'd want a community that cares about the tech & is sufficiently excited about it & tolerant/forgiving enough of bugginess. in this case, frequent breakages and upgrades are reasonable
    2. if a community wants a tool that "just works", a stable tool is best. a tool that's mature enough that it basically NEVER needs to be updated again after the initial install, and even if upgraded, are just bug fixes that don't break any compatibility in the data or protocol layers
  • Mapeo is in category 1, but is often being deployed in category 2 situations, which seems like a recipe for disappointment & frustration. expecting an immature tool to be a mature tool is going to be frustrating
  • ideally we'd do our best to maintain backwards compatibility, but it's worth considering how frequent breaking changes are,
  • i.e. if we release a data/proto breaking change every 3-5 months, it doesn't make
@hackergrrl
hackergrrl / corestorage.js
Last active October 30, 2019 20:41
corestorage api
let store = corestore('my-storage-dir' || ram() || webstore())
// Map a discovery key or local-name to a key.
store.keyFromDiscoveryKey(discoKey, cb)
store.keyFromLocalName('my-feed', cb)
// Create a new hypercore, which can include a local name. (creates + loads)
let core = store.create('localname', { valueEncoding: 'utf-8' })
core.ready(cb)

why I publish to npm + don't publish to my distro package manager

re: https://drewdevault.com/2018/01/10/Learn-your-package-manager.html

  • needs human effort to {write,modify} the package per distro, per update
    • do the write/update
    • someone working on the distro to review the work & merge it
  • need to wait until next release for people to use the package/update
    • need to maintain a private pkg server (per distro; or just fuck the others)
  • does my pkg then depend on distro pkgs or npm ones?
var stream = require('stream')
module.exports = function (id) {
// opts.allowHalfDuplex is _very_ important! Otherwise ending the readable
// half of the duplex will leave the writable side open!
var counter = new stream.Duplex({allowHalfOpen:false})
counter.processed = []
var payloadsLeft = 3
var sha = require('sha.js')
var umkv = require('unordered-materialized-kv')
var EventEmitter = require('events').EventEmitter
module.exports = ContentAddressableStore
function ContentAddressableStore (db, opts) {
var kv = umkv(db)
var events = new EventEmitter()
opts = opts || {}