Skip to content

Instantly share code, notes, and snippets.

Avatar

Mikael Göransson mgor

View GitHub Profile
View pydmesg
#!/usr/bin/env python
# coding=utf8
# Copyright (C) 2010 Saúl ibarra Corretgé <saghul@gmail.com>
#
"""
pydmesg: dmesg with human-readable timestamps
"""
View 02update-development-db.sh
#!/usr/bin/env bash
cmd="mysql -u ${MYSQL_USER} --password=${MYSQL_PASSWORD} ${MYSQL_DATABASE} -e"
table_prefix=$($cmd "show tables;" -N -B 2>/dev/null | tail -1 | awk -F\_ '{print $1}')
$cmd "update ${table_prefix}_options set option_value = 'http://localhost' where option_name in ('siteurl', 'home');" 2>/dev/null
View tree-structure.txt
.
├── env
│ ├── config
│ │ ├── 01production_dump.sql
│ │ ├── 02update-development-site.sh.sh
│ │ └── php.ini-development
│ └── dev-env.sh
└── src
└── wp-content
├── plugins
View prepare-commit-msg.sh
#!/usr/bin/env bash
commit_message=$1
commit_type=$2
commit_hash=$3
prefix="[commit prefix]"
heading=$(head -1 ${commit_message})
if [ -z "${heading}" ]
View dev-env.sh
#!/usr/bin/env bash
DATABASE_CONTAINER="dev-db"
WEBSERVER_CONTAINER="dev-web"
MYSQL_ROOT_PASSWORD="my-secret"
MYSQL_USER="dev"
MYSQL_PASSWORD="dev"
MYSQL_DATABASE="wordpress"
docker pull wordpress:latest
docker pull mysql:${MYSQL_VERSION}
View Makefile
.PHONY = all install reinstall uninstall test _wrapped_stow _pre_stow _stow _post_stow _stow_ignore _install_args _reinstall_args _uninstall_args _test_args
all:
$(error You probably want to run 'make test' first)
_stow_ignore:
$(foreach file,$(wildcard *),$(eval ARGS += --ignore=$(file)))
_stow: _stow_ignore
@stow -t $(HOME) -v $(ARGS) .
View measure-wireless.sh
#!/usr/bin/env bash
wifi_interface="$(nmcli d | awk '$2 ~ /wifi/ {print $1}')"
description="${1:-${wifi_interface}}"
sudo true
samples=10
sequences=($(seq 1 ${samples}))
@mgor
mgor / dice-pwgen.sh
Last active Jul 4, 2016
diceware password generator (as secure as $RANDOM would be?)
View dice-pwgen.sh
#!/usr/bin/env bash
DICTIONARY="/tmp/diceware.lst"
DICTIONARY_URL="http://world.std.com/~reinhold/diceware.wordlist.asc"
WORDS="3"
COUNT="1"
SEPARATOR="-"
while getopts ":w:n:s:" optchar; do
case "${optchar}" in
w)
View trouf.link
@mgor
mgor / test_unicode.sh
Last active Dec 2, 2016
test if terminal supports unicode
View test_unicode.sh
test_unicode() {
echo -ne "\xe2\x88\xb4\033[6n\033[1K\r"
# shellcheck disable=SC2034
read -d R foo
echo -ne "\033[1K\r"
echo -e "${foo}" | cut -d \[ -f 2 | cut -d";" -f 2 | (
read UNICODE
[[ $UNICODE -eq 2 ]]
) 2>/dev/null
}
You can’t perform that action at this time.