Skip to content

Instantly share code, notes, and snippets.

@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?

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 / goquery-demo.go
Last active November 18, 2016 10:33
Simple goquery demo
package main
import (
"log"
"fmt"
"github.com/PuerkitoBio/goquery"
)
@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
)
#!/usr/bin/env ruby
require 'minitest/autorun'
require 'erb'
class ErbTemplate
def initialize(hash)
hash.each do |k, v|
instance_var = "@#{k}"
@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
@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 / 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 / diskcheck.md
Last active July 13, 2018 09:00
Simple shell script to test new HDDs (moved)
@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