Skip to content

Instantly share code, notes, and snippets.

Fix WontFix


Fix WontFix
View GitHub Profile
ignacysokolowski /
Created Oct 29, 2012
Python: Play a WAV file with PulseAudio simple API
#!/usr/bin/env python
import ctypes
import wave
import sys
pa = ctypes.cdll.LoadLibrary('')
willurd /
Last active Jan 30, 2023
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
wernight /
Last active Nov 14, 2022
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.
mathisonian /
Last active Nov 26, 2022
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5


View gist:3b19447b304616f18657
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\n",
"sources" : [ "" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "" ],
marchelbling /
Last active Apr 1, 2022
C++ json writer


This code implements a naive JSON writer in C++ complying with RFC 4627. I wrote this as I believe it is a very good example of a real life problem involving lots of C++ constructs. This sample only supports writing JSON and does not support heterogenous ‘object’ serialization and extension are left as an exercice. See Writing json in C++ for some details.


  • json_stream: a std::ofstream wrapper fulfilling RFC 4627 constraints;
  • utf8_json: some code to decode/“json encode” std::string UTF-8 buffers
  • json_test.cpp: a very simple program testing the code
Vestride /
Last active Jan 22, 2023
Encoding video for the web

Encoding Video


Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
voluntas / webrtc.rst
Last active Dec 27, 2022
WebRTC の未来
View webrtc.rst
View riff-wave-pcm.js
* RIFF WAVE PCM file generator
* Reference:
* @author Lara Sophie Schütt (@literallylara)
* @license CC0
const DUR = 5 // duration in seconds
const NCH = 1 // number of channels
laerciobernardo / hexIEEEtoFloat.js
Last active Nov 27, 2021
Convert Hexadecimal IEEE754 to Float in Javascript
View hexIEEEtoFloat.js
var str = '0x41FC6733';
function parseFloat(str) {
var float = 0, sign, order, mantiss,exp,
int = 0, multi = 1;
if (/^0x/.exec(str)) {
int = parseInt(str,16);
for (var i = str.length -1; i >=0; i -= 1) {
if (str.charCodeAt(i)>255) {