Skip to content

Instantly share code, notes, and snippets.

View thejhh's full-sized avatar
💭
Excellence isn't believing you're best; It's about always striving to get better

Jaakko Heusala thejhh

💭
Excellence isn't believing you're best; It's about always striving to get better
View GitHub Profile
@thejhh
thejhh / install-python.yml
Created May 28, 2020 14:51
Python bootstrap for ansible
---
- hosts: hosts
remote_user: root
gather_facts: false
tasks:
- name: Check for Python
raw: test -e /usr/bin/python
changed_when: false
failed_when: false
register: check_python
@thejhh
thejhh / sample.js
Last active January 21, 2020 14:51
// Original supposedly "correct" way: https://flaviocopes.com/javascript-async-await-array-map/
// NOPE! This is correct:
// Function that returns a promise
const functionWithPromise = item => {
return Promise.resolve('ok');
};
// Prefer functions without side effects. Much easier to understand, unit test, re-use and optimize (eg. three shaking).
@thejhh
thejhh / shell-node.js
Created December 13, 2019 08:52
Example of executing a NodeJS script with custom environment variables on all systems (supports both node and nodejs names for the executable)
#!/bin/bash
':' //; export TERMINAL_COLS="$(tput cols)"
':' //; exec "$(command -v nodejs || command -v node)" -- "$0" "$@"
const TERMINAL_COLS = parseInt(process.env.TERMINAL_COLS, 10);
console.log(TERMINAL_COLS);
@thejhh
thejhh / app.html
Created October 11, 2019 18:41
POC for $scope.$digest() vs $rootScope.$evalAsync() problem
<html>
</html>
@thejhh
thejhh / README.md
Last active June 4, 2019 17:58
Attempt to patch OpenWRT 18.04 for Teltonika RUT240

This patch has something still wrong, since Teltonika RUT240 gives this error:

# sysupgrade -v openwrt-ar71xx-generic-rut200-squashfs-factory.bin
Invalid image, not supported on this device.
Image check 'platform_check_image' failed.
@thejhh
thejhh / get-property.html
Created May 30, 2019 08:12
Lodash's recursive `_.get(value, key)` functionality implemented in Liquid's include partial for Github Pages / Jekyll
{% comment %}
This works like Lodash's `_.get(value, key)`, where `value` can be an object and `key` a string path to specific value.
Use it like:
{% assign translation = site.data.lang[site.lang] %}
{% capture title %}{% include common/get-property.html value=translation key=page.title %}{% endcapture %}
And so, you can have your Front Matter title as "path.to.key" translated from your _data/lang/{fi,en}.json to correct value.
@thejhh
thejhh / Foo.js
Created May 11, 2019 17:47
ES6 and interfaces in WebStorm
/**
* @interface
*/
class Foo {
/**
* @returns {string}
*/
foo () {
@thejhh
thejhh / surfaceGoLteNVMeSSD.html
Created March 28, 2019 19:51
Bonnie++ on Surface Go, Windows 10, Ubuntu 18.04 over WSL with NVMe SSD
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>Bonnie++ Benchmark results</title><style type="text/css">td.header {text-align: center; background-color: "#CCFFFF" }td.rowheader {text-align: center; background-color: "#CCCFFF" }td.size {text-align: center; background-color: "#CCCFFF" }td.ksec {text-align: center; fontstyle: italic }</style></head><body><table border="3" cellpadding="2" cellspacing="1"><tr><td colspan="2" class="header"><font size=+1><b>Version 1.97</b></font></td><td colspan="6" class="header"><font size=+2><b>Sequential Output</b></font></td><td colspan="4" class="header"><font size=+2><b>Sequential Input</b></font></td><td colspan="2" rowspan="2" class="header"><font size=+2><b>Random<br>Seeks</b></font></td><td colspan="1" class="header"></td><td colspan="6" class="header"><font size=+2><b>Sequential Create<
@thejhh
thejhh / LinuxNetworkingCommands.md
Last active March 23, 2019 09:01
Linux network diagnostic & debugging command reference

Linux network diagnostic & debugging command reference

Ethernet device information

Display features on interface

ethtool -k INTERFACE

Network testing

@thejhh
thejhh / FooList.js
Last active November 3, 2018 17:56
"Interface" / Protocols implementation using ES6 and Symbols
// @norjs/Interface is commercial package from https://www.norjs.com
import Interface from '@norjs/Interface';
import listInterface from './listInterface.js';
class FooList {
// `listInterface.getList` is reference to an unique Symbol value for the name of the method.
//
// Using Symbols may look a bit strange, but this makes it possible to use