Skip to content

Instantly share code, notes, and snippets.

@benatwork
benatwork / machine.js
Created November 21, 2019 13:58
Generated by XState Viz: https://xstate.js.org/viz
// import { Machine, send } from 'xstate';
//----------------------------------------
const findingDevice = {
initial: 'findingDevice',
states: {
/* BASE STATES */
foundDevice: {
type: 'final',
@benatwork
benatwork / machine.js
Created November 18, 2019 15:38
Generated by XState Viz: https://xstate.js.org/viz
// import { Machine, send } from 'xstate';
//----------------------------------------
const findingDevice = {
initial: 'findingDevice',
states: {
/* BASE STATES */
foundDevice: {
type: 'final',
@benatwork
benatwork / machine.js
Last active October 22, 2019 14:57
Generated by XState Viz: https://xstate.js.org/viz
//----------------------------------------
const findingDevice = {
@benatwork
benatwork / machine.js
Last active October 21, 2019 15:20
Generated by XState Viz: https://xstate.js.org/viz
// const initDevice = {
// initial: 'readingServices',
// states: {
// readingServices: {
// on: {
// BT_READING_DEVICE_STATE: 'readingDeviceState',
// BT_DEVICE_READ_ERROR: 'readTimeout'
// }
// },
// readingDeviceState: {
// Restricts a number to the minimum/maximum
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
// Linear interpolation
function lerp(value, min, max) {
return min * (1 - value) + max * value;
}
### Keybase proof
I hereby claim:
* I am benatwork on github.
* I am b3nroth (https://keybase.io/b3nroth) on keybase.
* I have a public key ASB9OoIlPCq5vOw3DODbsAsyTMDOlsfI37qCSISyedSpNwo
To claim this, I am signing this object:
/**
* The Twitalinkahashifyer!
* http://www.dustindiaz.com/basement/ify.html
* Eg:
* ify.clean('your tweet text');
*/
ify: {
link: function(tweet) {
return tweet.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function(link, m1, m2, m3, m4) {
var http = m2.match(/w/) ? 'http://' : '';
@benatwork
benatwork / Round to increment
Created August 16, 2012 22:02
Round to increment
function roundToIncrement(originalNumber,increment) {
return Math.round( originalNumber / increment ) * increment;
}
@benatwork
benatwork / ffmpeg thumbnail generator
Created July 11, 2012 14:37
ffmpeg bash script to generate thumbnails for all videos in a folder
for f in *.mov; do ffmpeg -y -i "$f" -f image2 -ss 10 -vframes 1 -an "${f%.mov}.jpg"; done
@benatwork
benatwork / dabblet.css
Created January 16, 2012 16:16 — forked from trevorgerzen/dabblet.css
YouTube Footer Buttons
/*
YouTube Footer Buttons
*/
.button {
border: 1px solid #DDD;
border-radius: 3px;
text-shadow: 0 1px 1px white;
box-shadow: 0 1px 1px #fff;
font: bold 11px Sans-Serif;