Skip to content

Instantly share code, notes, and snippets.

View bAndie91's full-sized avatar

Andreas Hrubak bAndie91

View GitHub Profile
@vi
vi / split_by_silence.sh
Last active February 23, 2024 13:18
Using FFmpeg to split multimedia file into parts based on audio volume level
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then
@jalaziz
jalaziz / 999-aws-ebs-nvme.rules
Last active September 28, 2023 20:05
CoreOS AWS EBS NVMe udev rules
# Copyright (C) 2018 Jameel Al-Aziz
# Modified for simplicification and use within CoreOS.
#
# Copyright (C) 2006-2016 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
@markasoftware
markasoftware / mnemonic.sh
Created January 19, 2018 04:20
Mnemonic password generator
#!/bin/bash
# help text
[[ $1 == *-h* || -z $1 ]] && echo 'Usage: mnemonic.sh word_count [min_length max_length]' && exit
# Where is the wordlist?
[[ -e /usr/dict/words ]] && dict_path='/usr/dict/words' || dict_path='/usr/share/dict/words'
# Remove words with apostrophes, capitalization, or outside the correct length range
sed -r "/^[a-z]{${2:-5},${3:-8}}$/!d" "$dict_path" > /tmp/mnemonic-words
word_count=$(wc -l < /tmp/mnemonic-words)
# print estimated entropy per word
@noporpoise
noporpoise / unifieddiff.py
Last active November 14, 2023 18:59
Apply unified diff patches in pure python2/3
#!/usr/bin/env python
# coding=utf-8
# License: Public domain (CC0)
# Isaac Turner 2016/12/05
from __future__ import print_function
import difflib
import re
@wenjianhn
wenjianhn / test_socket_prio_and_tos.c
Created January 29, 2015 03:30
Test if setsockopt(SO_PRIORITY) sets the IP type-of-service (TOS) field or not.
#include <assert.h>
#include <netinet/ip.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
void test_setsockopt()
{
int priority = 6;
@vi
vi / filedistance
Last active May 2, 2019 07:31
Calculate "distance" between files using compression as metric
#!/bin/bash
COMPRESSOR="xz --lzma2=dict="
OVERHEAD=60
if [ -z "$2" ]; then
echo "Usage: filedistance file1 file2"
echo " Outputs similarity metric using between two small files using compression"
echo " 0 - completely similar; 1 - completely dissimilar"
exit 1
@vi
vi / unix2udp.c
Created October 22, 2013 16:50
Turn a pair of packet AF_UNIX sockets into a UDP connection Primary use case: forward individual UDP stream into other network namespace though the shared filesystem (TCP case can be done with socat).
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
@vi
vi / dbus-shell-service.pl
Created April 5, 2012 02:44
Simple DBUS service that calls your command lines and returns their output
#!/usr/bin/perl -w
# Vitaly "_Vi" Shukela 2012 License=MIT
use strict;
package DbusShellService;
use Net::DBus::Exporter qw(org.vi_server.DbusShellService);
use base qw(Net::DBus::Object);