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 / maptiler-population.html
Created July 27, 2023 10:03
Using MapTiler Weather library and SDK to visualise global population density
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cloud coverage displayed from radar data</title>
<script src="https://cdn.maptiler.com/maptiler-sdk-js/v1.1.1/maptiler-sdk.umd.min.js"></script>
<link href="https://cdn.maptiler.com/maptiler-sdk-js/v1.1.1/maptiler-sdk.css" rel="stylesheet" />
<script src="https://cdn.maptiler.com/maptiler-weather/v1.0.0/maptiler-weather.umd.min.js"></script>
function main() {
console.log(12)
}
@jonathanlurie
jonathanlurie / NumpyTypeEncoder.md
Last active November 10, 2021 13:39
Serialize to JSON dictionaries containing Numpy types

NumpyTypeEncoder

Attempting to serialize into JSON a dictionary that contains Numpy-specific types such as np.ndarray, np.float64, np.uint32, etc. will generaly lead to error such as:

  • TypeError: Object of type ndarray is not JSON serializable
  • TypeError: Object of type float32 is not JSON serializable

To achieve a clean serialization, one must first cast all Numpy-type values into something more Python-friendly. This is done by extending the base JSONEncoder:

import json
import numpy as np
// This comes from https://usefulangle.com/post/30/javascript-get-date-time-with-offset-hours-minutes
function getIso8601z() {
// timezone part
const timezoneOffsetMin = new Date().getTimezoneOffset()
const offsetHours = parseInt(Math.abs(timezoneOffsetMin / 60))
const offsetMinutes = Math.abs(timezoneOffsetMin % 60)
let timezoneStandard = null
if(offsetHours < 10) {
offsetHours = `0${offsetHours}`
this is a test
@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,
@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 / 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 / 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 / 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" />