Skip to content

Instantly share code, notes, and snippets.

View davidraedev's full-sized avatar
💭
Busy Being Awesome

D davidraedev

💭
Busy Being Awesome
View GitHub Profile
@davidraedev
davidraedev / rpi_quickstart.py
Created October 5, 2015 17:00
RPi Python Quickstart for TheKnobleJosh
# a pretty good overview here
# http://openmicros.org/index.php/articles/94-ciseco-product-documentation/raspberry-pi/217-getting-started-with-raspberry-pi-gpio-and-python
# quick python overview
# indentation is important, things like loops MUST be indented and the first part ends with a colon
# for a in b:
# do something
@davidraedev
davidraedev / ino calc
Last active March 16, 2016 18:57
fixed functions for ino calc
<!doctype html>
<html>
<head>
</head>
<body>
<script>
var refinerations = 4502212239;
@davidraedev
davidraedev / gist:5539dfafb7903ff736b1d1430ad4aaf1
Created January 25, 2017 04:57
adafruit coupon days between
var dates = [
"2017-01-11",
"2017-01-04",
"2016-12-21",
"2016-12-07",
"2016-11-03",
"2016-10-27",
"2016-10-13",
"2016-09-22",
"2016-09-15",
@davidraedev
davidraedev / gist:7970d63ed6fec3cca3d0b58e85da2bbd
Created March 29, 2017 02:10
simple javascript ajax with exponential backoff (untested)
var timeout = {
initial: 10, // start backoff
backoff: 1.5, // backoff exponent
max: 5000, // maximum retry backoff
fail: ( 1000 * 60 * 3 ), // stop retrying after this time
loop: 0, // current number of tries
};
function getUrl( url ) {
if ( ! timeout.start )
// from https://en.wikipedia.org/wiki/List_of_typefaces_included_with_macOS
// 10.7-10.9
Al Bayan, American Typewriter, Andalé Mono, Apple Casual, Apple Chancery, Apple Garamond, Apple Gothic, Apple LiGothic, Apple LiSung, Apple Myungjo, Apple Symbols, .AquaKana, Arial, Arial Hebrew, Ayuthaya, Baghdad, Baskerville, Beijing, BiauKai, Big Caslon, Brush Script, Chalkboard, Chalkduster, Charcoal, Charcoal CY, Chicago, Cochin, Comic Sans, Cooper, Copperplate, Corsiva Hebrew, Courier, Courier New, DecoType Naskh, Devanagari, Didot, Euphemia UCAS, Fang Song, Futura, Gadget, Geeza Pro, Geezah, Geneva, Geneva CY, Georgia, Gill Sans, Gujarati, Gung Seoche, Gurmukhi, Hangangche, HeadlineA, Hei, Helvetica, Helvetica CY, Helvetica Neue, Herculanum, Hiragino Kaku Gothic Pro, Hiragino Kaku Gothic ProN, Hiragino Kaku Gothic Std, Hiragino Kaku Gothic StdN, Hiragino Maru Gothic Pro, Hiragino Maru Gothic ProN, Hiragino Mincho Pro, Hiragino Mincho ProN, Hoefler Text, Inai Mathi, Impact, Jung Gothic, Kai, Keyboard, Krungthep, Ku
@davidraedev
davidraedev / mountpoint.sh
Created June 24, 2017 10:45
mountpoint command for OSX
# OSX doesn't have a mountpoint command, or concise way to get that info
# this is a replacement for the mountpoint command, with the exception that it returns 2 instead of 1 for no argument
function mountpoint() {
# require a path
if [[ -z "$1" ]]; then
echo 'mountpoint requires a path as an argument';
echo 'ex. `mountpoint /mnt/some_disk`';
return 2;
@davidraedev
davidraedev / promise_loop.js
Last active July 25, 2017 08:44
promises with resolve inside a loop will resolve, but the loop will continue
function a() {
return new Promise( ( resolve, reject ) => {
let arr = [ 0,1,2,3,4,5 ];
let stop = false; // short circuit the loop
arr.forEach(( num ) => {
if ( stop )
return;
if ( num === 2 ) {
resolve( num );
stop = true;
@davidraedev
davidraedev / convert_to_mp3.sh
Created September 29, 2017 23:40
quick and dirty mp3 conversion with ffmpeg, multithreadable
#!/bin/bash
OUT='mp3/';
for FILE in *.mp4; do
if [ ! -f "$OUT$FILE".mp3 ]; then
ffmpeg -n -i "$FILE" -codec:a libmp3lame -qscale:a 0 "$OUT$FILE".mp3;
fi;
done;
@davidraedev
davidraedev / gist:9c0b51947f730ce56491e11158270967
Created November 10, 2017 02:43
subresource integrity hash, local and remote wget or curl
# local
echo 'sha384-'"$( cat FILENAME | openssl dgst -sha384 -binary | openssl enc -base64 -A )";
# wget
echo 'sha384-'"$( wget -o/dev/null -O- URL_HERE | openssl dgst -sha384 -binary | openssl enc -base64 -A )";
# curl
echo 'sha384-'"$( curl -s URL_HERE | openssl dgst -sha384 -binary | openssl enc -base64 -A )";