Skip to content

Instantly share code, notes, and snippets.

View rroemhild's full-sized avatar

Rafael Römhild rroemhild

View GitHub Profile
@rroemhild
rroemhild / gist:190931
Created September 22, 2009 08:41
Tidy decimal places after comma
def tidyDecimalPlaces(value):
retval = str(value)
if ',' in value:
post,pre = value.split(',')
if len(pre) == 0:
retval = "%s,00" % post
elif len(pre) == 1:
pre = "%s0" % pre
retval = "%s,%s" % (post,pre)
else:
@rroemhild
rroemhild / gist:190970
Created September 22, 2009 10:16
simple shell script log function
# Vars for log()
LOGGER="/usr/bin/logger" # Path to logger
FACILITY="LOCAL4" # Syslog facility
PROG="´basename $0´" # Program name
SYSLOG="YES" # Write to Syslog? (YES/NO)
VERBOSE="NO" # Write to STDOUT? (YES/NO)
# Function: log()
# Usage: log priority "message"
log()
@rroemhild
rroemhild / pymod_test.sh
Created February 9, 2010 09:50
sample shell script to test python modules
#!/bin/sh
pymod_test()
{
echo -n "Testing python module $1: "
python -c "import $1" 2> /dev/null
retval=$?
if [ "$retval" -eq "0" ]; then
echo "Ok"
else
@rroemhild
rroemhild / gist:2855383
Created June 1, 2012 21:56
query yes no
query_yesno () {
DEFAULT="no"
YES="y"
NO="n"
case $2 in
[Yy]*) YES="Y"
DEFAULT="yes";;
[Nn]*) NO="N"
DEFAULT="no";;
@rroemhild
rroemhild / .Xdefaults
Created June 22, 2012 09:36
Xdefaults solarized
!----------------------------------------------------------
! Xft settings
!----------------------------------------------------------
Xft.dpi: 96
Xft.antialias: true
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
@rroemhild
rroemhild / htpasswd.py
Last active January 4, 2016 15:19 — forked from eculver/htpasswd.py
Replacement for htpasswd
#!/usr/bin/env python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from getpass import getpass
from optparse import OptionParser
@rroemhild
rroemhild / is_true.sh
Last active August 29, 2015 14:07
bash is_true function
is_true() {
local var=${1,,}
case $var in
yes|y|true|t|on|1) return 0 ;;
esac
return 1
}
is_true "true"; echo $?
# 0

Keybase proof

I hereby claim:

  • I am rroemhild on github.
  • I am rroemhild (https://keybase.io/rroemhild) on keybase.
  • I have a public key ASAYIPva1Txin2wZ5SSoSSdsT6oDD66IZfBUVU6NCKbGwAo

To claim this, I am signing this object:

@rroemhild
rroemhild / errbot.init
Created May 11, 2016 16:04
Errbot init.d start script
#!/bin/sh
### BEGIN INIT INFO
# Provides: errbot
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Errbot
### END INIT INFO
@rroemhild
rroemhild / errbot.service
Created May 11, 2016 22:14
Errbot systemd service
[Unit]
Description=Errbot
After=network.target
[Service]
Type=forking
User=errbot
Environment="CONFIGFILE=/etc/errbot/config.py"
ExecStart=/usr/local/bin/errbot --daemon --config $CONFIGFILE
ExecStop=/bin/kill -SIGINT $MAINPID