Simple algorithm to insert commas (commaize) in 9 languages


This project contains nine different language implementations of a simple algorithm named “commaize” that inserts commas into a number. The languages are: bash, c++, java, javascript, perl, php, python, ruby and tcl. My hope is that it will be a useful reference.
Continue reading Simple algorithm to insert commas (commaize) in 9 languages

How to support multiple self-contained production quality web sites based on django, postgres and nginx on a single server using mkwebsite

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

Password Selection Strategies

Choosing secure passwords is a tricky business. This document describes some strategies for creating and selecting them to effectively protect your accounts. The key points are that you need long passwords that are hard to crack but easy to remember, that you should have different passwords for different accounts and that for critical accounts you should have different usernames as well.
Continue reading Password Selection Strategies

How to add a superuser in Django 1.6 from the command line

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

Simple remote control command execution tool (rctl.py)

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)

PassMan – Browser Based Password Manager Released

Today I am officially releasing PassMan, my browser based password manager. It is a free, open-source tool written in javascript that allows you to securely manage password data in your browser locally without interactions with a remote server.
Continue reading PassMan – Browser Based Password Manager Released

Bash script to install gcc 4.8.2 and boost 1.55.0 on CentOS 6.4, CentOS 5.5 and Mac OS X 10.9

I recently installed gcc 4.8.2 and boost 1.55.0 on CentOS 6.4 to take advantage of the improved support for C++-11. It was painful to do manually so I automated the process with this script: http://projects.joelinoff.com/gcc-4.8.2/bld.sh. Hopefully this will make it easier for folks that want to experiment with the latest version of the GNU C++ compiler.

If you are interested in a more recent version, I recently added a post that provides a script to install gcc-4.8.3 and boost 1.55.0.

Continue reading Bash script to install gcc 4.8.2 and boost 1.55.0 on CentOS 6.4, CentOS 5.5 and Mac OS X 10.9

Select the k-th smallest item from an unordered array in O(n) in python

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

Create and use a local mirrored yum repository for CentOS 6.4 x86_64

A local mirrored yum repository is a copy of the standard yum repositories for CentOS that exists on your local network. It is kept up to date by synchronizing to an external site. If you have more than a few local hosts, using a local mirrored repo can significantly reduce internet traffic and speed up the update process.

This blog describes how to create, sync, test and use a local mirrored repo for CentOS 6.4. You will be shown how to create the repo, keep it in sync using cron, test the implementation and how to update the /etc/yum.repos.d directory on each host. It also provides 4 bash scripts that you can customize for your site to make maintenance easier.
Continue reading Create and use a local mirrored yum repository for CentOS 6.4 x86_64

Count all Confluence pages in python using XML-RPC API

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

Remote command execution in python using paramiko that supports arbitrary input

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

Simple python functions that provide openssl -aes-256-cbc compatible encrypt/decrypt

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

Private data management tool using client side javascript

I recently created a web based tool that allows you to manage your private data and generate passwords safely. If you are interested in trying it click here.

I suspect that it will only work on newer browsers. I have only tested it on Firefox 15, IE 9 and Chrome 23. See the tool help for more detailed information.
Continue reading Private data management tool using client side javascript

Install firefox 15.0.1 with flash and java support on linux

This blog describes how I installed firefox 15.0.1 with java jre-7u7 and flash 11.2 on a CentOS 5.8 host. None of the installation commands were distro specific so it should work on any linux system.

This technique allows you to test different versions of firefox/java/flash without interfering with your system defaults. It also allows you to install a centralized version that can be shared by other users.
Continue reading Install firefox 15.0.1 with flash and java support on linux

iOS 6 on the iPad – My workarounds for Google Maps and YouTube

I recently installed iOS 6 on my iPAD and was impressed with the speed, battery life improvements and the upgrades. Unfortunately, I was very disappointed to find that Google Maps and YouTube were no longer available because I use them often. This blog describes what I did to address those missing apps.
Continue reading iOS 6 on the iPad – My workarounds for Google Maps and YouTube

Bash script to install gcc 4.7.2 and boost 1.51.0 on CentOS 5.5+ and 6.3

I recently installed gcc 4.7.2 and boost 1.51.0 on CentOS 5.5, 5.8 and 6.3 to take advantage of the improved support for C++-11. It was painful to do manually so I automated the process with this script: http://projects.joelinoff.com/gcc-4.7.2/bld.sh. Hopefully this will make it easier for folks that want to experiment with the latest version of the GNU C++ compiler.

If you are interested in a more recent version, I recently added a post that provides a script to install gcc-4.8.3 and boost 1.55.0.

Continue reading Bash script to install gcc 4.7.2 and boost 1.51.0 on CentOS 5.5+ and 6.3

Installing jshint and rhino for command line javascript analysis

I recently had to install jshint and rhino. It was a bit of a challenge because they needed ant and npm (node package manager). This blog describes what I did and provides a bash shell script that you can use.
Continue reading Installing jshint and rhino for command line javascript analysis

Make X11 programs work in an ssh sudo session

Have you ever needed to run an X11 based program like emacs or firefox in a sudo session and received one of the following errors?

This blog describes how to fix the problem.
Continue reading Make X11 programs work in an ssh sudo session