Skip to content

Instantly share code, notes, and snippets.

@sometimesfood
sometimesfood / reencrypt.sh
Last active April 28, 2023 11:30
Small script that re-encrypts GPG-encrypted files with a new key
#!/bin/bash
checkusage() {
[[ $# -lt 2 ]] && err_exit 'Usage: reencrypt.sh KEY_ID FILE...'
}
err() { echo -e "$@" >&2; }
err_exit() {
err "$@"
@sometimesfood
sometimesfood / sync.bat
Last active October 26, 2022 09:51
Windows rsync batch file
@ECHO OFF
SETLOCAL
SET ARGC=0
FOR %%x IN (%*) DO SET /A ARGC+=1
IF NOT %ARGC%==3 (
ECHO Usage: %~n0 USER TARGET_HOST TARGET_DIR
GOTO :eof
)
@sometimesfood
sometimesfood / anagrams.rb
Created October 3, 2020 11:45
Simple anagram finder in Ruby
#!/usr/bin/env ruby
require 'set'
def usage
puts 'usage: #{$PROGRAM_NAME} WORD...'
exit(1)
end
usage if ARGV.length.zero?
@sometimesfood
sometimesfood / diskcheck.md
Last active July 13, 2018 09:00
Simple shell script to test new HDDs (moved)

Keybase proof

I hereby claim:

  • I am sometimesfood on github.
  • I am sometimesfood (https://keybase.io/sometimesfood) on keybase.
  • I have a public key whose fingerprint is 3219 8348 BA23 87DC 3A28 C055 66EB 4AE8 3C43 CFF5

To claim this, I am signing this object:

@sometimesfood
sometimesfood / handy-aliases.sh
Last active June 1, 2017 14:42
handy shell aliases
playrar () { unrar p -inul $* | mplayer -noidx -cache 30000 - }
alias spindown="sdparm --flexible --command=stop"
alias diff2html="pygmentize -f html -O full,style=emacs -l diff"
alias wdiff2html="pygmentize -f html -O full,style=emacs -l wdiff"
@sometimesfood
sometimesfood / goquery-demo.go
Last active November 18, 2016 10:33
Simple goquery demo
package main
import (
"log"
"fmt"
"github.com/PuerkitoBio/goquery"
)
@sometimesfood
sometimesfood / hurt-me-plenty
Created March 19, 2012 18:39
Bash script to reboot UEFI systems to Windows
#!/bin/bash
set -e
WIN_REGEXP='Boot\([[:digit:]]*\)\* Windows Boot Manager$'
WIN_BOOT_ENTRY=$(efibootmgr | grep -e "${WIN_REGEXP}" | head -1)
WIN_BOOT_NUM=$(echo ${WIN_BOOT_ENTRY} | sed -e "s/${WIN_REGEXP}/\1/g")
efibootmgr --quiet --bootnext ${WIN_BOOT_NUM}
reboot
@sometimesfood
sometimesfood / chef-standalone-bootstrap.sh
Last active September 26, 2015 15:17
Chef standalone bootstrap with chef-admin-essentials
#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
sudo apt-get install -qy curl git-core lsb-release chef
mkdir ~/cookbooks
cd ~/cookbooks
echo '*~' > .gitignore
git init
git add .
git commit -am 'Initial commit'
@sometimesfood
sometimesfood / grml-console.sh
Created May 12, 2011 11:37
Set up grml console config
#!/bin/bash
mkdir -p ~/.dotfiles
git clone git://git.grml.org/grml-etc-core.git ~/.dotfiles/grml-etc-core
cd ~/.dotfiles/grml-etc-core
export LAST_RELEASE=$(git describe)
git checkout $LAST_RELEASE
ln -sf ~/.dotfiles/grml-etc-core/etc/grml/screenrc_generic ~/.screenrc
ln -sf ~/.dotfiles/grml-etc-core/etc/vim/vimrc ~/.vimrc
ln -sf ~/.dotfiles/grml-etc-core/etc/zsh/zshrc ~/.zshrc
touch ~/.zshrc.local