Skip to content

Instantly share code, notes, and snippets.

--- src/main.cpp
+++ src/main.cpp
@@ -433,20 +433,15 @@
}
if (isRoot()) {
- CUtils::PrintError(
- "You are running ZNC as root! Don't do that! There are not many "
- "valid");
- CUtils::PrintError(
// cancel request
let req = new Request(url);
fetch(req).catch(() => {
// reject with abort error
});
req.abort(); // abort fetch
// cancel stream reading
fetch(url).then(r => {
r.abort();
@hgl
hgl / Cancelable Promises.md
Created July 30, 2015 02:46
Cancelable Promises

Background

In a promise system, there are two parties involved, an action initiator, and observers:

let done = fetch(url);
let insertDom = () => console.log("element inserted");
let read = () => done.then(insertDom);

Thoughts on OpenWrt's sysupgrade script

I want to improve the sysupgrade script, making it support extroot better.

I have the following improvements in mind:

  • After upgrading but before restarting, new usb storage related packages are installed to the jffs2 partition, along with the fs package to support the current usb overlay's filesystem.
  • Before upgrading, /etc/config/fstab in jffs2 partition is saved to /tmp, and after upgrading, restored to the jffs2 partition
  • The upper directory in the usb overlay is removed after upgrading, making sure no mismatched kernel and kernel modules.
  • All other saved configs (if any) are restored to the usb overlay after upper is removed.
elem1.style.transform = "translateX(0px)";
var fx = new SequenceEffect([
new KeyframeEffect(elem1, [{
"transform": "translateX(100px)"
}, {
"transform": "translateX(200px)"
}], {duration: 500, fill: "forwards"}),
new KeyframeEffect(elem2, [{
"transform": "translateX(100px)"
}, {
@hgl
hgl / gist:abbaf35f96b70e276725
Last active May 20, 2020 18:25
Suggestions to OpenWrt's znc package

After spending much time configurating znc on OpenWrt with the helps from people on znc channel, I believe I have a pretty decent configration, and would like to suggest the following modifications to the znc package so other people can benefit from it.

  • Drop UCI config, and use znc's config directly.

    • With UCI config, it means the used config dir is temporary, and it makes modules like webadmin less useful. Also it makes remembering password for the sasl module very hard, which doesn't support specifying the password when loading the module. The same goes for using a pem file for the cert module and making it stick.

      I know the znc package currently supports external config. But the problem is that the pid file is specified to live in /tmp/etc/znc/znc.pid. I'm not sure if this directory will be created when the external config is used. Ideally, it should live in /var/run/znc/znc.pid with /var/run/znc be owned by a limited user znc (more on this later).

  • Use sudo instead of su

  • U

Problem

Given this css code

:root {
	--color: #aaa;
	--bg-color: var(--color);
	--narrow-window-width: 30em;
}
body {