Skip to content

Instantly share code, notes, and snippets.

View flying-sausages's full-sized avatar
🕴️
🌭

flying-sausages

🕴️
🌭
View GitHub Profile
@soliton-
soliton- / vcompare
Last active April 19, 2021 18:22
version compare for bash
#!/bin/bash
# compare version $1 and $2; returns 0 if version $1 >= $2
# versions must be numeric only
vcompare() {
local v1=$1 v2=$2 v1a v2a n1 n2 max i
IFS=. read -ra v1a <<< "$v1"; IFS=. read -ra v2a <<< "$v2"
((n1=${#v1a[@]}, n2=${#v2a[@]}, max=(n1 > n2 ? n1 : n2)))
for ((i=0; i<max; ++i))
do
@daniel-j
daniel-j / README.md
Last active June 4, 2024 10:51
Converts images in a directory to a comic/manga EPUB3 ebook. Can be used to convert extracted CBZ/CBR to EPUB3.

images2epub.py

Converts a directory of images into a modern EPUB3 ebook. Use a tool to extract CBZ/CBR/CBT files and then run this program to generate a nice fixed-layout EPUB ebook of it. You can optionally set the reading direction to right-to-left (e.g. for manga). For Kobo ereaders, use the file extension .kepub.epub to get the modern reader and correct reading direction.

Usage

Install dependencies with pip install imagesize lxml

@mminer
mminer / formatBytes.swift
Last active April 19, 2023 00:59
Formats bytes into a more human-readable form (e.g. MB).
import Foundation
func format(bytes: Double) -> String {
guard bytes > 0 else {
return "0 bytes"
}
// Adapted from http://stackoverflow.com/a/18650828
let suffixes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
let k: Double = 1000
@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active June 18, 2024 05:42
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"
@amitchhajer
amitchhajer / Count Code lines
Created January 5, 2013 11:08
Count number of code lines in git repository per user
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n