Skip to content

Instantly share code, notes, and snippets.

@smoser
smoser / example-output
Last active January 17, 2021 17:08
shell benchmarks: compare grep and pipe versus awk or sed only
LANG=C
3156 out.full
76 out.100
50 out.50
20 out.20
3302 total
awk: /usr/bin/gawk
sed: /bin/sed
grep: /bin/grep
----
@smoser
smoser / cloud-to-lxd
Last active January 10, 2019 16:07
lxc tools. Random tools around lxc.
#!/bin/bash
VERBOSITY=0
TEMP_D=""
UC_PREP="/usr/share/lxc/hooks/ubuntu-cloud-prep"
error() { echo "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
Usage() {
#!/bin/sh
##
## this is run on new cloudatcost.com system, to get me more set up
## disables root password login and adds my user.
##
bdimage="http://bazaar.launchpad.net/~smoser/+junk/backdoor-image/download/head:/backdoorimage-20121004180823-pi43gdnl3fbp82la-1/backdoor-image"
me_ssh_id="smoser"
gecos="Scott Moser"
user="smoser"
@smoser
smoser / mini-ec2-init
Created September 24, 2014 20:59
mini ec2 init
#!/bin/bash
set -f
NAME="mini-ec2-init"
OIFS="$IFS"
CONSOLE="/dev/console"
LOG="/var/log/${NAME}.log"
MD_URL="http://169.254.169.254/2009-04-04/"
VERBOSITY=${VERBOSITY:-0}
HAS_USERDATA=""
@smoser
smoser / mount-private
Last active May 22, 2018 02:33
mount-private: just a tool to help mount an encrypted dir
#!/bin/bash
# https://gist.github.com/smoser/1f1d7d78fdbb36dce590
VERBOSITY=0
Usage() {
cat <<EOF
Usage: ${0##*/} ecryptfs-dir target-mountpoint
options:
-w | --wrapped-passphrase-file F wrapped passphrase file
this would ormally be ~/.ecryptfs/wrapped-passphrase
@smoser
smoser / README.md
Last active January 31, 2016 15:57
build-pentadactyl: build pentadactyl from git or mercurial on ubuntu

Build Pentadactyl on Ubuntu

This builds pentadactl on Ubuntu in a simple './build-pentadactyl'. I use it since daily builds have been sporadic.

Issues

  • issue 95: not working entirely correctly on firefox 42
  • issue 79: signing enforcement of firefox 44 and later (warning only in 42, 43) will need to be addressed.
  • issue 99: Future development of Pentadactyl
@smoser
smoser / README.md
Last active January 18, 2019 21:23
xvim: run 'vim' in a new gnome-terminal. optionally block until exit (useful with pentadactyl)

xvim

When I want to run vim in a new terminal, I prefer vim inside gnome-terminal rather than gvim. Thats easily enough accomplished with

gnome-terminal --execute vim "$@"

However, sometimes you want to block until vim is done. One example of this is pentadactl's editor (invoked with ctrl-i) older versions of gnome-terminal had --disable-factory, that would block until the command executed returned. Newer versions have dropped that

@smoser
smoser / README.md
Last active April 3, 2017 18:53
give user sudo access without password

sudo stuff

  • no-sudo-password: give user sudo without password for any command

  • mic-lxd: example of how to give user ability to run mount-image-callback with either mchroot or uns-switch.

@smoser
smoser / upgrade-userdata.yaml
Created May 14, 2015 19:40
example user-data
#cloud-config
apt_upgrade: true
packages: [ bzr, vim-nox, git-core ]
apt_reboot_if_required: true
ssh_import_id: [smoser]
@smoser
smoser / README.md
Last active October 26, 2023 16:39
upgrade [apt-get update/upgrade system and log / time ]

upgrade

This is a simple script (scripts) to run the typical apt-get upgrade, and collect the logs to a directory.

Also included here is 'purge-kernels' to get rid of old kernels in your /boot.