Skip to content

Instantly share code, notes, and snippets.

@riyad
riyad / ffmpeg-mp3-converter.rb
Last active November 17, 2018 22:14
Small scripts to transcode any file VLC or ffmpeg can play to mp3.
#!/usr/bin/env ruby -rubygems
#
# Author: Riyad Preukschas <riyad@informatik.uni-bremen.de>
# License: Mozilla Public License 2.0
#
# Transcode any file ffmpeg can play to mp3.
require 'optparse'
require 'shellwords'
@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 / 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 / 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": [
@riyad
riyad / android-backup.md
Last active November 22, 2018 11:35
Backup and Restore your Android Phone With ADB

Android-Backup

NOTE: this project has moved to https://github.com/riyad/android-backup

Backup and restore your Android phone with ADB (and rsync)

It will backup and restore all of your /sdcard directory and any other storage (e.g. an external SD Card) mounted within /storage except for emulated and self). Assuming you're using also something like Titanium Backup you'll be able to backup and restore all your apps, settings and data.

@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
@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 / 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 / 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 / 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`)