Skip to content

Instantly share code, notes, and snippets.

@belsander
belsander / Jenkinsfile
Created November 21, 2018 16:13 — forked from ftclausen/Jenkinsfile
Jenkins pipeline - An approach to get all commits since the last successful build.
// -*- mode: groovy -*-
// vim: set filetype=groovy :
node( 'some_node' ) {
stage( "Phase 1" ) {
sshagent( credentials: [ 'some_creds' ] ) {
checkout scm
def lastSuccessfulCommit = getLastSuccessfulCommit()
def currentCommit = commitHashForBuild( currentBuild.rawBuild )
if (lastSuccessfulCommit) {
@belsander
belsander / SetupStaticRouteThatOverrulesDefaultInterface.bat
Created June 6, 2018 04:23
In case you want to have your default gateway on a higher metric interface (so slower) and only use the lower metric interface for specific routes
REM If you want to set metrics on interfaces go to the confguration of the network interface:
REM (THIS IS NOT POSSIBLE WITH THE route COMMAND !!)
REM Goto: 'Internet Protocol Version 4 (TCP/IPv4)' -> Properties
REM Goto: 'General' -> Advanced
REM Goto: 'IP Settings'
REM Uncheck 'Automatic metric'
REM Type in the metric you want for that interface in 'Interface metric'
REM Find out what the interface number is
route print
@belsander
belsander / find_key_occurences.py
Last active May 3, 2018 14:26
Find all occurences of a key in a nested Python dictionary and return the occurences together with the keys
def find(find_object, result, keys=[]):
if isinstance(find_object, dict):
for key, value in find_object.iteritems():
find(value, result, keys + [key])
else:
if not(result):
result['values'] = [find_object]
result['keys'] = [keys]
else:
result['values'].append(find_object)
# Basic examples
>>> var1 = 100
>>> eval("50 + var1")
150
>>> eval("var1 = 25")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
var1 = 25
^
# Code below behaves the same as eval()
eval(compile(str_source_code, “<string>”, “eval”))
# Code below behaves the same as exec()
exec(compile(str_source_code, “<string>”, “exec”))
var = <any valid Python syntax you can place here is an expression>
import dbus
class dbus_parse(object):
__slots__ = ("__dbus_parse_dict", "__parse_dbus_dict", "__parse_dbus_list", "__parse_dbus_tuple", "__parse_dbus_var", "parse_dbus_vars")
def __init__(self):
self.__dbus_parse_dict = { dbus.String: str,
dbus.Int16: int, dbus.Int32: int, dbus.Int64: int,
dbus.UInt16: int, dbus.UInt32: int, dbus.UInt64: int,
dbus.Double: float,
dbus.Boolean: bool,
zip([iterable, ...])
# Example
>>> test_list1 = ["a", "b", "c"]
>>> test_list2 = [1, 2, 3]
>>> zip(test_list1, test_list2)
[('a', 1), ('b', 2), ('c', 3)]
>>> dict(zip(test_list1, test_list2))
{'a': 1, 'c': 3, 'b': 2}
>>> test_list2 = [1, 2, 3, 4]
type(object)
# Example
>>> test_dict = dict()
>>> test_int = 0
>>> test_str = ""
>>> test_tuple = tuple()
>>> test_list = list()
>>> type(test_dict)
<type 'dict'>
isinstance(object, classinfo)
# Example
>>> test_dict = dict()
>>> dict # just showing what is a type object is
<type 'dict'>
>>> isinstance(test_dict, dict)
True
>>> isinstance(test_dict, list)
False