Skip to content

Instantly share code, notes, and snippets.

View bddap's full-sized avatar

Andrew Dirksen bddap

View GitHub Profile
@bddap
bddap / split.cpp
Created February 23, 2017 19:45
C++ split string on char
vector<string> split(string s, char delimiter) {
vector<string> r;
while (true) {
string::size_type l = s.find(delimiter);
if (l == string::npos) {
r.push_back(s);
break;
}
r.push_back(s.substr(0, l));
s.erase(0, l + 1);
#!/bin/bash
lctrl=30064771296
rctrl=30064771300
lcmd=30064771299
rcmd=30064771303
loption=30064771298
roption=30064771302
# -1 none
@bddap
bddap / pronounceables.py
Created March 22, 2018 17:56
iterate over a subset of pronounceable words
#!/usr/bin/env python3
from itertools import count, product, islice, takewhile
def syllables():
cs = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']
vs = ['a','e','i','o','u']
for c in cs:
for v in vs:
yield c + v
@bddap
bddap / sfs_gen_audio.py
Created April 2, 2018 22:00
sfs_gen_audio.py
#!/usr/bin/env python3
from os import listdir
import json
songfiles = list(listdir('songs'))
def songs_for(q):
return [{'url' : '/songs/' + file} for file in songfiles if file.startswith(q)]
@bddap
bddap / sfs_cat_audio.py
Created April 4, 2018 19:44
sfs_cat_audio.py
#!/usr/bin/env python3
from os import listdir, mkdir, path
from subprocess import run
import json
songfiles = list(listdir('songs'))
if not path.exists('songs2'):
mkdir('songs2')
@bddap
bddap / antiresonant_speaker.js
Created April 10, 2018 20:17
jscad speaker
const len = 100; // length of longest resonator
const count = 8;
const irr = (Math.sqrt(5) + 1) / 2; // a very irrational number
const s = 1 / irr; // length ratio between largest and smallest resonator
function main() {
return Array(count).fill(0)
.map((_, i) => resonator(Math.pow(s, i / (count - 1))))
.reduce(combine);
const len = 200; // length of longest resonator
const count = 8;
const irr = (Math.sqrt(5) + 1) / 2; // a very irrational number
const s = 1 / irr; // length ratio between largest and smallest resonator
function main() {
return Array(count).fill(0)
.map((_, i) => resonator(Math.pow(s, i / (count - 1))))
.reduce(combine);
@bddap
bddap / slides.md
Created July 14, 2018 01:54
Minimal html slideshow.
<script> let currentSlide = 0; function display(slide) { const sections = document.getElementsByTagName('section'); currentSlide = Math.min(Math.max(slide, 0), sections.length - 1); Array.from(sections).forEach((section, index) => { section.style.display = index === currentSlide ? null : 'none'; }) } document.addEventListener('keydown', event => {
@bddap
bddap / simple-slides.js
Created July 14, 2018 01:56
link to this script and each your <section> tag becomes a separate slide.
let currentSlide = 0;
function display(slide) {
const sections = document.getElementsByTagName('section');
currentSlide = Math.min(Math.max(slide, 0), sections.length - 1);
Array.from(sections).forEach((section, index) => {
section.style.display = index === currentSlide ? null : 'none';
})
}
document.addEventListener('keydown', event => {
if(event.key === 'ArrowRight' || event.key == ' ') display(currentSlide + 1);
@bddap
bddap / fullscreen-slides.html
Created July 15, 2018 20:24
slideshow with fullscreen support
<script>
let currentSlide = 0;
function display(slide) {
const sections = document.getElementsByTagName('section');
currentSlide = Math.min(Math.max(slide, 0), sections.length - 1);
Array.from(sections).forEach((section, index) => {
section.style.display = index === currentSlide ? null : 'none';
})
}
document.addEventListener('keydown', event => {