Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Typing...

Spencer Bliven sbliven

💻
Typing...
View GitHub Profile
@sbliven
sbliven / vcd2mp4
Created Aug 3, 2020
Convert a VCD .dat file to .mp4 video
View vcd2mp4
#!/bin/bash
# usage: vcd2mp4 output.mp4 input.dat [input2.dat...]
if [[ $# -lt 2 ]]; then
echo "usage: $0 output.mp4 input.dat [input2.dat...]" >&2
exit 1
fi
output="$1"
shift
@sbliven
sbliven / timeout_fn.sh
Last active Jul 14, 2020
'timeout' command, implemented within the shell so that it works with shell functions
View timeout_fn.sh
#!/bin/zsh
# A version of the 'timeout' command that works with shell functions
#
# Usage:
# source timeout_fn.sh
# timeout_fn DURATION COMMAND [ARG]...
timeout_fn () {
local timeout=$1
shift
View animals.cpp
/* Solutions to https://stackoverflow.com/questions/800368/declaring-an-object-before-initializing-it-in-c/62247236#62247236
*
* Uses c++17 for some solutions
*
* Output:
*
* $ g++ --std=c++17 -o animals animals.cpp && ./animals
* Naive Method
* ------------
* Default Constructing Animal at 0x7ffee3fc20d0
@sbliven
sbliven / circular_types.py
Last active Sep 11, 2019
Test a difficult typing case. Python type annotations!
View circular_types.py
"""Test a difficult typing case.
Inspired by biopython's Bio.PDB.Entity.
https://gist.github.com/sbliven/8fb593f005eeafc0fecef71063f5dc39
"""
import sys
from typing import TypeVar, Union
View linelength.py
"""Create distribution of line lengths over files
Example:
find . -regextype egrep -regex './(Bio|Tests)/.*\.py' -type f -exec \
python linelength.py --hist linelengths.png \
--cdf linelengthscumulative.png -v '{}' '+'
"""
import sys
@sbliven
sbliven / google-authenticator.rb
Last active Mar 8, 2019 — forked from Dan-Q/google-authenticator.rb
Command-line Google Authenticator (TOTP)
View google-authenticator.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
# encoding: utf-8
#
# TOTP implementation (google authenticator)
#
# Reads ~/.google-authenticator-accounts for account info.
# For security, you should run `chmod 600 ~/.google-authenticator-accounts
#
# Changelog:
@sbliven
sbliven / test10.sh
Created Feb 6, 2019
Generate evenly-spaced heic file for testing Mac dynamic wallpapers
View test10.sh
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
JSONFILE="${1:-wallpapper.json}"
HEICFILE="${2:-wallpapper.heic}"
blocks=()
for ((a=-90;a<=90;a+=10)); do
for ((z=0; z<360; z+=10)); do
@sbliven
sbliven / Sync Calendars.scpt
Created Dec 17, 2018
Copies events between calendars in Apple Calendar.app
View Sync Calendars.scpt
-- Syncronize several calendars
--
-- The calendars to be synced must be set by UID in the 'targetCalendarIDs' variable.
-- UIDs can be read using the 'Get Calendar' script.
--
-- When run, copies each selected event to other calendars in the target list.
--
-- Author: Spencer Bliven (spencer.bliven@gmail.com)
--
-- Event selection code from http://www.johneday.com/1086/reference-selected-calendar-events-applescript
@sbliven
sbliven / LICENSE.md
Created Mar 28, 2018
ODC Public Domain Dedication and Licence (PDDL)
View LICENSE.md

ODC Public Domain Dedication and Licence (PDDL)

A lay explaination of this license is available at https://opendatacommons.org/licenses/pddl/summary/. The full legal text is also available online at https://opendatacommons.org/licenses/pddl/1.0/.

Preamble

The Open Data Commons – Public Domain Dedication & Licence is a document intended to allow you to freely share, modify, and use this work for any purpose and without any restrictions. This licence is intended for use on databases or their contents (“data”), either together or individually.

Many databases are covered by copyright. Some jurisdictions, mainly in Europe, have specific special rights that cover databases called the “sui generis” database right. Both of these sets of rights, as well as other legal rights used to protect databases and data, can create uncertainty or practical difficulty for those wishing to share databases and their underlying data but retain a limited amount of rights under a “some rights reserved” approach to licensing as

@sbliven
sbliven / Lunar Lander.ipynb
Last active Mar 6, 2018
Calculations for DanQ's Lunar Lander game (https://danq.me/2018/03/03/lunar-lander/)
View Lunar Lander.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.