Skip to content

Instantly share code, notes, and snippets.

View whhone's full-sized avatar

Wai Hon Law whhone

View GitHub Profile
@whhone
whhone / 24-bit-true-color.sh
Last active March 16, 2025 03:10
24-bit-true-color.sh
awk 'BEGIN{
n=256
for (colnum = 0; colnum<n; colnum++) {
r = 255-(colnum*255/n);
g = (colnum*510/n);
b = (colnum*255/n);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "/\033[0m";
@whhone
whhone / org-agenda-with-repeater.el
Last active January 5, 2025 20:00
Past Solution with "org-agenda-finalize-hook"
;; Past solution for https://whhone.com/posts/org-agenda-repeated-tasks/
(defun my/org-agenda-entry-get-repeat ()
"Get the repeater of the current entry with 'org-get-repeat'."
(when-let ((marker (org-get-at-bol 'org-marker))
(buffer (marker-buffer marker))
(pos (marker-position marker)))
(with-current-buffer buffer
(goto-char pos)
(org-get-repeat))))
@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>