Skip to content

Instantly share code, notes, and snippets.

View sbliven's full-sized avatar
💻
Typing...

Spencer Bliven sbliven

💻
Typing...
View GitHub Profile
@sbliven
sbliven / darkmode
Last active November 20, 2024 08:01
Script to toggle dark mode on and off on MacOS
#!/bin/bash
# usage: darkmode [dark|light]
set -euo pipefail
shopt -s nocasematch
if [[ $# > 0 ]]; then
# mode given
case "$1" in
dark)
@sbliven
sbliven / gh_title.js
Last active October 24, 2024 12:46
Custom function for the Obsidian Templater plugin (https://github.com/SilentVoid13/Templater/) to convert a github issue URL to a link with the issue title. Only works for public repos.
async function getGitHubIssueTitle(owner, repo, issueNumber) {
const url = `https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}`;
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Error fetching issue: ${response.status}`);
}
const issueData = await response.json();
@sbliven
sbliven / index.html
Created August 20, 2024 19:33
Websafe color filter
<!--
SVG filter to make your images look like its 1999!
(Hi Dan!)
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 160">
<defs>
<linearGradient id="rainbow" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="100%" y2="0">
<stop offset="0" stop-color="#ff0000"></stop>
<stop offset="0.2" stop-color="#ffff00"></stop>
@sbliven
sbliven / Automata.ipynb
Created May 2, 2024 08:57
Explore 1D Cellular Automata in python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sbliven
sbliven / handlebar-demo.ts
Created October 25, 2023 08:03
Initial draft for job configuration schema
const Handlebars = require('handlebars');
const json = {
job: {
pids: ["10/1","10/2","10/3"],
owner: "bliven_s",
status: "SUCCESS"
},
secrets: {
jwt_token: "8AK820="
@sbliven
sbliven / 1_to_1_scale.ipynb
Created April 17, 2023 23:14
SVG images for XKCD "1-to-1 scale" https://xkcd.com/2761/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sbliven
sbliven / restore_pb.sh
Created December 7, 2022 22:11
Karabiner Elements script to use Fn-<key> for emojis and unicode
#!/bin/zsh
# Restores the clipboard after running unicode_fn.sh
export LC_ALL='en_US.UTF-8'
export LANG='en_US.UTF-8'
sleep .1
pbpaste -pboard ruler | pbcopy
@sbliven
sbliven / TimeDistToZurich.csv
Last active August 11, 2021 12:35
driving distance around zurich (in minutes)
lon lat duration
8.5215272410261 47.3957616953417 0
8.371835 47.24679 31.235
8.371027 47.250516 29.9966666666667
8.372975 47.255491 29.2833333333333
8.37146 47.260156 28.6333333333333
8.372376 47.264277 29.7183333333333
8.369903 47.269002 33.515
8.371152 47.274843 31.0783333333333
8.371162 47.280342 27.5366666666667
import shapefile
def replace_escape(s):
return s.replace(b'\xc3\x82\xc2',b'\xc2').replace(b'\xc3\x83\xc2',b'\xc3')
sf = shapefile.Reader("swisscantonsmod/ch-cantons.dbf")
print(f"records: {len(sf.records())}")
print(f"shapes: {len(sf.shapes())}")
out = shapefile.Writer("swisscantonsmod/ch-cantons_fixed.dbf")
for f in sf.fields:
@sbliven
sbliven / mysettings.ini
Last active April 22, 2021 21:39
Improved version of sbliven/d413c2f2f4af3bf56e13d1f8656751b1 using configparser
[nlsa] |~
name = Custom Settings |~
x = 4 |~