This module provides 3 ways of detecting which objects have been allocated (methods 1 and 3) or became un-reclaimable (method 2) between 2 points in the code. It can be very useful to detect memory leaks (eg. cycles involving objects with a...
Advertisement
See docstring in the code
An implementation of the token bucket algorithm in Python.
reduce is a pretty nice built-in, but its usage in everyday code is seemingly rare. If you've been looking for excuses to use reduce, here are a few useful recipes to get you started.
This is an implementation of the binary search algorithm in (almost) one line. Given a number 'n' and a list 'L', the function returns the index of the number on the list, or -1.
This code attempts to implement psexec in python code, using wmi. As part of a project of mine I had to run remote commands on remote Windows machines from other Windows machine. At first I used psexec for that with subprocess.Popen. The...
In asynchronous code, signal.alarm() is extremely useful for setting and handling timeouts and other timed and periodic tasks. It has a major limitation, however, that only one alarm function and alarm time can be set at a time; setting a new...
An incremental PCA algorithm in python.
Incremental PCA allows computing an approximation of the principal components on large data sets as observations are given sequentially.
I received UnicodeEncodeError when playing with various codepages in source code/files/standard streams. Sometime I receive UnicodeEncodeError when script launched via scheduler or in long running batch when parsing unpredictable [alien ;)]...
This recipe helps find cyclical references in Python code to a] optimize so the garbage collector doesn't have to work as hard, and b] deal with uncollectable objects, such as those with a __del__ method, or extension objects that don't...
Some people like to sprinkle stack trace information in their code, and it is always helpful to get a visual clue to the call stack depth. inspect.stack() contains the entire call stack.
To make this information available conditionally,...
In some code I have to work with but don't have much control over, there are a bunch of strings declared at the module level. I need to figure out what all those strings are, and wrap them in something. Once they are wrapped, they...
Function to auto-strip indentation and whitespace from triple-quoted multi-line strings in Python code. Useful when you need to emit blocks of HTML/TCL/etc. from Python, but don't want to mess up the visual flow of your Python code.
Ruby has the functionality of being able to add a method to a class at an arbitrary point in your code. I figured Python must have some way for allowing this to happen, and it turned out it did. The method is available instantly to all already...
The source code for the PC1 encryption algorithm in Delphi, C, C++.The PC1 algorithm is a stream cipher secure against linear and differential cryptanalysis. You can use 128 or 256 bits keys.
This is a simple python implementation of the XTEA block encryption algorithm (http://www.cix.co.uk/~klockstone/xtea.pdf). For details please see docstrings in the code.
Build a Versatile .NET Code Execution Timer / Logger is a web based tutorial which helps in generating code which works in calculating the executing time of the .NET applications. Through this article users can learn more about setting run time...
This tutorial will show you how the Selection Sort algorithm works. It is mostly used to sort numbers, but you can sort letters as well using the ASCII numeration. It also has examples that demonstrates algorithm. All the code examples are written...
Complete all-in-one web code editor for all your web document editing needs. Clean and convenient interface, quick startup, true flexibility and powerful features allow you to create and edit HTML, XHTML, CSS, JavaScript, VBScript, PHP, ASP,...
CtrlCAD is a 2D source code cad for C++.It is the starting point to build your own customized drawing applications. The library is furnished in source code formats for c++ More then 1000 functions,well documented with a lot of examples. |