Skip to content

Instantly share code, notes, and snippets.

@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 / .irbrc
Created January 22, 2011 19:56
my ~/.irbrc
require 'irb/completion'
require 'irb/ext/save-history'
require 'pp'
# Load the readline module.
IRB.conf[:USE_READLINE] = true
# Remove the annoying irb(main):001:0 and replace with >>
IRB.conf[:PROMPT_MODE] = :SIMPLE
@sometimesfood
sometimesfood / osx-dot-emacs
Created February 24, 2011 12:05
OS X minimal .emacs
(defun macosx-p()
(string= "darwin" system-type))
(when (macosx-p)
(setq mac-option-key-is-meta nil)
(setq mac-command-key-is-meta t)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier nil)
(set-default-font "Menlo-Regular-14")
(blink-cursor-mode 1)
@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
@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 / 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 / diskcheck.md
Last active July 13, 2018 09:00
Simple shell script to test new HDDs (moved)
@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 / asciidoctor-callout-bug.asciidoc
Last active August 29, 2015 14:22
asciidoctor #1360: Callouts in code listings break syntax when not using ':icons: font'
@sometimesfood
sometimesfood / system_runner_spec.rb
Last active August 29, 2015 14:23
Ruby Kernel methods: stubless stubs
#!/usr/bin/env ruby
require 'minitest/autorun'
class SystemRunner
def ls
system 'ls'
end
end