Skip to content

Instantly share code, notes, and snippets.

foo(N) :- write('Roy'), write('sits'), bar(N), write('bored'), write(N).
bar(N) :- write('here').
@thanatos
thanatos / real-audio-player.rst
Last active July 23, 2018 04:17
A real audio player

Some notes on what an audio player (somewhat targeted at dancers / DJs) should support:

This is a side project I'd like to try my own hand at some time. If you want ultimate, I've got a few requirements from an interesting angle for you: I'm both a dancer, and in some regards a DJ. Specifically, I tend to play music for dancers. iTunes absolutely falls down here.

  • Replay gain: Replay gain is an amazing feature, and once you have it, you never want to be without it.
  • Do not trust duration tags. They lie. A lot of media players (Foobar2000 included!) trust these. Or assume MP3s are CBR, and that the remainder is the same bit-rate as the rest. It greatly affects usability too, when the player thinks a 3 minute song is 30 minutes, and scales the seeking bar to that point.
  • Robust codec support ogg and flac are a must, as they're the two best formats out there. (ogg beats the pants off mp3, and it beats mp4 by virtue of no patents; flac is the only good lossless codec I know of, which is important¹.)
@thanatos
thanatos / minimal-xhtml.rst
Last active August 29, 2015 14:01
Minimal XHTML document

Gathering info from here_ and `The WHATWG Blog`_, the minimal XHTML 5 document.

(This is served with Content-Type: application/xhtml+xml.)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
@thanatos
thanatos / py-unittest-locations.rst
Last active August 29, 2015 14:04
Python: Where do unittests go?

Considerations

The filename

It's basically between test_foo.py and foo_test.py, though one might argue that if tests are in a tests/ directory, you shouldn't need to prefix/suffix each file with test because the path already has it. However, it seems like many testing frameworks — such as nose — really want that.

@thanatos
thanatos / tmobile.txt
Last active August 29, 2015 14:05
T-Mobile, what *is* this?
Captured in the heart of silicon valley…
--- 8.8.8.8 ping statistics ---
1590 packets transmitted, 1513 packets received, 4.8% packet loss
round-trip min/avg/max/stddev = 36.482/2250.401/69421.562/8192.683 ms
Request timeout for icmp_seq 65
Request timeout for icmp_seq 66
Request timeout for icmp_seq 67
@thanatos
thanatos / utf8-template1.sql
Created October 2, 2014 19:00
Make PosgreSQL's "template1" database UTF-8
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UTF-8';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
GRANT CONNECT ON DATABASE template1 TO PUBLIC;
REVOKE TEMPORARY ON DATABASE template1 FROM PUBLIC;
\c template1
VACUUM FREEZE;
@thanatos
thanatos / .gitignore
Last active December 15, 2016 23:09
Cues into Deca Choreos
/html
@thanatos
thanatos / test.md
Last active August 29, 2015 14:11
markdown test
this is a test qqq
a b c r
@thanatos
thanatos / atom-contrib.rst
Last active December 15, 2016 22:56
Commit Message Emoji

Stolen from Atom's contribution guidelines <https://github.com/atom/atom/blob/b4b492a32134c3c92248d020f090480451982140/CONTRIBUTING.md>:

Consider starting the commit message with an applicable emoji:

  • 💄: 💄 when improving the format/structure of the code
  • 🐎: 🐎 when improving performance (perhaps 🏇)
  • 🚱: 🚱 when plugging memory leaks
  • 📝: 📝 when writing docs
  • 🐧: 🐧 when fixing something on Linux
  • 🍎: 🍎 when fixing something on Mac OS
@thanatos
thanatos / context_switch_speed.py
Created February 3, 2015 16:12
Context Switches Speeds: OS threads vs. gevent greenlets
from __future__ import print_function
import datetime
import threading
import gevent
# Greenlets: