Skip to content

Instantly share code, notes, and snippets.

@optilude
optilude / _app.js
Last active March 25, 2024 15:05
Pattern for accessing a Feathers client via a React context hook
import React, { useState, useEffect } from 'react';
import { FeathersContext, createFeathersClient } from '../feathersClient';
/**
* Top level app wrapper which does a few things:
*
* - Ensure the feathers context is set up, so that pages can just `useFeathers()` to get a client.
* - Listen for login/logout events and pass a `user` prop to pages which is either `null`, or a user object.
*/
@optilude
optilude / find-cpu-hogs.sh
Created March 15, 2020 20:09
Capture processes with significant CPU usage (Bash shell script)
#!/bin/bash
# Output CSV-formatted statistics about each process using > ${threshold}% CPU,
# sampling every ${delay} seconds. Assume we'll find them in the top ${max}
# processes returned by `top` sorting by CPU usage.
threshold=${1:-5}
delay=${2:-5}
max=${3:-25}
2019-05-23 23:01:45 DEBUG (SyncWorker_2) [pyaarlo] starting
2019-05-23 23:01:45 DEBUG (SyncWorker_2) [pyaarlo] starting request=https://arlo.netgear.com/hmsweb/login/v2
2019-05-23 23:01:46 DEBUG (EventStream) [pyaarlo] starting event loop
2019-05-23 23:01:46 DEBUG (EventStream) [pyaarlo] starting stream with no timeout
2019-05-23 23:01:46 INFO (SyncWorker_2) [pyaarlo] pyaarlo starting
2019-05-23 23:01:46 DEBUG (SyncWorker_2) [pyaarlo] starting request=https://arlo.netgear.com/hmsweb/users/devices
2019-05-23 23:01:47 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/deviceId=5EX184SH25B77
2019-05-23 23:01:47 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/deviceName=Back
2019-05-23 23:01:47 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/deviceType=camera
2019-05-23 23:01:47 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/mediaObjectCount=718
2019-04-28 17:17:33 DEBUG (SyncWorker_2) [pyaarlo] starting
2019-04-28 17:17:33 DEBUG (SyncWorker_2) [pyaarlo] starting request=https://arlo.netgear.com/hmsweb/login/v2
2019-04-28 17:17:34 DEBUG (EventStream) [pyaarlo] starting event loop
2019-04-28 17:17:34 DEBUG (EventStream) [pyaarlo] starting stream with no timeout
2019-04-28 17:17:34 INFO (SyncWorker_2) [pyaarlo] pyaarlo starting
2019-04-28 17:17:34 DEBUG (SyncWorker_2) [pyaarlo] starting request=https://arlo.netgear.com/hmsweb/users/devices
2019-04-28 17:17:34 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/deviceId=5EX184SH25B77
2019-04-28 17:17:35 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/deviceName=Back
2019-04-28 17:17:35 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/deviceType=camera
2019-04-28 17:17:35 DEBUG (SyncWorker_2) [pyaarlo] set:5EX184SH25B77/mediaObjectCount=98
@optilude
optilude / arlobackup.py
Created September 30, 2018 20:23
Arlo backup (Python 2.7)
import sys
import os
import logging
import argparse
import datetime
from datetime import timedelta, date
from Arlo import Arlo
@optilude
optilude / example.js
Last active January 1, 2017 23:11
Helper for JS-XLSX (https://github.com/sheetjs/js-xlsx) to read tables with named columns into a data structure that is easy to work with.
function doSomething(workbook) {
let { sheet, range } = findSheet(workbook, "Invoices");
if(sheet === null) {
return null;
}
let { columns, firstRow } = findTable(sheet, range, {
name: "Person name",
Everybody's doin' a brand new dance now
(C'mon baby do the vmotion)
I know you'll get to like it
If you give it a chance now
(C'mon baby do the vmotion)
My little baby sister can do it with ease
It's easier than learning your a be see's
So come on, come on,
Do the vmotion with me
You gotta swing your hips now
↪ meteor
[[[[[ ~/Build/JavaScript/simon/app ]]]]]
=> Started proxy.
=> Started MongoDB.
=> Meteor 1.4.1.1 is available. Update this project with 'meteor update'.
Warning: unable to resolve "es2015" in presets of /Users/maraspeli/Build/JavaScript/simon/app/.babelrc
Warning: unable to resolve "transform-class-properties" in plugins of /Users/maraspeli/Build/JavaScript/simon/app/.babelrc
Warning: unable to resolve "transform-decorators-legacy" in plugins of /Users/maraspeli/Build/JavaScript/simon/app/.babelrc
@optilude
optilude / weibull_estimate.py
Last active March 2, 2022 15:57
Kanban lead time weibull distribution estimator
import numpy as np
def weibull_estimate(min_, max_, shape=1.25):
"""Draw a random number between min_ and max_ using a Weibull
distribution with shape `shape`.
Thanks to Troy Magennis for the inspiration!
"""
return min(max_, ((max_ - min_) / 4.0) * np.random.weibull(shape) + min_)
<div class="container header">
<div class="main">
<a id="logo" href="/">
{{#avatar}}
<img class="avatar {{#roundAvatar}}rounded{{/roundAvatar}}" src="{{avatar}}" alt="{{name}}'s avatar"/>
{{/avatar}}
{{title}}
</a>
<div class="nav">
<a href="/" title="Home">Home</a>