Skip to content

Instantly share code, notes, and snippets.

View Paebbels's full-sized avatar

Patrick Lehmann Paebbels

View GitHub Profile
@Paebbels
Paebbels / Reproducer.py
Created June 13, 2023 20:52
Python __new__ and __init__ with meta-classes
class AbstractClassError(Exception):
pass
class M(type):
# staticmethod
def __new__(cls, className, baseClasses, members, abstract):
newClass = type.__new__(cls, className, baseClasses, members)
if abstract:
def newnew(cls, *_, **__):
@Paebbels
Paebbels / BindingDecorator.py
Created January 13, 2021 12:00
Bind Python Functions via ctype to Shared Libraries
class __Environment():
"""
Create a Python root environment with local and global symbols and a builtins
namespace
"""
globals: Dict #: global symbols
locals: Dict #: local symbols
builtins: Dict #: builtins namespace (``__builtins__``)
@Paebbels
Paebbels / Add-and-Remove-from-PATH.ps1
Created January 12, 2021 14:12
PowerShell Snippets
# GitHub user: https://github.com/mkropat
# Gist account at GitHub: https://gist.github.com/mkropat
# Gist snippet URL: https://gist.github.com/mkropat/c1226e0cc2ca941b23a9
function Add-EnvPath
{ param(
[Parameter(Mandatory=$true)]
[string] $Path,
[ValidateSet("Machine", "User", "Session")]
[string] $Container = "Session"
@Paebbels
Paebbels / pyUnittest_Testcase.py
Created December 28, 2020 11:05
Abort following tests if one failed.
class SomeTestcases(TestCase):
_continueTesting = True
def setUp(self) -> None:
"""Check for every test, if tests should continue."""
if not self.__class__._continueTesting:
self.skipTest("No reason to go on.")
def fail(self, msg: Any = ...) -> NoReturn:
self.__class__._continueTesting = False
@Paebbels
Paebbels / gist:3a111f070f3151383d5021e0eec46f52
Created August 7, 2020 06:29 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
@Paebbels
Paebbels / ssh-tar
Created November 21, 2018 21:07 — forked from purplefish32/ssh-tar
Compress and copy via SSH using TAR
#Compress and copy via SSH using SCP and TAR
tar -czf - /some/file | ssh joebloggs@otherserver.com tar -xzf - -C /destination
#Switch -c for tar creates an archive and -f which tells tar to send the new archive to stdout.
#The second tar command uses the -C switch which changes directory on the target host. It takes the input from stdin. The -x switch extracts the archive.
#The second way of doing the transfer over a network is with the -z option, which compresses the stream, decreasing time it will take to transfer over the network.
#Some people may ask why tar is used, this is great for large file trees, as it is just streaming the data from one host to another and not having to do intense operations with file trees.
#If using the -v (verbose) switch, be sure only to include it on the second tar command, otherwise you will see double output.
#Using tar and piping can also be a great way to transfer files locally to be sure that file permissions are kept correctly
@Paebbels
Paebbels / iCLA test
Created April 29, 2016 00:09
Individual Contributor License Agreement (iCLA)
The PoC-Library is licensed under the [Apache License 2.0][al20].
Due to the modular structure of the PoC-Library, contributions can come in two distinct forms:
- **(1)** modifications of the core code (i.e., the code under the copyright of the
Chair for VLSI Design, Diagnostics and Architecture, Faculty of Computer Science,
Technische Universität Dresden, including extensions in the core repository) as well as
- **(2)** **third party extensions**, translations and similar additions.
Essentially, the difference between the two is that type **(1)** contributions cannot be
@Paebbels
Paebbels / IndividualContributerLicenseAgreement_JSON-for-VHDL
Created April 23, 2016 23:37
Individual Contributer License Agreement for Paebbels/JSON-for-VHDL
The Apache Software Foundation
Individual Contributor License Agreement ("Agreement") V2.0
http://www.apache.org/licenses/
Thank you for your interest in The Apache Software Foundation (the
"Foundation"). In order to clarify the intellectual property license
granted with Contributions from any person or entity, the Foundation
must have a Contributor License Agreement ("CLA") on file that has
been signed by each Contributor, indicating agreement to the license
terms below. This license is for your protection as a Contributor as
@Paebbels
Paebbels / Microsoft.PowerShell_profile.ps1
Created January 21, 2015 17:06
My PowerShell profile scripts
# Save this file as: C:\Users\<Username>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
$Executables = @{
'Notepad++'="C:\Program Files (x86)\Notepad++\notepad++.exe"
}
Write-Host "--------------------------------------------------------------------------------"
if (Test-Path $Executables['Notepad++'])
{ # function Edit