Skip to content

Instantly share code, notes, and snippets.

@edelbluth
edelbluth / simple_trie.py
Created October 23, 2016 09:53
Code Sample for juergen.rocks
root_node = None
class TrieNode(object):
def __init__(self):
self.__children = {}
self.__result = None
def __add(self, word: str, rest: str) -> None:
def addiere(*args):
"""
Die Methode »addieren« soll 2-5 Summanden annehmen und deren Summe zurückliefern.
>>> addiere(1, 2)
3
>>> addiere(1, 2, 3)
6
@edelbluth
edelbluth / nested.py
Last active August 29, 2015 14:23
juergen.rocks > Python-Klassen-Initialisierung: Bemerkenswertes Verhalten
# -*- coding: utf-8 -*-
# Copyright 2015 Juergen Edelbluth
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@edelbluth
edelbluth / cherrypy-tpl.py
Last active August 29, 2015 14:06
Mount a CherryPy Application with additional header security
"""
References:
[LUH] https://www.owasp.org/index.php/List_of_useful_HTTP_headers
[XFO] https://www.owasp.org/index.php/Clickjacking_Defense_Cheat_Sheet
[CSP] https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Bonus_Rule_.232:_Implement_Content_Security_Policy
"""
_csp_sources = ['default', 'script', 'style', 'img', 'connect', 'font', 'object', 'media', 'frame']
_csp_default_source = "'self'"

Licence (MIT Licence)

Copyright (c) 2011 Simon Walker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: