Skip to content

Instantly share code, notes, and snippets.

@cibyr
cibyr / sublime-keymap
Created December 25, 2018 02:11
Muscle memory
[
{ "keys": ["ctrl+g"], "command": "find_next" },
{ "keys": ["shift+ctrl+g"], "command": "find_prev" },
{ "keys": ["ctrl+shift+;"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
]
@cibyr
cibyr / uudecode.sh
Created April 10, 2013 05:12
uudecode in bash
if ! hash uudecode; then
uudecode() {
bs=0
while read -rs t ; do
if [ $bs -eq 1 ] ; then
if [ "a$t" = "aend" ] ; then
bs=2
else
x=1
i=($(printf "%d " "'${t:0:1}" "'${t:1:1}" "'${t:2:1}" "'${t:3:1}" "'${t:4:1}" "'${t:5:1}" "'${t:6:1}" "'${t:7:1}" "'${t:8:1}" "'${t:9:1}" "'${t:10:1}" "'${t:11:1}" "'${t:12:1}" "'${t:13:1}" "'${t:14:1}" "'${t:15:1}" "'${t:16:1}" "'${t:17:1}" "'${t:18:1}" "'${t:19:1}" "'${t:20:1}" "'${t:21:1}" "'${t:22:1}" "'${t:23:1}" "'${t:24:1}" "'${t:25:1}" "'${t:26:1}" "'${t:27:1}" "'${t:28:1}" "'${t:29:1}" "'${t:30:1}" "'${t:31:1}" "'${t:32:1}" "'${t:33:1}" "'${t:34:1}" "'${t:35:1}" "'${t:36:1}" "'${t:37:1}" "'${t:38:1}" "'${t:39:1}" "'${t:40:1}" "'${t:41:1}" "'${t:42:1}" "'${t:43:1}" "'${t:44:1}" "'${t:45:1}" "'${t:46:1}" "'${t:47:1}" "'${t:48:1}" "'${t:49:1}" "'${t:50:1}" "'${t:51:1}" "'${t:52:1}" "'${t:53:1}" "'${t:54:1}" "'${t:55:1}" "'${t:56:1}" "'${t:57:1}" "'${t:58:1}" "'${t:59:1}" "'${t:60:1}"))
@cibyr
cibyr / gdb-backtrace.sh
Created April 3, 2013 05:56
Bash script to attach GDB to a process and print a stack trace, from http://root.cern.ch/svn/root/tags/v5-26-00b/etc/gdb-backtrace.sh Useful on stupid distros (like Ubuntu) where pstack doesn't work and gstack isn't included in the GDB package. Set /proc/sys/kernel/yama/ptrace_scope to 0.
#!/bin/bash
# This script is almost identical to /usr/bin/gstack.
# It is used by TUnixSystem::StackTrace() on Linux and MacOS X.
tempname=`basename $0 .sh`
messfile=`dirname $0`/gdb-message.sh
OUTFILE=`mktemp -q /tmp/${tempname}.XXXXXX`
if test $? -ne 0; then
@cibyr
cibyr / latest_kernel.sh
Created March 20, 2013 08:20
Shell script fragment to get the latest installed kernel version. Useful for building dkms packages in chroots.
ls /usr/src/ | grep linux-headers | awk -F '-' '{print $3"-"$4}' | sort | tail -n1
@cibyr
cibyr / find_chroot_daemons.sh
Created March 19, 2013 05:40
Command to find daemons accidentally left running in the chroot you're building
sudo ls -l /proc/*/root | grep chroot
@cibyr
cibyr / bash_aliases
Created January 8, 2013 03:56
My bash aliases file.
alias here='caja .'
alias ack='ack-grep'
alias svn-clean='svn stat | awk '\''/^?/ { print $2 }'\'' | xargs rm -r'
alias svnlog='svn log -l 10'
alias svnstat='svn stat -q'
alias pylab='ipython --pylab'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'