Skip to content

Instantly share code, notes, and snippets.

Niels Leenheer NielsLeenheer

Block or report user

Report or block NielsLeenheer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View console.hex.js
console.hex = (d) => console.log((Object(d).buffer instanceof ArrayBuffer ? new Uint8Array(d.buffer) :
typeof d === 'string' ? (new TextEncoder('utf-8')).encode(d) :
new Uint8ClampedArray(d)).reduce((p, c, i, a) => p + (i % 16 === 0 ? i.toString(16).padStart(6, 0) + ' ' : ' ') +
c.toString(16).padStart(2, 0) + (i === a.length - 1 || i % 16 === 15 ?
' '.repeat((15 - i % 16) * 3) + Array.from(a).splice(i - i % 16, 16).reduce((r, v) =>
r + (v > 31 && v < 127 || v > 159 ? String.fromCharCode(v) : '.'), ' ') + '\n' : ''), ''));
@NielsLeenheer
NielsLeenheer / Duck.gltf
Last active Aug 1, 2017
WebGL / Three.js ducks
View Duck.gltf
{
"asset": {
"generator": "COLLADA2GLTF",
"version": "2.0"
},
"scene": 0,
"scenes": [
{
"nodes": [
0
@NielsLeenheer
NielsLeenheer / screenmirror-puck.js
Last active Jul 6, 2017
Toggle screen-mirroring on the new MacBook Pro using a Puck.js
View screenmirror-puck.js
var kb = require("ble_hid_keyboard");
var services = {
0x180a: {
0x2a50: {
value: [
0x01, /* Use USB Vendor IDs */
0xac, 0x05, /* Apple */
0x5a, 0x02, /* Internal Keyboard */
0x00, 0x00
@NielsLeenheer
NielsLeenheer / geolocation.js
Last active Feb 21, 2018
Make navigator.geolocation.getCurrentPosition more reliable
View geolocation.js
(function() {
if (navigator.geolocation) {
function PositionError(code, message) {
this.code = code;
this.message = message;
}
PositionError.PERMISSION_DENIED = 1;
PositionError.POSITION_UNAVAILABLE = 2;
View gist:32c82a2b3b19df8a0f44
Consoles:
Xbox 360 - Internet Explorer 9
Xbox One - Internet Explorer 10
Sony PlayStation 3 - Netfront
Sony PlayStation 4 - Chromium based
Sony PlayStation TV - Netfront NX
Nintendo Wii - Opera 9.6, Presto
Nintendo Wii U - Netfront NX
@NielsLeenheer
NielsLeenheer / Native app communication
Last active Aug 14, 2019
How a web app running on HTTPS can communicatie with local services
View Native app communication
I have a web app that needs to talk to point of sale hardware: receipt printers, customer displays,
cash drawers and payment terminals. Direct communication from the web app with these devices is
impossible, so I created a native app that can be installed on the computer that can talk to the
devices. The app runs a web server that exposes these devices using a REST api.
The native app registers itself upon startup with a webservice. It sends its own IP address on
the local network and the server also sees the external IP address of the network. The web app
sends a discovery request to the webservice and it receives all the local IP addresses which
have the same external IP address.
@NielsLeenheer
NielsLeenheer / Sony
Last active May 24, 2017
Google Chrome on Sony devices
View Sony
Sony devices ship with Google Chrome as the default browser. Google Chrome is baked
into the firmware of the device. Different versions of the firmware come with different
versions of Google Chrome.
Usually the version that comes with the firmware is updated using Google Play, however...
When first starting up the device Sony does not ask the user to log into Google Play.
This means that unless you manually open Google Play and log in, the devices does not
receive any updates using Google Play. In this case Google Chrome is only updated when
the user installs a firmware update.
View LG Browser
Chromium 30
458 / 555
https://html5test.com/results/related/7c791b543cbd7705f547a0a30e5404cf.html
- G Pad 8.3 Android 4.4.2
- G Pro 2 Android 4.4.2
- G2 Android 4.4.2
- G2 mini Android 4.4.2
- L65 Android 4.4.2
- L70 Android 4.4.2
View HTC Sense Browser
Note: All versions of the HTC Sense browser listed below send the following header: X-Requested-With: com.htc.sense.browser
Note: The difference between the two WebKit based versions are mostly which form field types are supported
Webkit
368 / 555
https://html5test.com/results/related/127d2c84dc7e495a6ed4ddd8ceccac2a.html
View Samsung Browser
Note: Some older devices such as the Galaxy S III did not get the Chromium based browser with
the update to Android 4.2 or later. When Samsung later introduced the Galaxy S3 Neo it did get
the new browser.
Note: With the Android 4.3 release and version 1.5 of the Chromium browser, Samsung did not
enable WebAudio API for the Note 3. All other devices did get the WebAudio API.
Note: Samsung did not update the browser version with the upgrade from Android 4.3 to 4.4,
but did add getUserMedia and WebRTC functionality.
You can’t perform that action at this time.