Browsing All Posts filed under »Programming«

Easy Way to Create Colorful Bash Prompt

May 23, 2013

0

The Problem I often want to fiddle with the bash prompt, but don’t want to deal with bash prompt escape sequences. I wish for a utility which simplify setting a bash prompt. I finally wrote that utility myself: mkprompt Install Copy mkprompt to a directory in the path. Using mkprompt The best way to show […]

Tcl Print CSV File

February 20, 2013

1

When scripting in Tcl, I often need to process CSV files, including printing it out. Since I often found myself in need of printing, I wrote two helper procedures: load_matrix, which loads a matrix (a table) from CSV file; and print_matrix, which prints a text presentation of the matrix. The end result is the ability […]

Accessing Configurations and Settings in Python

October 13, 2011

2

The Problem When coding in Python, we need a way to store configurations and settings in a file, then be able to access them in the code. Our requirements for accessing these settings are: Simple to learn and use — We would like to target novice coders Easy to understand Hierarchical of settings References ConfigParserShootout […]

How to Print a Tcl Keyed List

September 8, 2011

0

I have added to the Tcl Wiki a section on how to print out a keyed list. If you want to print out the contents of a keyed list, give it a visit, search for keylprint.

Tcl: How to Throw an Exception

July 17, 2011

0

Many Tcl scripters know how to catch an exception, but not many know how to throw it. This wiki page shows how.

Better Font and Color for tkcon in Linux Mint 11

July 2, 2011

0

The Problem In Linux Mint, the default font and background color for tkcon is terrible. I want to change that to something easier to read. The Solution Here is my ~/.tkconrc, which fixes it by choosing a better font and background color: Discussion The default font in Linux Mint is terrible: it is hard to […]

Tcl: Does This File Belong to Me?

July 2, 2011

0

I often need to determine if a file belongs to me while my script is running in a shared environment. For that, I created a function called fileIsMine, read all about it here. Update: I did not know that Tcl has a command called file owned, which does exactly what I want. Duh!

Automatically List a Directory’s Contents After Changing Dir

April 26, 2011

0

The Problem After the cd command, the next command is almost always ls so we want to combine the two to automatically issuing the ls command right after the cd command. The Solution In bash, add the following line in either ~/.bash_profile or ~/.bashrc: If you are using csh or tcsh, add the following line […]

tcltest Part 8: Recursive Test Suites

April 26, 2011

1

The Problem We want to organize tests in a hierarchy of directories and execute them in all at once. The Solution We can organize tests in sub directories of arbitrary depths, but in order for tcltest to include a directory, that directory must contain a file named all.tcl. In this example, we only create two […]

tcltest Part 7 – Inexact Result Matching

April 19, 2011

0

The Problem We want to test the result of a function, but don’t know the exact values The Solution In case where we only have a vague idea of what the result or output should look like, we can use the test command’s -match option. For example: Explanations: Lines 6-10: this is the same test […]

Follow

Get every new post delivered to your Inbox.

Join 36 other followers