Skip to content

Instantly share code, notes, and snippets.

@fniessink
fniessink / .bashrc
Last active August 15, 2023 19:33
Automatically activate and deactivate Python virtual envs on change directory
# Include this in your .bashrc:
function activate_virtualenv () {
[[ -n $VIRTUAL_ENV ]] && deactivate;
venv=`python3 ~/.find_venv.py .`;
[[ ! -z "$venv" ]] && . $venv/bin/activate;
return 0
}
function cd () {
@cvn
cvn / update_ip.py
Last active November 11, 2022 16:25
A script for updating dynamic DNS using Opalstack's API
#!/usr/bin/env python3
# update_ip.py - A script for updating dynamic DNS using Opalstack's API
# by Chad von Nau
#
# * Python 2 and 3 compatible.
# * Supports IPv4 and IPv6 addresses.
# * Records the last IP in a JSON file and only calls the API if the IP has changed.
#
# Instructions:
@scottnunemacher
scottnunemacher / dovecot-doveadm-sync.md
Last active November 9, 2023 18:45
Sync (migrate) a Dovecot Email Account from One Dovecot Server to Another

Sync (migrate) a Dovecot Email Account from One Dovecot Server to Another

The man doveadm-sync pages are cryptic and not very well explained, as well they are missing quality real-world examples.

This gist aims to give some clarity and explanation.

Here is the command I got to successfully transfer (and sync backwards too) an email account from an old Dovecot email server to a new Dovecot email server:

To my knowledge, both servers must have a matching account already setup for this to work:

@darencard
darencard / gnuplot_quickstart.md
Created August 31, 2017 14:20
A quick-start guide for using gnuplot for in-terminal plotting

A quick-start guide for using gnuplot for in-terminal plotting

Sometimes it is really nice to just take a quick look at some data. However, when working on remote computers, it is a bit of a burden to move data files to a local computer to create a plot in something like R. One solution is to use gnuplot and make a quick plot that is rendered in the terminal. It isn't very pretty by default, but it gets the job done quickly and easily. There are also advanced gnuplot capabilities that aren't covered here at all.

gnuplot has it's own internal syntax that can be fed in as a script, which I won't get into. Here is the very simplified gnuplot code we'll be using:

set terminal dumb size 120, 30; set autoscale; plot '-' using 1:3 with lines notitle

Let's break this down:

@kvaps
kvaps / rspamd-lists.md
Last active March 28, 2024 23:51
Howto create local whitelists and blacklists for Rspamd

Local whitelists and blacklists for Rspamd

  • cd /etc/rspamd
  • create rspamd.conf.local
  • create lists:
touch local_bl_from.map.inc local_bl_ip.map.inc local_bl_rcpt.map.inc \
local_wl_from.map.inc local_wl_ip.map.inc local_wl_rcpt.map.inc
  • change permissions:
@alptugan
alptugan / CONDTIONALS
Last active June 4, 2023 12:21
Sonic Pi Cheat Sheet
So, let’s flip a coin: if it’s heads, play a drum, if it’s tails, play a cymbal. Easy. We can emulate a coin flip with our one_in function (introduced in the section on randomness) specifying a probability of 1 in 2: one_in(2). We can then use the result of this to decide between two pieces of code, the code to play the drum and the code to play the cymbal:
loop do
if one_in(2)
sample :drum_heavy_kick
else
sample :drum_cymbal_closed
end
@jplhomer
jplhomer / disable-comments.sh
Created February 25, 2015 16:38
Disable all comments/pings in WordPress with WP-CLI
$ wp post list --format=ids | xargs wp post update --comment_status=closed
# Output:
# Success: Updated post 2514.
# Success: Updated post 2511.
# Success: Updated post 2504.
# Success: Updated post 2499.
# Success: Updated post 2441.
# etc...
@nifl
nifl / grok_vi.mdown
Created August 29, 2011 17:23
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@cowboy
cowboy / github_post_recieve.php
Created October 11, 2010 02:04
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi