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 / 02-reconfigure-tzdata.yml
Last active June 19, 2020 17:09
09-configure-timezone.yml
- name: Reconfigure tzdata
include_tasks: 20-reconfigure-tzdata.yml
$ test "$memmb" -gt 4000
-bash: test: : integer expression expected
$ test $memmb -gt 4000
-bash: test: -gt: unary operator expected
$ [ $memmb -gt 4000 ]
-bash: [: -gt: unary operator expected
$ [ "$memmb" -gt 4000 ]
@thejhh
thejhh / bootstrap-container-ssh.yml
Last active May 28, 2020 19:22
Example how to bootstrap install SSH pubkeys to remote lxc containers
---
- hosts: containers
remote_user: root
connection: local
tasks:
- name: Test for SSH host key verification
local_action: command is-ssh-host-verified {{ inventory_hostname }}
changed_when: false
failed_when: false
register: ssh_host_verified
@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 () {