Skip to content

Instantly share code, notes, and snippets.

View wernerb's full-sized avatar
🏠
Working from home

Werner Buck wernerb

🏠
Working from home
View GitHub Profile
@wernerb
wernerb / gist:6a52e77b0b8974714263
Last active August 28, 2015 08:31 — forked from evandrix/gist:1076041
Using bcrypt to secure passwords in a Perl application
#!/usr/bin/perl
use Crypt::Eksblowfish::Bcrypt;
use Crypt::Random;
$password = 'bigtest';
$encrypted = encrypt_password($password);
print "$password is encrypted as $encrypted\n";
print "Yes the password is $password\n" if check_password($password, $encrypted);
print "No the password is not smalltest\n" if !check_password('smalltest', $encrypted);
@wernerb
wernerb / keybase.md
Created March 24, 2014 21:29
My keybase.io proof

Keybase proof

I hereby claim:

  • I am wernerb on github.
  • I am buck (https://keybase.io/buck) on keybase.
  • I have a public key whose fingerprint is 70BB 5523 42D5 3EC8 C22D F4C5 3634 04C4 8767 E6F6

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am wernerb on github.
* I am buck (https://keybase.io/buck) on keybase.
* I have a public key whose fingerprint is 82BA F93B ADC2 9352 411B D2D2 2E3F 8B94 6AF1 B74E
To claim this, I am signing this object:
@wernerb
wernerb / async.sh
Created June 29, 2014 21:25
Executes commands asynchronously while keeping stdout/stderr. Does not use tail -f, stops when the command stops. Works in POSIX shells.
############
# Executes commands asynchronously while keeping stdout/stderr.
# If the shell quits or fails then the script can be started again and it
# will read in stdout again from the beginning and continue.
#
# Author: Werner Buck
############
# Command to execute asynchronously.
#!/bin/bash
set +u
shopt -s xpg_echo
shopt -s expand_aliases
unset PATH JAVA_HOME LD_LIBRARY_PATH
function abort {
echo "aborting: $@" 1>&2
exit 1
}
function default {
@wernerb
wernerb / jclouds_posix.sh
Last active August 29, 2015 14:03
This is a POSIX compatible init script for jclouds
#!/bin/sh
export INSTANCE_NAME="test"
export INSTANCE_HOME="/tmp/test"
export LOG_DIR="$INSTANCE_HOME"
forget () {
mkdir -p "$LOG_DIR"
if test ! -f "$LOG_DIR/pid" ; then
nohup "$INSTANCE_HOME/$INSTANCE_NAME.sh" > "$LOG_DIR/stdout.log" 2> "$LOG_DIR/stderr.log" &
echo $! > "$LOG_DIR/pid"
else
---
clusters:
#Static website running nginx and displaying the
smallweb:
state:
provider: private
instance-template: small-centos-6.5
nodes: 3
dependencies: []
cluster-groups: []
@wernerb
wernerb / wbuck.zsh-theme
Created December 18, 2014 11:01
Theme for oh-my-zsh.
# oh-my-zsh w-buck Bureau Theme
### CUSTOM
_COL="red"
_HR="(" #❯
_HL=")" #❮
_LEFT="%{$fg[$_COL]%}$_HR%{$reset_color%}"
_RIGHT="%{$fg[$_COL]%}$_HL%{$reset_color%}"
### NVM
#!/bin/bash
while :
do
clear
git --no-pager log --graph --pretty=oneline --abbrev-commit --decorate --all $*
sleep 1
done
@wernerb
wernerb / wgetmirror.sh
Last active December 27, 2015 23:29
Uses strictly wget and grep to mirror a remote HTTP location recursively. Deletes old files. Supports http auth and self-signed certificates. Strictly POSIX compliant so that it works in "dash" as well as in "bash". Handy to use on arm devices that need syncing but do not have rsync or ssh. Currently used to sync multiple kobo ereaders.
#!/bin/bash
################ CONFIG ###################
username="user"
#HTTP Auth username
password="password"
#HTTP Auth password
basedirname="/directory/to/Sync"
#CA certificate in PEM format
certificate="/directory/to/cert.crt"
#url = Set to the https server running an nginx or apache file listing. Make sure its urlencoded and don't forget trailing slash.