Skip to content

Instantly share code, notes, and snippets.

@aliang
aliang / Mac SSH Autocomplete
Created June 14, 2011 07:14
Add auto complete to your ssh, put into your .bash_profile
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
# vim: set ft=sshconfig cc=0 fdm=marker:
host *
controlmaster auto
controlpath ~/.ssh/connections/%r_%h_%p
controlpersist 4h
host laleh# {{{
user scp1
hostname 192.168.1.128
port 19217
@noonien
noonien / evil
Created July 19, 2012 12:07
Simple bash prank
# This script disables execution of commands and echoes messages to the user, to disable type: "wat"
#
# To install this, you need to have access to the user's home directory.
# sudo -u <user> -i sh -c 'cp /path/to/evil ~/.evil && cp ~/.bashrc ~/.bashrc.ebak && echo ". ~/.evil" >> ~/.bashrc'
shopt -s extdebug
function disable_evil() {
rm ~/.evil
rm ~/.bashrc
@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
# 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])
@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

@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() {
@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
@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
@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