Skip to content

Instantly share code, notes, and snippets.

@romanvm
romanvm / sqlite_storage.py
Last active September 22, 2022 18:33
Simple key-value storage based on SQLite
# coding: utf-8
#
# Copyright (c) 2017 Roman Miroshnychenko <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@ianhattendorf
ianhattendorf / mount-encrypted.sh
Created June 26, 2017 01:20
LUKS helper scripts
#!/bin/sh
set -e
set -u
FILENAME="${1-encrypted.img}"
FILESIZE="${2-32M}"
# Create encrypted volume if it doesn't exist
if [ ! -f "$FILENAME" ]; then
@milanboers
milanboers / clone.bash
Last active April 24, 2025 16:49
Clone all repositories of a Github user
curl -s https://api.github.com/users/milanboers/repos | grep \"clone_url\" | awk '{print $2}' | sed -e 's/"//g' -e 's/,//g' | xargs -n1 git clone
@mihow
mihow / load_dotenv.sh
Last active April 22, 2025 02:18
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a
@jonbakerfish
jonbakerfish / loop_aria2.sh
Last active August 14, 2024 20:08
aria2 downloads a list of files, loop until all file are finished
#!/bin/bash
aria2c -j5 -i list.txt -c --save-session out.txt
has_error=`wc -l < out.txt`
while [ $has_error -gt 0 ]
do
echo "still has $has_error errors, rerun aria2 to download ..."
aria2c -j5 -i list.txt -c --save-session out.txt
has_error=`wc -l < out.txt`
sleep 10
@roastedlasagna
roastedlasagna / ListOfSubreddits_Alphabetical.txt
Last active December 12, 2024 02:36
Alphabetical list of subreddits with 50,000+ subscribers.
List of subreddits with 50,000+ subscribers, compiled by /u/roastedlasagna, in alphabetical order. Latest update Feb 4. Note that these are not necessarily marked NSFW!
/r/100yearsago
/r/1200isplenty
/r/2007scape
/r/2meirl4meirl
/r/3amjokes
/r/3Dprinting
/r/3DS
/r/4chan
@tsmetana
tsmetana / csumattr.sh
Created April 24, 2016 18:27
Store file checksum in the extended attribute
#!/usr/bin/bash
#
# Set/check SHA256 file checksum stored in the file's extended attributes
#
csum_attr="user.sha256sum"
check_path="."
action=""
usage() {
@orymate
orymate / pass.md
Created April 22, 2015 11:24
Password-store (pass)

This repository contains the database of password-store used by our Team to store passwords (mostly to be used in emergencies).

The database is encrypted for the PGP keys of all members, and can be read and written by any standard PGP implementation.

pass

The preferred tool to manage these passwords is

# See docs in http://git-annex.branchable.com/internals/hashing/ and implementation in http://sources.debian.net/src/git-annex/5.20140227/Locations.hs/?hl=408#L408
import hashlib
import struct
def hashdirlower(key):
hasher = hashlib.md5()
hasher.update(key)
digest = hasher.hexdigest()
return "%s/%s/" % (digest[:3], digest[3:6])
@scttnlsn
scttnlsn / README.md
Created August 21, 2012 16:13
Git as a key/value store

git-store

$ git init mystore
$ cd mystore

$ git store set foo "this is foo"
$ git store get foo
this is foo