Skip to content

Instantly share code, notes, and snippets.

View jonathanlurie's full-sized avatar
🐛
I like to code things

Jonathan Lurie jonathanlurie

🐛
I like to code things
View GitHub Profile
@jonathanlurie
jonathanlurie / data-3.csv
Last active May 25, 2017 03:06 — forked from d3noob/data-3.csv
v4 curve interpolation comparison
date close
1-May-12 558.13
30-Apr-12 553.98
27-Apr-12 567.00
26-Apr-12 589.70
25-Apr-12 599.00
24-Apr-12 630.28
21-Apr-12 666.70
23-Apr-12 666.70
20-Apr-12 634.98
@jonathanlurie
jonathanlurie / endianness.js
Last active July 12, 2017 00:38 — forked from TooTallNate/endianness.js
Get host machine endianness using JavaScript Typed Arrays (polyfill for `os.endianness()` in node.js)
function endianness () {
var b = new ArrayBuffer(4);
var a = new Uint32Array(b);
var c = new Uint8Array(b);
a[0] = 0xdeadbeef;
if (c[0] == 0xef) return 'LE';
if (c[0] == 0xde) return 'BE';
throw new Error('unknown endianness');
}
@jonathanlurie
jonathanlurie / index.html
Created September 17, 2017 20:31
play audio in JS
<html>
<head>
</head>
<body>
<script>
// index of the sound currently being played (-1 if none)
var playingIndex = -1;
// duration in second of the fading
var fadeDuration = 2;
@jonathanlurie
jonathanlurie / jsont.js
Last active November 26, 2024 07:28
Serialize/deserialize json and conserve typed arrays
/*
Author: Jonathan Lurie - http://me.jonathanlurie.fr
License: MIT
The point of this little gist is to fix the issue of losing
typed arrays when calling the default JSON serilization.
The default mode has for effect to convert typed arrays into
object like that: {0: 0.1, 1: 0.2, 2: 0.3} what used to be
Float32Array([0.1, 0.2, 0.3]) and once it takes the shape of an
object, there is no way to get it back in an automated way!
@jonathanlurie
jonathanlurie / index.html
Last active October 17, 2017 19:39
This is to show the brain 0 coord when using a Image3DAlt.getMetadata("transformations")["v2w"], shown with axis
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name=keywords content="coma, separated, keywords" />
<meta name=description content="This is the description" />
<meta property=og:title content="Page Title" />
<meta property=og:description content="This is the description" />
@jonathanlurie
jonathanlurie / index.html
Last active February 22, 2018 17:08
Posting to Webtask
<html>
<head>
<title>test</title>
</head>
<body>
<div id="output"></div>
<script>
var output = document.getElementById("output")
@jonathanlurie
jonathanlurie / prepent_http.js
Last active February 6, 2019 08:05
In a Markdown file, all images paths not starting with 'http' will be prepended with some sufix
let lorem = `
Lorem ipsum dolor sit amet, ![ ghj78 ](consectetur) adipiscing elit. Praesent rhoncus neque vel justo ![foo](http://kdjkasdjkajs.com/asdasd.png), at imperdiet massa porta. In eget risus ac tortor tristique congue. Quisque hendrerit a ante sed vehicula. Vivamus vitae libero magna. Donec nec orci maximus felis blandit tristique eget vitae sapien. Vestibulum vitae tortor ![foo bar](consectetur) ultrices, convallis orci vitae, convallis lacus. Aenean accumsan egestas nibh, eu convallis nibh feugiat id. Mauris libero ligula, mattis quis sem at, tempus rhoncus ipsum.
Curabitur vitae ipsum ut arcu congue placerat vitae ut dolor. Vestibulum dolor ligula, ultricies et orci a, ornare porta sem. Morbi eget tellus scelerisque, vehicula metus id, aliquam ex. Pellentesque eget bibendum sem. Suspendisse commodo, neque et cursus varius, metus justo convallis lacus, ac mattis nisi leo a urna. Phasellus iaculis enim sed diam fermentum ![bar](consectetur). Integer sed bibendum nulla. Duis dignissim eleifend urna,
@jonathanlurie
jonathanlurie / EventManager.js
Created February 6, 2019 18:56
A simple way to deal with events (no event deleting yet)
/**
* The EventManager deals with events, create them, call them.
* This class is mostly for being inherited from.
*/
class EventManager {
/**
* Constructor
*/
constructor() {
this._events = {}
@jonathanlurie
jonathanlurie / misctools.js
Last active March 1, 2019 17:41
Some handy functions I use quite a lot but that does not deserve a proper repo
/**
* Because sometime we want to use the constructor of a typed array
* from a string such as 'uint8' or 'float32'
*/
const TYPED_ARRAY_LUT = {
int8: Int8Array,
int16: Int16Array,
int32: Int32Array,
uint8: Uint8Array,
uint16: Uint16Array,
this is a test