Skip to content

Instantly share code, notes, and snippets.

View andiwand's full-sized avatar

Andreas Stefl andiwand

  • CERN
  • Geneva
View GitHub Profile
@andiwand
andiwand / fix-default-routes
Last active September 26, 2018 04:07
OpenWrt / LEDE script to fix default routes.
#!/bin/ash
# OpenWrt / LEDE script to fix default routes.
if [ "$#" -ne 1 ]; then
>&2 echo "usage: $0 interface [interface ...]"
exit 1
fi
for arg in "$@"; do
@andiwand
andiwand / 01-default-route
Last active December 3, 2022 04:49
OpenWrt / LEDE hotplug script to add default routes correctly.
#!/bin/sh
# OpenWrt / LEDE hotplug script to add default routes correctly.
#
# Location "/etc/hotplug.d/iface/01-default-route".
#
# Fixed mwan3 "No default route in the main routing table" and
# "WARNING: this interface has no default route in the main routing table!" for me.
uci get "network.${INTERFACE}.gateway" > /dev/null 2>&1 || exit
@andiwand
andiwand / observables.js
Last active November 5, 2019 06:20
Javascript observable objects with Proxy (ECMA-262 6th Edition, https://mzl.la/203LEg9)
ObservableArray = function(array) {
if (array == null) array = [];
if (!Array.isArray(array)) throw new TypeError('argument is not an array');
var listeners = [];
this.toString = array.toString;
this.listen = function(listener) {
listeners.push(listener);
@andiwand
andiwand / focustree.js
Created July 26, 2016 20:20
Javascript focus tree eventing
focustree = (function() {
var entries = [];
var currentFocus = [];
function indexOf(array, element) {
for (var i = 0; i < array.length; i++) {
if (array[i] === element) return i;
}
return -1;