Skip to content

Instantly share code, notes, and snippets.

@riyad
riyad / firewall.npt6
Last active December 31, 2023 05:31
OpenWRT firewall script to configure network prefix translation for IPv6
#!/bin/sh
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
# SPDX-License-Identifier: MPL-2.0
#
# OpenWRT firewall script for configuring NPTv6 (network prefix translation).
#
# # Installation
#
@riyad
riyad / lsswap
Last active January 10, 2022 14:32
List all processes and how much swap they use.
#!/bin/bash
#
# Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
# SPDX-License-Identifier: MPL-2.0
#
# List all processes and how much swap they use.
# The output format is: "<swap used> : <pid> : <process name>"
#
# To get the top 10 processes using swap you can run:
@riyad
riyad / zrepl-run-and-wait-for-job-with-progress.sh
Last active December 26, 2022 19:07
Run a zrepl job and block/wait until it's finished.
#!/bin/bash
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Run a zrepl job and block/wait until it's finished (with progress indication).
#
# Note: this is basically a hack until there's a properly integrated solution for this.
# see https://github.com/zrepl/zrepl/issues/427
@riyad
riyad / email_from_imap.py
Created May 27, 2020 10:02
Scaffolding for fetching and parsing emails from IMAP
#!/usr/bin/python3
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Scaffolding for fetching and parsing emails from IMAP
import imaplib
import email.parser
import email.policy
@riyad
riyad / ffmpeg-cut
Last active November 17, 2018 22:16
Cut out a part of a media file within the given time stamps (without converting or reencoding!)
#!/bin/bash
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Cuts out a part of a media file within the given time stamps (without converting or reencoding!).
set -o nounset # complain when reading unset vars
# set -o xtrace # print every command as it's executed
@riyad
riyad / README.md
Last active April 6, 2017 15:56
a helper for creating list of 'HH:MM' for the `at` option of `Clockwork.every` with alignment and hour ranges

Use this in your clock.rb file:

require 'clockwork'

include ClockHelper

module Clockwork
  # ...
 every 1.day, "do_something", at: steps(every: 3.hours, aligned_at: '01:32') do
#!/usr/bin/env ruby
#
# Cleanup Sidekiq uniquejobs in Redis
# see https://github.com/mhenrixon/sidekiq-unique-jobs/issues/195
#
require 'bundler/setup'
require 'sidekiq/api'
DRY_RUN = true
@riyad
riyad / extract-audio.sh
Last active November 17, 2018 22:19
Extract audio from any media file ffmpeg can play into a new one (without converting or reencoding!)
#!/bin/sh
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Extract audio from any file ffmpeg can play (without converting or reencoding!).
if [[ $# -ne 3 ]]; then
echo "Error: wrong number of arguments"
@riyad
riyad / Application.mk
Last active September 23, 2020 13:38
Build Rsync for Android with Android NDK
APP_ABI := armeabi-v7a arm64-v8a
APP_OPTIM := release
APP_BUILD_SCRIPT := $(NDK_PROJECT_PATH)/Android.mk
APP_PLATFORM := android-29
@riyad
riyad / another-intermediate-ca_csr.json
Last active November 17, 2018 22:35
Using CFSSL building your own CA and generating service specific key, cert and chain files.
{
"CN": "Another Intermediate CA",
"hosts": [
""
],
"key": {
"algo": "ecdsa",
"size": 384
},
"names": [