Skip to content

Instantly share code, notes, and snippets.

View BachoSeven's full-sized avatar
🎩
thinking

Francesco Minnocci BachoSeven

🎩
thinking
View GitHub Profile
@pedrominicz
pedrominicz / peterson.c
Last active November 25, 2022 20:38
Peterson's algorithm in C.
#include <pthread.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// This program illustrates the use of Peterson's algorithm to synchronize
// multiple threads.Two new threads are created and alternate writing to the

Vim will move the cursor to the beginning of an object after invoking operator upon it. From an interactive editing perspective this may be considered annoying however it is the consistent choice as operators can be destructive. As such restoring the cursor to its prior position after invoking an operator on an object may not make sense.

There are many ways possible to alter this behaviour to your preference with mappings and/or scripting. But with custom operator mappings this can be particularly ugly.

if ((! ${+precmd_functions[(r)__vte_osc7|title_precmd]}${+preexec_functions[(r)title_preexec]}))
then
function title {
[[ ( ! -o interactive || $- != *i* ) || $EMACS == *t* ]] && return
emulate -L zsh -o promptsubst -o extendedglob
: ${2=$1}
case ${TERM} in
[aEkx]term*|(#i)rxvt*|(#i)vte*|(#i)cygwin*|(#i)[pk][ui]tty*)
print -Pn "\e]2;$2:q\a"; print -Pn "\e]1;$1:q\a" ;;
@lewisthompson
lewisthompson / dedupe_maildir.py
Created January 19, 2019 19:59
Part of dedupe_maildir.sh
#!/usr/bin/env python
import sys
tuids = {}
xtuids_filename = sys.argv[1]
dupes1_filename = sys.argv[2]
dupes_filename = sys.argv[3]
origs_filename = sys.argv[4]
@lewisthompson
lewisthompson / dedupe_maildir.sh
Last active July 28, 2022 09:05
Dedupe a Maildir with X-TUID headers
#!/usr/bin/env bash
set -euo pipefail
# After some strange combination of OfflineIMAP & mbsync/isync created a whole
# bunch of duplicate messages in my Fastmail account I had to start cleaning things
# up. I discovered that the duplicates all had X-TUID headers and were showing up
# totally out of order in the Fastmail UI. I now run mbsync with `CopyArrivalDate yes`
# which appears prevents this from occurring again.
#
# I found that every message with an X-TUID header had a matching message without
@Pablo1107
Pablo1107 / mpc-fade
Last active September 8, 2023 20:24
A script to fade volume when toggling MPD via mpc based on lcpz's script.
#!/bin/sh
# A script to fade volume when toggling MPD via mpc
mpc=`which mpc`
SINKAPP="mpd"
SECS=2.0
sinks=$(pactl list sink-inputs)
@Lartza
Lartza / tmux.conf
Last active May 9, 2024 23:42 — forked from anonymous/tmux.conf
vim friendly tmux configuration
#Prefix is Ctrl-a
set -g prefix C-a
bind C-a send-prefix
unbind C-b
set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1
#Mouse works as expected
//
// Author: Jonathan Blow
// Version: 1
// Date: 31 August, 2018
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//
@keeferrourke
keeferrourke / latexcompile
Created May 28, 2018 04:03
Simple bash script to compile a LaTeX document with pdflatex, and clean up auxillary output files.
#!/bin/bash
#
# latexcompile
# Keefer Rourke <mail@krourke.org>
#
# To the extent possible under law, the person who associated CC0 with
# latexcompile has waived all copyright and related or neighboring rights
# to latexcompile.
#
# See <http://creativecommons.org/publicdomain/zero/1.0/> for a copy of