I have created a program on github to answer this question with examples and code samples: https://github.com/jlinoff/ztables. It shows how to generate z-tables for Standard Normal Distributions and Student-t Distributions. It also shows how to generate the z-values for specific probabilities from those distributions without using any special libraries.
The program has been tested using Python 2.7.10 and 3.5.
I created a simple python based web server to demonstrate how to use SimpleHTTPServer.SimpleHTTPRequestHandler for handling GET/POST requests. It also demonstrates how to build a system that supports embedded python, templates, create custom URLs, execute local scripts and a number of other things.
It is a single script that acts like a web server, a web server gateway interface and server code so the solution is completely self contained.
Continue reading Simple python web server to demonstrate GET/POST handling and support for embedded Python- round 2
This bash script downloads, builds and installs a particular version of python in the location of your choice without requiring root permissions. It also creates a virtual environment that you can activate to use it. It is licensed under the terms of MIT open source license.
Continue reading Bash script to install python locally without root permissions
This blog describes a simple open source (MIT licensed) web server that demonstrates how browser/server interactions work for GET and POST requests using the python BaseHTTPServer package. It was updated to version 1.2 on 20-May-2015. This software is licensed under the term of the MIT license. Feel free to use it however you wish.
Use it as a starting point to understand the package when creating your own custom web server for handling specific types of requests but recognize that it is not suitable for a production environment. To use it in such an environment you would, at the very least, want to add improve the error handling and add threading support. You would probably also want to add SSL/TLS support.
Continue reading Simple python web server to demonstrate GET/POST handling
lock_files.py is a python command line tool to encrypt or decrypt files using AES encryption and a common password. You can use it lock files before they are uploaded to storage services like DropBox or Google Drive.
It is available from github: https://github.com/jlinoff/lock_files. You will find a more complete description of the tool including the command line options there.
The mkwebsite package allows you to install multiple completely self contained production quality websites on a single server for development and debugging without root privileges. I have used it for web development on linux and Mac OS X. The sites generated can also be used in production.
I developed it because I wanted to be able to completely remove my development sites without leaving any system wide packages around that I didn’t need and because I wanted to compare security settings side by side for sites that were otherwise identical.
It is very easy to use, simply download the package, extract it and run the associated install script for each website that you want to create. It takes care of all the system administration details (like database and server configuration) so that you can concentrate on development.
Continue reading How to support multiple self-contained production quality web sites based on django, postgres and nginx on a single server using mkwebsite
This python script shows how to add a super user and display all super users in your Django 1.6 installation from the command line. I wrote it to support automated configuration of my django installations.
Continue reading How to add a superuser in Django 1.6 from the command line
I have written a public domain remote control tool call rctl.py that runs remote commands on one or more hosts to automate all sorts of different administration tasks. It consists of a single python script that does not require any configuration and does not require client side daemons (sometimes called minions) so no tool based client side installation is needed which makes it much simpler to setup and use compared to tools such as Puppet, Chef or salt. Of course it is not as powerful as those tools but it has met my modest needs for small networks (<100 hosts). I hope that you find it as useful as I have.
Continue reading Simple remote control command execution tool (rctl.py)
This blog contains two python implementations of the SELECT algorithm to select the k-th ordered item from an unsorted array of N items in O(N) time. They derive from the discussion of RANDOM-SELECT and SELECT in the CLRS “Introduction to Algorithms, 3rd Edition” on pages 215-222 and from Professor David Eppstein’s lecture notes entitled “ICS 161: Design and Analysis of Algorithms” from January 30th, 1996.
Continue reading Select the k-th smallest item from an unordered array in O(n) in python
I was recently asked how to count the total pages on a 4.2 Confluence server so I provided this python script that shows how to use the XML-RPC API to do it. The technique can be used for more than counting pages. The API provides all sorts of useful operations, like adding users. For more information on the available methods see this page: https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods.
Continue reading Count all Confluence pages in python using XML-RPC API
I recently had to access Django session data from a cookie in a third party application (based on Tomcat) with no access to the Django infrastructure. This example shows how I did it.
Continue reading Decode Django session data without the infrastructure
I recently decided to use paramiko to develop a remote command execution tool.
It was very easy to setup initially and ran much faster than my existing pexpect implementation but it had a problem with sudo commands because they required the password to be provided as input.
I solved the problem by using a pseudo-terminal and by creating my own ChannelFile objects for stdin and stdout/stderr. The solution should be general enough to handle any case that requires simple input but it is not as flexible as pexpect. I hope that you find it useful.
Continue reading Remote command execution in python using paramiko that supports arbitrary input
The example here shows how to encrypt and decrypt data using python in a way that is fully compatible with openssl aes-256-cbc. It is based on the work that I did in C++ Cipher class that is published on this site. It works for both python-2.7 and python-3.x.
The key idea is based on the way that openssl generates the key and iv data from password as well as the “Salted__” prefix that it uses.
The complete routine can be downloaded here: mycrypt.py.
Continue reading Simple python functions that provide openssl -aes-256-cbc compatible encrypt/decrypt
I recently needed to print out the time with timeszone name but when I used the %Z paramter it was blank. I fixed it by using the dateutil package as shown in the short example below.
Continue reading Python datetime.datetime.now() that is timezone aware
I have written a RAID configuration analysis tool to help me configure filers. It reports the mean time to data loss (MTTDL), the amount of storage available in a JBOD, the number of possible spares and a other useful information. I am releasing it on the hope that other folks that are trying to figure out how many disks to bundle in a RAID configuration (vdev) will find it useful.
||Python source code
Continue reading RAID Configuration Analysis Tool in Python
The NX web page entitled “The password scrambling algorithm in NX client” describes their password scrambling algorithm in C++ and perl but it does not describe it in python. Nor does it describe how to unscramble the data.
This blog describes how I implemented both algorithms in python. I was surprised that NX didn’t use a standard symmetrical key algorithm like blowfish or DES for storing the keys but they must have some good reason.
Continue reading NX password scrambling and unscrambling algorithms in python 2.7
I released version 1.1 of change.py today. It has two fixes:
- When a file was renamed in in-place mode the file with the old name was not deleted.
- File permissions were not correctly set in some cases when changes were made.
The version is here: http://projects.joelinoff.com/change-1.0/change.py.
I simply replaced the 1.0 version.
For many years I have used a home grown tool that allows me to make simple changes to multiple files with one command. It is called change and has existed as csh, bash and perl incarnations over the years. I recently rewrote it in python and thought that it might be useful to others so I am publishing it. Here is an example of how it works:
files=$(find . -type f)
change.py 'Copyright (c) 2010' 'Copyright (c) 2012' $files
change.py 'Version 1.0' 'Version 1.2' $files
I suspect that lots of you have written your own, similar tools. If that is the case, please look it over send me suggestions for improvements.
Continue reading Edit multiple files at once using change.py
I officially released SecEd into the public domain today, you can find it here.
SecEd was written using Python 2.7 and the wxPython 2.8 package. It allows you to securely edit sensitive data. It also has a feature that allows you to rate the strength of your password.
Because it is written in Python it is portable and because it is open source you can use it to learn about wxPython and/or teach me more about it.