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
import Colors | |
using DataStructures | |
using ImageSegmentation | |
using LightGraphs | |
using MetaGraphs | |
# idea from https://vcansimplify.wordpress.com/2014/08/17/hierarchical-merging-of-region-adjacency-graphs/ | |
function _weight_mean_color(data::MetaGraph, n1::Int, n2::Int)::Real | |
# Determine weight of an edge between n1 and n2 |
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
from skimage import io | |
import argparse | |
import glob | |
import numpy as np | |
import os | |
def make_frames(files, outdir, n=8, prefix="composite"): | |
split = int(len(files) / n) | |
pathstart = os.path.join(outdir, prefix) |
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
function history() | |
map(sort(collect(keys(IJulia.In)))) do k | |
println(k, ": ", IJulia.In[k]) | |
end; | |
return Nothing; | |
end |
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
function super(a) | |
local t | |
try | |
t = supertype(a) | |
catch | |
t = typeof(a) | |
end | |
if t == a |
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 | |
# Adapted from https://stackoverflow.com/questions/6118948/bash-loop-ping-successful. | |
# Network connection mysteriously dies; ping every N seconds, and if ping fails | |
# turn wifi off and on again, which seems to fix it. | |
echo "run this script with sudo!" | |
echo "Starting ..." | |
DOWN=0 | |
while true; do |
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
# forked from https://gist.github.com/bradp/bea75b16d3325f5c47d4 | |
# usage: | |
# 1) attach ssd to old machine and start running backup.sh | |
# 2) grab the latest version of this file from | |
# https://gist.github.com/jsundram/eeca472a8929bfab27209783b16bd6d9 | |
# 3) copy this script onto the new machine and start running it | |
# sh setup.sh | |
# you will need to add homebrew to your .zprofile path | |
# PATH=$PATH:/opt/homebrew/bin | |
# echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zprofile |
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
from datetime import datetime, timedelta | |
import random | |
import matplotlib.pyplot as plt | |
import matplotlib.dates as dates | |
def make_data(): | |
random.seed(0) # Make it repeatable | |
s = datetime(2020, 1, 1) # Pick a leap year! |
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
from collections import defaultdict | |
import networkx as nx | |
import string | |
import matplotlib.pyplot as plt | |
def get_words(filename='/usr/share/dict/words'): | |
d = defaultdict(set) | |
with open(filename) as f: | |
for line in f: |
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
""" | |
Takes a Met Opera json file and parses it and then writes a .inf file suitable for creating video chapters. | |
ffmpeg -i opera.mp4 -i opera.json.inf -map_metadata 1 -codec copy new_opera.mp4 | |
""" | |
import json | |
import sys | |
from datetime import datetime |
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
find *.wav -exec ffmpeg -i '{}' '{}.flac' \; |