Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
@nst
nst / bpm.py
Created March 5, 2014 15:01
Counts the number of heartbeats per minute.
#!/usr/bin/python
""""
Counts the number of heartbeats per minute.
For example, you can use it to count your mp3's bpm or your number or heartbeats or breaths per minute.
$ python bpm.py
BPM - Calcule les bpm sur les 4 derniers beats.
Appuyer sur a chaque beat, 'q' pour quitter.
# http://corkami.googlecode.com/svn/trunk/src/HexII/
$ ./hello
Hello world
$ hexdump hello
0000000 ce fa ed fe 07 00 00 00 03 00 00 00 02 00 00 00
0000010 02 00 00 00 88 00 00 00 01 00 00 00 01 00 00 00
0000020 38 00 00 00 5f 5f 54 45 58 54 00 00 00 00 00 00
0000030 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00
@nst
nst / DrawingUnicode
Last active August 29, 2015 14:04
Draw all Unicode code points in all 16 planes, see http://seriot.ch/visualization/unicode/
//
// main.m
// Unicode
//
// Created by Nicolas Seriot on 26/07/14.
// Copyright (c) 2014 Nicolas Seriot. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#!/usr/bin/env python
HIGH_BITS_MAX = 0xFF
LOW_BITS_MAX = 0xFF
def write_plane(plane_number, path):
with open(path, 'w+') as f:
f.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
//
// main.m
// Unicode
//
// Created by Nicolas Seriot on 26/07/14.
// Copyright (c) 2014 Nicolas Seriot. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
@nst
nst / request.swift
Last active May 3, 2016 08:35
NSURLRequest extension with curl description, fetch data and typed JSON, success and failure closures with status, headers and errors
see https://github.com/nst/HTTPRequests
__Add Submodule__
git submodule add https://github.com/username/Module
┌─────────────────────────┐
│ MyProject │
│ ┌────────────────┐ │
│ │ Module │ │
│ └────────────────┘ │
└─────────────────────────┘
@nst
nst / strava_to_doarama.py
Created August 13, 2016 13:48
Fix GPX paths exported from Strava by restoring the timestamp
#!/usr/bin/env python
"""
For some reason, Strava lets you export the GPX of another athletes but removes
the timestamps, presumably so that you can't "steal" their paths.
This script adds fake timestamps to these GPX files, so that you see the
overview of the run in other services like doarama for instance.
Technically, the script adds a timstamp after the </ele> tag, +1s at each point:
@nst
nst / test_json.go
Created October 18, 2016 22:46
A quick assessment of Go JSON parser conformance to RFC 7159
// go build test_json.go
// echo -n "[1e1000]" > n.json
// ./test_json n.json
// echo $? # 0 - failed to parse valid JSON
// echo -en '["\xFF"]' > s.json
// ./test_json s.json
// echo $? # 1 - parsed invalid JSON
@nst
nst / eca.py
Last active October 29, 2017 12:33
#!/usr/bin/python
__author__ = "Nicolas Seriot"
__date__ = "2017-05-24"
# http://mathworld.wolfram.com/ElementaryCellularAutomaton.html
# https://en.wikipedia.org/wiki/Rule_110
import png