Skip to content

Instantly share code, notes, and snippets.

@smblott-github
smblott-github / _insync-headless
Last active March 16, 2018 03:06
Simple zsh completion for insync, insync-headless and insync-portable. Grab this, name it "_insync-headless" and put it in some suitable location for zsh completion functions. And good luck. Zsh completion is a mystery to me.
#compdef insync-headless insync-portable insync
if [[ $CURRENT == 2 ]]
then
_values 'commands' \
'accept_all_new_shares[Accept all new shares file to given account]' \
'accept_share[Accept shared file to given account]' \
'add_account[Add account to Insync]' \
'force_sync[Force sync item]' \
'get_account_information[Show information for connected acounts]' \
@smblott-github
smblott-github / launch-vim-in-pantheon-terminal
Created June 16, 2015 11:50
Pantheon-terminal for Text-Aid-Too
#!/bin/sh
exec pantheon-terminal -e "vim $@"
# Save this in a file "FILENAME", then ...
# export TEXT_AID_TOO_EDITOR="exec sh /full/path/to/FILENAME"
#
# For example,
# export TEXT_AID_TOO_EDITOR="exec sh /home/blott/tmp/launch-vim-in-pantheon-terminal"
@smblott-github
smblott-github / _drive
Created November 5, 2015 13:22
Rudimentary zsh completion for odeke-em/drive (a Google Drive utility)
#compdef drive drive-google
local cmnd desc
if [[ $CURRENT == 2 ]]
then
local -a options
drive |
grep '^ [a-z]' |
while read cmnd desc
do
#!/usr/bin/env python
# Find all nine-digit numbers whose digits are a permutation of the digits 1 to
# 9 and such that, taken independently:
#
# - the first digit is divisible by 1
# - the first two digits are divisible by 2
# - the first three digits are divisible by 3
# - and so on.
#
@smblott-github
smblott-github / rc
Last active December 26, 2018 10:40
Maintain the correct SSH agent config when using tmux remotely (after detach, reattach)
#!/bin/sh
# This goes in ~/.ssh/rc.
# It adds a symlink to the new $SSH_AUTH_SOCK under ~/.ssh/ssh-auth-socks/.
# The symlink is named after the current /dev/pts entry, so that we can find the correct link/agent to use later.
if [ -n "$SSH_TTY" ] && [ -n "$SSH_AUTH_SOCK" ]
then
mkdir -p $HOME/.ssh/ssh-auth-socks
ln -sf $SSH_AUTH_SOCK $HOME/.ssh/ssh-auth-socks/${SSH_TTY##*/}
@smblott-github
smblott-github / dwm.c
Created December 26, 2018 06:38
<alt-Tab> for dwm
/* this implements <alt-Tab> for dwm, put it in config.h */
static int alt_tab_count = 0;
/* focus and restack a client */
static void focus_restack(Client *c)
{ if (c) { focus(c); restack(selmon); } }
static void start_alt_tab(const Arg *arg)
{ alt_tab_count = 0; }
@smblott-github
smblott-github / simple-init-reaper.c
Created September 29, 2022 08:03
Simple zombie (init) process for docker.
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
void term(int signum)
{
printf("TERM: %d\n", getpid());