Skip to content

Instantly share code, notes, and snippets.

View niccokunzmann's full-sized avatar

Nicco Kunzmann niccokunzmann

View GitHub Profile
@niccokunzmann
niccokunzmann / C_buitinTypes.py
Created February 17, 2013 15:43
Coming closer to my goal of subjective programming
# see https://github.com/niccokunzmann/wwp
from relative import roleOf, useRoles
@roleOf(int)
class NaturalNumber:
@property
def successor(self):
return self + 1
@niccokunzmann
niccokunzmann / runningConfiguration.py
Created March 28, 2013 11:51
This module persists its attributes in a file located in the same directory. All running programs importing this module see the same attributes.
'''
This is a module with persistent attributes
the attributes of this module are spread all over all instances of this module
To set attributes:
import runningConfiguration
runningConfiguration.x = y
to get attributes:
runningConfiguration.x
@niccokunzmann
niccokunzmann / .bashrc
Created April 3, 2013 10:19
These are code snippets to run in $MAGLEV_HOME to create a new maglev stone or to create a new test stone for maglev after buildmaglev was run
buildmaglev () {
use ruby &&
rake maglev:stop
rake stone:destroy[maglev]
rake build:clobber &&
rake build:maglev &&
rake maglev:reload_prims &&
rake maglev:start
}
@niccokunzmann
niccokunzmann / RemoteException.py
Last active March 24, 2024 16:02
See the traceback of the error occurring from the other process with multiprocessing.
import sys
import traceback
import StringIO
from copy_reg import dispatch_table, pickle
def exc_info(hide_calls = 0):
'''as sys.exc_info() but returns a remote exception object'''
ErrorType, thrownError, traceback = sys.exc_info()
for i in range(hide_calls):
@niccokunzmann
niccokunzmann / hanging_threads.py
Last active September 27, 2023 08:13
This module prints all hanging threads that are dead locked. It is for Python 2 and 3. Installable: https://pypi.python.org/pypi/hanging_threads
## The MIT License (MIT)
## ---------------------
##
## Copyright (C) 2014 Nicco Kunzmann
##
## https://gist.github.com/niccokunzmann/6038331
##
## Permission is hereby granted, free of charge, to any person obtaining
## a copy of this software and associated documentation files (the "Software"),
@niccokunzmann
niccokunzmann / example.py
Last active March 1, 2023 15:52
You can use while and for loops without blocking the GUI. This is currently for Tkinter and PyQT. To install guiLoop copy the guiLoop.py file into the directory of your script.
## MIT License
##
## Copyright 2014 Nicco Kunzmann
##
## 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:
##
@niccokunzmann
niccokunzmann / RecursiveThreadPoolExecutor.py
Last active June 16, 2021 02:08
The RecursiveThreadpoolExecutor enables the use of futures in the functions that are parallely executed.
'''
This is crated as an answer to the stackoverflow qustion:
http://stackoverflow.com/questions/21960514/can-i-use-a-processpoolexecutor-from-within-a-future
The updated code can be found here:
https://gist.github.com/niccokunzmann/9170072
The RecursiveThreadPoolExecutor allows the usage of futures in the
submitted functions.
It uses the yield and yield from statements to suspend the execution of the
@niccokunzmann
niccokunzmann / DecodeLargeJSON.py
Last active October 10, 2023 18:17
Decode large json files
"""
Response to
http://stackoverflow.com/a/22904200/1320237
"""
import json.scanner
import json.decoder
from json.decoder import JSONDecoder
class FileString(object):
@niccokunzmann
niccokunzmann / license_footer.js
Created June 18, 2014 10:26
weebly license footer
@niccokunzmann
niccokunzmann / download.py
Last active July 7, 2016 20:52
This script downloads all the mp4 files for a tele-task course
#!/usr/bin/python3
## The MIT License (MIT)
##
## Copyright (c) 2014 Nicco Kunzmann
##
## https://gist.github.com/niccokunzmann/9c60cb40d3d3975ef830
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal