Skip to content

Instantly share code, notes, and snippets.

View soxofaan's full-sized avatar

Stefaan Lippens soxofaan

View GitHub Profile
@soxofaan
soxofaan / phantomjs-revealjs-slide-capture.js
Last active July 1, 2017 11:00
PhantomJS script to capture/render screenshots of the slides of a Reveal.js powered slideshow.
/**
* PhantomJS script to capture/render screenshots of the slides of a Reveal.js powered slideshow.
*/
var page = require('webpage').create();
var args = require('system').args;
// Get url to render from command line.
var url;
if (args.length < 2) {
@soxofaan
soxofaan / .block
Last active August 15, 2017 12:23
Four-dimensional hypersphere packing
license: mit
border: no
@soxofaan
soxofaan / zequals.py
Last active November 28, 2017 08:52
"Zequals" ruthless rounding: just keep one leading digit.
import math
def zequals(x):
"""
"Zequals" ruthless rounding: just keep one leading digit.
examples:
123 -> 100
4567 -> 5000
-0.0345 -> -0.03
@soxofaan
soxofaan / pandas-timeindex-secondary-y-issue.ipynb
Last active December 13, 2017 17:25
pandas-timeindex-secondary-y-issue.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import subprocess
import random
import time
import threading
from queue import Queue
import collections
class AsynchronousFileReader(threading.Thread):
'''
@soxofaan
soxofaan / .block
Last active December 29, 2018 17:06
Circle of Fifths with Diatonic Seventh Chords
license: mit
height: 800
border: no
@soxofaan
soxofaan / signal_catcher_context.py
Last active April 13, 2019 16:12
Python (3.6+) context manager that catches signals (e.g. SIGINT, SIGTERM) and exposes that. Allows writing infinite loops that can be exited in a clean way.
import logging
import os
import signal
import time
log = logging.getLogger(__name__)
class SignalCatcher:
@soxofaan
soxofaan / index.html
Last active May 14, 2019 14:37
d3-plugins sankey cycle support
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://d3js.org/d3.v2.js"></script>
<script type="text/javascript" src="./sankey.js"></script>
<title>Sankey Diagram</title>
<style>
sankeyDraw(
{
'nodes': [
{name: "a"},
{name: "b"},
{name: "c"},
{name: "d"},
{name: "e"},
{name: "f"},
{name: "g"},
@soxofaan
soxofaan / .block
Last active August 15, 2019 21:55
Microphone Spectrum Analyser
license: mit
height: 500
border: no