This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $1 exit code | |
# $2 ok exit codes (comma separeted) | |
# | |
verify_exitcode(){ | |
local j | |
for j in ${2//,/ };do | |
if [ $j -eq $1 ]; then | |
echo "[info] assume exit code $j as ok" | |
return 0 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Convert version number of only digits into one number, ready for comparing. | |
""" | |
v1=(1,20,0,10) | |
v2=(1,20,1,0) | |
# length in bits of each version number. | |
# for example '8' allows to use version number with elements of a max 256: "256.256.256.256" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def json2xml(json_obj): | |
"""Simple converter from json to xml | |
Kudos go to https://stackoverflow.com/questions/8988775/convert-json-to-xml-in-python. | |
""" | |
result_list = list() | |
json_obj_type = type(json_obj) | |
if json_obj_type is list: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from subprocess import Popen, PIPE | |
import shlex | |
items = ['i1', 'i2', 'i3'] | |
cmd='xargs -rn1 -I% echo "run for %"' | |
p = Popen(shlex.split(cmd), stdout=PIPE, stdin=PIPE, stderr=PIPE) | |
# this will emulate the shell sequence: "echo 'i1 i2 i3'|tr ' ' '\n'|xargs ..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mgo = new Mongo() | |
function getReadableFileSizeString(fileSizeInBytes) { | |
var i = -1; | |
var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB']; | |
do { | |
fileSizeInBytes = fileSizeInBytes / 1024; | |
i++; | |
} while (fileSizeInBytes > 1024); |