Skip to content

Instantly share code, notes, and snippets.

@zertrin
zertrin / purge_logs.sh
Last active January 13, 2024 21:52 — forked from miohtama/purge_logs.sh
Remove old logs from Quassel SQLite database
#!/bin/bash
set -u
CURRENT_PATH="/var/lib/quassel/quassel-storage.sqlite"
BAK_PATH="/data/backup/quasselcore/quassel-storage.sqlite.bak"
DATE_TO_PRUNE='-180 day'
# This is an additional filter to only prune from a selected list of buffers,
@zertrin
zertrin / export_fig_helper.ipynb
Last active December 9, 2023 09:43
export_fig() helper for notebooks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zertrin
zertrin / gcash2ledger.py
Last active January 12, 2021 16:43 — forked from nonducor/gcash2ledger.py
A simple script to convert an (uncompressed) gnucash XML file to the ledger-cli format
#!/usr/bin/env python3
import os
import sys
import dateutil.parser
import xml.etree.ElementTree
nss = {'gnc': 'http://www.gnucash.org/XML/gnc',
'act': 'http://www.gnucash.org/XML/act',
'book': 'http://www.gnucash.org/XML/book',
@zertrin
zertrin / 0001-Update-Mapbox-API.patch
Created October 8, 2020 11:20
Git patch for Academic theme v4.8.0 - Update Mapbox API
From 1f751f8c68c9d67c0108747755d43c4449cd9a43 Mon Sep 17 00:00:00 2001
From: zertrin <zertrin@gmail.com>
Date: Thu, 8 Oct 2020 19:09:54 +0800
Subject: [PATCH] Update Mapbox API
---
assets/js/academic.js | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/assets/js/academic.js b/assets/js/academic.js
@zertrin
zertrin / .screenrc
Created July 10, 2020 06:03
.screenrc
term screen-256color
defscrollback 50000
bind ^x
bind x
bind K kill
bind h focus left
bind j focus down
bind k focus up
bind l focus right
bind t focus top
@zertrin
zertrin / .zshrc
Created November 4, 2019 04:05
Simple zshrc for zertrin theme
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@zertrin
zertrin / zertrin.zsh-theme
Created November 4, 2019 03:52
zertrin zsh theme
PROMPT='%{$fg_bold[red]%}%* %(!.%{$fg_bold[blue]%}.%{$fg_bold[yellow]%})%n@%m %{$fg_bold[cyan]%}%~$(git_prompt_info)% %(!.%{$fg_bold[red]%}#.%{$fg_bold[green]%}$)%{$reset_color%} '
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}"
@zertrin
zertrin / conda_compare.py
Created July 25, 2019 09:32 — forked from ChrisBarker-NOAA/conda_compare.py
Python Script to compare two conda environments
#!/usr/bin/env python2
"""
quicky script that compares two conda environments
can be handy for debugging differences between two environments
This could be made much cleaner and more flexible -- but it does the job.
Please let me know if you extend or improve it.
@zertrin
zertrin / useful_pandas_snippets.py
Created September 25, 2016 17:17 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@zertrin
zertrin / find-obsolete.sh
Created February 14, 2015 00:40
Find obsolete libs used by processes
function find-obsolete() {
local pid cmd file
for pid in $(\grep '(deleted)' /proc/*/maps | \grep -v '/dev/zero' | cut -d/ -f 3 | sort -un); do
cmd=$(ps -o comm -p $pid | tail -n 1)
for file in $(\grep '(deleted)' /proc/$pid/maps | \grep -v '/dev/zero' | awk '{print $6}' | sort -u); do
echo "$pid $cmd $file"
done
done | column -t
}