Skip to content

Instantly share code, notes, and snippets.

View chumaltd's full-sized avatar

Chuma Takahiro chumaltd

View GitHub Profile
/// Several functions are derived from MDN example:
/// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#examples
function str2ab(str) {
const buf = new ArrayBuffer(str.length);
const bufView = new Uint8Array(buf);
for (let i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
@chumaltd
chumaltd / setup-functions.sh
Last active July 15, 2025 03:28
extra installation for Debian variants.
function apt_install () {
which apt
if [[ $? > 0 ]]; then
echo "apt command not found. skip..."
else
sudo apt-get install -y "$@"
fi
}
function emacs_snap () {
; This gist is derived from ng-ts-mode.el:
; https://gist.github.com/lesteral/007afd6f0cf2505efcacaaf640edb698
;
; NOTE: >=emacs30 needs to rework with bundled html-ts-mode. emacs29 depends on mickynp's extra work:
; https://github.com/mickeynp/html-ts-mode/tree/master
; WARN: nested html`` fails.
; WARN: css`` part doesn't works yet.
(add-hook 'typescript-ts-mode-hook
(lambda ()