Skip to content

Instantly share code, notes, and snippets.

* root topic - TAB and S-TAB to toggle folding
** child topic
child topic text
*** leaf topic:
some text blah
blah
blah
*** another leaf topic:
# test table - TAB to cycle through columns, M-e to move point to end of cell
@jclosure
jclosure / killgrep.sh
Last active March 9, 2021 03:59
portable killall based on a grep expression
# e.g. portable killall based on a grep expression
# usage: killgrep python3
$ echo "killgrep() {ps -aux | grep -i \"\$1\" | awk '{print \$2}' | xargs kill -9;}" >> ~/.zshrc
@jclosure
jclosure / pb_generic_dict_codec.py
Created February 7, 2021 02:54
Generic Python Protobuf <-> Dictionary: encoder/decoder functions
from google.protobuf.json_format import MessageToDict
from google.protobuf.json_format import ParseDict
def encode(dictObj, pb_class):
"""Takes in a dict and returns the serialized binary of pb_class"""
# pb = dict_to_protobuf(pb_class, dict)
pb = pb_class()
pb = ParseDict(dictObj, pb, ignore_unknown_fields=True)
return pb.SerializeToString()
@jclosure
jclosure / sample.org.gpg
Created October 21, 2020 17:49
Org-file header to be automatically encrypted/decrypted
HeadlineTime
Total time0:00
@jclosure
jclosure / example.sh
Created October 11, 2020 20:35
Automated deployment of pod and proxy ssh and other ports without load-balancer
#!/bin/bash
# Scripted deployment of a pod w/ forward ports using ssh tunnels via $JUMP_BOX.
JUMP_BOX=root@my-bastion-host
NAME="my-container-prefix-name"
CONTAINER=`kubectl -n admin get pods | grep $NAME | head -1 | awk '{print $1}'`
@jclosure
jclosure / init.el
Created September 21, 2020 05:16 — forked from tonini/init.el
Minimal setup for alchemist and company init.el
;; ELPA setup
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
(package-initialize)
;; Company setup
@jclosure
jclosure / example.md
Created September 16, 2020 08:55
Create a derived major-mode in emacs for personal customization

I wrote in ~/.emacs.d/lisp/ros-cmake-mode.el:

(require 'cmake-mode)

(defun ros-cmake-indent ()
   ;; my code here...
  )

;;;###autoload
@jclosure
jclosure / xref-fallback.md
Last active September 14, 2020 23:44
Use dumb-jump as a fallback for xref

I use dumb-jump, though I was unaware of the new changes as I probably use an older version. Skimming the docs it encourages you to enable M-x dumb-jump-mode but the keymap does not actually enable the xref bindings. The code says you must add dumb-jump-xref-activate to xref-backend-functions.

Try this:

(add-to-list 'xref-backend-functions 'dumb-jump-xref-activate t)

And then xref will fall back to dumb-jump when there are no better options. Edit: you may want to try with and without t as it appends, meaning dumb-jump

@jclosure
jclosure / raspberry_pi_4_setup_guide.md
Last active August 15, 2020 10:39
Raspberry pi 4 install notes

Raspberry pi setup notes

Graphical Login

If you are using gdm3 or lightdm, you can setup graphical login

sudo raspi-config

go to and set

@jclosure
jclosure / kill_port_process.sh
Created August 5, 2020 05:13
Simple bash command to kill a process that's occupying a port by specifying the port as arg
#!/bin/bash
PORT=$1
kill `lsof -t -i:$PORT`