Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am einarjh on github.
  • I am einarjh (https://keybase.io/einarjh) on keybase.
  • I have a public key whose fingerprint is 4DA1 BF91 DE68 5B78 1552 7782 C5D7 F8B7 5D6F FD72

To claim this, I am signing this object:

@einarjh
einarjh / gist:d583a340798464199ab8
Created November 11, 2014 14:30
make temporary password in bash
# Explanation haiku:
# semi-random temp password
# easy to remember, type
# not very secure
function maketemppassword() {
part1="$(awk 'length==8' /usr/share/dict/words | grep -v '[^[:alpha:]]' | shuf -n 1 | tr '[:upper:]' '[:lower:]')"
part2="$(< /dev/urandom tr -dc 0-9 | head -c${1:-2};echo;)"
part3="$(< /dev/urandom tr -dc A-Z | head -c${1:-2};echo;)"
echo "${part1}-${part2}_${part3}"
}
@einarjh
einarjh / Windows10-Setup.ps1
Last active August 29, 2015 14:26 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
function makethumbnail() {
filename="$(basename ${1} .mp4)"
# Use the wadsworth constant to set the time when we want the thumbnail from
# http://knowyourmeme.com/memes/the-wadsworth-constant
wadsworth=$(echo "${2} * 0.3 / 1 * 60" | bc)
echo "INFO: Creating thumbnail for ${1} by skipping ${wadsworth} seconds ahead."
if [ ! -f ${filename}.jpg ]; then
${FFMPEGPATH}/ffmpeg -loglevel ${LOGLEVEL} -ss ${wadsworth} -i ${1} -vframes 1 -an ${filename}.jpg
if [ "${?}" -ne 0 ]; then
echo "ERROR: Creation of thumbnail for ${1} failed."
@einarjh
einarjh / minecraft.service
Last active August 3, 2017 12:29
A very basic, but functional, minecraft service description for systemd.
[Unit]
Description=Minecraft Server
[Service]
# Adjust these to your liking, the service assumes that minecraft_server.jar and eula.txt already
# exists in this directory, and that the User specified has write access to the WorkingDirectory
#
# To send commands to minecraft, do:
# echo "command" >> minecraft-input
@einarjh
einarjh / backup-wallet.sh
Created June 1, 2017 18:15
A tiny script to make a backup of your zcash wallet
#!/bin/bash
export LC_ALL=en_US.utf-8
Repo="username@remote:path" # Path to premade remote repo, preferably with encryption
Backupdir="/path/to/backup" # Same as exportdir in zcash.conf
Date="$(date +%Y-%m-%d)"
Options="--compression lz4 --chunker-params 19,23,21,4095"
zcash-cli z_exportwallet keysbackup
zcash-cli backupwallet walletbackup
@einarjh
einarjh / interfaces
Created August 2, 2017 18:12
Set static IPv6 address on Debian and disable RA and privacy extensions
iface eth0 inet6 static
address 2001:700:1d00:beef::13
netmask 64
gateway 2001:700:1d00:beef::1
accept_ra 0
privext 0
@einarjh
einarjh / minecraft.service
Last active June 10, 2018 12:30
Simple Minecraft service take 2 (screen based)
# This unit file is suitable for running as a normal user, as a user unit
# I.e. put the file in $HOME/.config/systemd/user and do systemctl --user daemon-reload
# Then start it with systemctl --user start minecraft.service
# Your user needs permission to run units while not logged in (linger):
# sudo systemctl enable-linger <your user>
[Unit]
Description=Minecraft Server
After=network.target
@einarjh
einarjh / weechat.service
Last active November 12, 2020 16:01
SystemD user service for launching weechat in a screen on boot
# Save as ~/.config/systemd/user/weechat.service
# Remember that you need to allow background processes to keep running
# even when there are no interactive sessions:
# sudo loginctl enable-linger username
# And then:
# systemctl --user daemon-reload && systemctl --user --now enable weechat.service
[Unit]
Description=weechat session
After=bitlbee.service
@einarjh
einarjh / getlatestmcsnapshot.bash
Created July 10, 2019 20:32
A script that downloads the latest Minecraft snapshot and makes it available for Multicraft. Requires wget and jq
minecraft@minecraft:~$ cat bin/getlatestminecraftsnapshot.bash
#!/bin/bash
# A quick and dirty script to fetch the latest minecraft snapshot for multicraft
cd ~/multicraft/jar
VERSION_URL="https://launchermeta.mojang.com/mc/game/version_manifest.json"
LATEST_VER=$(wget -qO - "${VERSION_URL}" | jq -r .latest.snapshot)
# Our CURRENT_VER is stored in current_ver and we don't need no stinking error messages
source current_snap > /dev/null 2>&1