Skip to content

Instantly share code, notes, and snippets.

View whhone's full-sized avatar

Wai Hon Law whhone

View GitHub Profile
@whhone
whhone / random-org.el
Last active December 4, 2023 08:38
Emacs lisp function to jump to random org heading. Useful for getting a random note from a giant org file.
(defun my/org-random-heading ()
"Jump to a random org heading in the current org file."
(interactive)
(goto-char (point-min))
(let ((headings '()))
(while (re-search-forward "^\\*+ " nil t)
(push (point) headings))
(when headings
(goto-char (nth (random (length headings)) headings))
(org-reveal))))
@whhone
whhone / keybase.md
Created February 23, 2021 04:30
keybase.md

Keybase proof

I hereby claim:

  • I am whhone on github.
  • I am whhone (https://keybase.io/whhone) on keybase.
  • I have a public key ASCpaOsI-Ri-TiaIlT-O_XQnCz33XwKCXybmiAU0IsHS9Ao

To claim this, I am signing this object:

// .then block does not complete
Future<void> foo_then_bad() async {
final future = Future(() => print('foo_then_bad: started'))
.then((_) async => () async {
await Future.delayed(Duration(seconds: 1), null);
print('foo_then_bad: 111');
await Future.delayed(Duration(seconds: 1), null);
print('foo_then_bad: 222');
});
@whhone
whhone / arc.md
Last active October 4, 2022 16:59

set default host

arc set-config default <instance>

set default editor to vim

arc set-config editor "vim"
@whhone
whhone / virtualenvwrapper.md
Last active July 16, 2018 22:26
virtualenvwrapper Cheat Sheet

Installing

sudo apt install virtualenvwrapper # Ubuntu
sudo pip install virtualenvwrapper # Mac or Ubuntu

Create a virtual env

mkvirtualenv --python=`which python3` <vir_env_name>