View 7segscroll.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TM1637.h> | |
// | |
// This is just some mish-mash of a bunch of things but it's posted for the video over here: | |
// https://youtu.be/JN4j-aCagH0 | |
// | |
// How you set the date: | |
// exec 3<> /dev/ttyUSB0 | |
// printf "$(date "+obase=16;4096+(%H*60+%M)" | bc | sed -E s'/(..)/\\x\1/g')" > /dev/ttyUSB0 | |
// exec 3<&- |
View plug.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import pyemvue as pyem, json, sys | |
with open('keys.json') as f: | |
data = json.load(f) | |
v = pyem.PyEmVue() | |
v.login(id_token=data['id_token'], | |
access_token=data['access_token'], | |
refresh_token=data['refresh_token'], | |
token_storage_file='keys.json') |
View top-10-slow.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a very crazy 1-liner that only uses builtins | |
#set -o noglob;declare -a mapper=() count=();exec 3<access.log; while read -a lines -u 3; do [[ ${lines[5]} != '"GET' ]] && continue; page="${lines[6]}"; ix=0;for i in "${mapper[@]}"; do [[ "$page" = "$i" ]] && break; (( ix++ )); done ; if [[ "$page" = "$i" ]]; then (( count[$ix] ++ )); else mapper+=( $page ); count[$ix]=1; fi; done; (( max=-1, winner=-1, show=10 )); while (( show > 0 )); do ix=0;for i in "${count[@]}"; do (( i > max )) && (( max=i, winner=ix )) ;(( ix++ ));done; builtin echo -e "${count[winner]}\t${mapper[$winner]}";(( count[$winner]=-1, max=0, show-- )); done; | |
# Here's a formatted nice version | |
# We need to make sure that bash doesn't do weird substitution | |
set -o noglob | |
declare -a mapper=() count=() | |
# And to avoid cat we do file descriptors | |
exec 3<access.log |
View animal-say.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cat << ENDL | |
- - - ~ ~~~~==~#=###=#~==~~~~~ ~ - - - | |
$(fortune | sed -E 's/^\s+//g' | fold -sbw 40 | sed -E 's/^/ /') | |
- - - ~ ~~~~==~#=###=#~==~~~~~ ~ - - - | |
$(curl -s https://9ol.es/animals.db | shuf -n 1 | tr 'F' '\n' | gawk ' { if (FNR == 1) { printf " \\ ";} else if (FNR == 2) { printf " \\ "; } else { printf " " }; print $0 } ';) | |
ENDL |
View simple-datepicker-react.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is more a guide than working code. | |
constructor(props) { | |
super(props); | |
let minimum_age = 21; | |
this.endyear = (new Date().getYear() + 1900) - minimum_age; | |
this.state = { | |
dob_year: this.endyear, | |
dob_month: 0 |
View generate-words.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Here's the prompt: | |
# | |
# Construct a "word search" N x M letter grid where: | |
# | |
# * There are NO possible words horizontal or vertical | |
# * The letters appear random with no trivial patterns | |
# * The frequency distribution of letters is close to English prose | |
# | |
# This is a naive implementation |
View transp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
def encode(plain): | |
plain = list(plain) | |
cypher = '' | |
while len(plain) > 0: | |
# Roll a die, add 3 to the result | |
step = random.randint(4,9) | |
# start at the beginning of the remaining string |
View gist:d3211dfb395bbb922fee14665dd941cb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# /etc/init.d/xdm: Login Procedure for Bob480 | |
# Edited Sept-2001; Contact Author: cjm@ucdavis.edu | |
n=$1 | |
n=$n"." | |
[ $n == "stop." ] && exit | |
moveon=0 | |
set PATH="/bin:/usr/bin:/sbin" |
View process.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import png | |
import os | |
import numpy as np | |
import json | |
import math | |
import time | |
import random |
View gist:40943f2babfcaa6fdb48953192fb352b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import png | |
from pprint import pprint | |
cx = 0 | |
width = 4000 | |
height = 4000 | |
image = [ [ 0 for y in range ( width ) ] for x in range( height ) ] |
NewerOlder