Skip to content

Instantly share code, notes, and snippets.

@haansn08
haansn08 / convert.sh
Created April 5, 2015 13:14
Bash audio converter using ffmpeg
#!/bin/bash
find "$1" -name *.$2 | while read filename
do
newdir="$3"/${filename#*/}
newpath=${newdir%/*}
mkdir -p "$newpath"
newext=${newdir%.$2}.$4
ffmpeg -i "$filename" -vn "$newext" < /dev/null
done
item itemLabel qual value valueLabel
Q84166704 2020 coronavirus pandemic in Spain http://www.wikidata.org/prop/qualifier/P518 Q29 Spain
Q87770827 2020 coronavirus pandemic in Tanzania http://www.wikidata.org/prop/qualifier/P518 Q924 Tanzania
Q87785296 2020 coronavirus pandemic in Greenland http://www.wikidata.org/prop/qualifier/P518 Q223 Greenland
Q87814953 2020 coronavirus pandemic in Syria http://www.wikidata.org/prop/qualifier/P518 Q858 Syria
Q87836826 COVID-19 pandemic in East Timor http://www.wikidata.org/prop/qualifier/P518 Q574 East Timor
Q87887813 2020 coronavirus pandemic in Montenegro http://www.wikidata.org/prop/qualifier/P518 Q236 Montenegro
Q87901408 2020 coronavirus pandemic in Alberta http://www.wikidata.org/prop/qualifier/P518 Q1951 Alberta
Q87899022 2020 coronavirus pandemic in Djibouti http://www.wikidata.org/prop/qualifier/P518 Q977 Djibouti
Q87899016 2020 coronavirus pandemic in the Gambia http://www.wikidata.org/prop/qualifier/P518 Q1005 The Gambia
@haansn08
haansn08 / cf-dynamic-ip.service
Created February 13, 2022 10:19
Cloudflare Dynamic IP
[Unit]
Description=Update DNS record on Cloudflare
[Service]
ExecStart=/usr/bin/python /opt/cf.py
DynamicUser=yes
LoadCredentialEncrypted=cf-api-token:/etc/cf-api-token
[Install]
WantedBy=network.target
@haansn08
haansn08 / n3t.py
Last active May 29, 2022 19:01
Variation of Tic-Tac-Toe where players have numbers 1 to 9 for their moves
# board is an array with indices in following arrangement
#
# 1 | 5 | 2
# ---------
# 6 | 0 | 7
# ---------
# 3 | 8 | 4
win_indices = [
(1,5,2), (6,0,7), (3,8,4), #left to right
Inductive nat : Type :=
| z : nat
| s : nat -> nat.
Inductive even : nat -> Prop :=
| even_z : even z
| even_ss n: even n -> even (s (s n)).
Fixpoint double (n : nat) :=
match n with
# calculate sdp approximation for C5
using Random, LinearAlgebra, JuMP, CSDP
n = 5 #number of vertices
V = 1:n
E = [(i, i+1).%n.+1 for i in V]
m = Model(CSDP.Optimizer)
X = @variable(m, X[1:n, 1:n], PSD)