Skip to content

Instantly share code, notes, and snippets.

@riyad
riyad / firewall.npt6
Last active April 25, 2024 14:56
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 / 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 / sync-to-from
Last active December 18, 2022 15:57
Synchronize directories between computers using rsync (and SSH)
#!/usr/bin/env python3
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Synchronize directories between computers using rsync (and SSH).
#
# INSTALLATION:
# Save this script as something like `sync-to` somewhere in $PATH.
# Link it to `sync-from` in the same location. (i.e. `ln sync-to sync-from`)
@riyad
riyad / bootstrap_breadcrumbs_builder.rb
Created February 28, 2012 17:38
How to make breadcrumbs_on_rails render a Bootstrap compatible breadcrumb navigation
# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder.
# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions.
#
# BootstrapBreadcrumbsBuilder accepts a limited set of options:
# * separator: what should be displayed as a separator between elements
#
# You can use it with the :builder option on render_breadcrumbs:
# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "&raquo;" %>
#
# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class:
@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 / chrome-unsafe.plugin.zsh
Last active January 28, 2021 14:33
Open a Chrome window with a temporary profile and several security checks disabled.
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Loads an unsafe (i.e. with several security features disabled) instance of
# Chrome with a temporary profile (i.e. all data is lost once Chrome is closed)
chrome-unsafe() {
# for Homebrew Cask (see http://caskroom.io/) compatibility
local -a CHROME_PATHS
@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 / 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 / application_helper.rb
Created May 23, 2012 13:45
Render Rails assets to string
module ApplicationHelper
# thanks to http://blog.phusion.nl/2011/08/14/rendering-rails-3-1-assets-to-string/
# you may need to change the owner of the tmp/cache/* directories to the web servers user
# e.g. for Debian systems: `chown -R www-data:www-data tmp/cache/*`
def render_asset(asset)
Conferator::Application.assets.find_asset(asset).body.html_safe
end
end
#!/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