Ruby Tool Configuration in UltraEdit

Uncategorized — Titus Barik on August 20, 2010 at 6:01 pm

To configure Ruby from within UltraEdit, use the following settings under Tool Configuration:

  • Command Line should be C:\Ruby191\bin\ruby.exe "%f".
  • Set Working Directory to %p. Note that there are no quotes.
  • Under the Options, set Program Type to DOS Program.
  • Set Output to Capture Output, and tweak your preferences as desired.

Don’t forget to also download the wordfile!

CSS Substring Selectors

Uncategorized — Titus Barik on August 17, 2010 at 3:52 pm

You can use CSS 3 Selectors to change properties of elements (such as for links) without having to write dynamic PHP code:

ul.lectures a[href $=".ppt"] {
    background:url(../images/icons/icon_ppt.gif) 
    center right no-repeat; padding-left:20px;
}

The example above will display a Microsoft PowerPoint icon for file names ending in “.ppt”.

NetBeans 6.8 IDE Fails to Uninstall

Uncategorized — Titus Barik on July 28, 2010 at 11:31 am

NetBeans 6.8 fails to uninstall correctly on my system. Instead, I am faced with the following error message:

The specified target component - nb-base/6.8.0.0
was not found in the registry. The installer 
can continue as if the target component was not specified.
Click Yes to continue, No to exist the installer.

I have already posted this to the NetBeans forums.

Raleigh, NC

Uncategorized — Titus Barik on July 16, 2010 at 3:36 pm

I have moved to Raleigh, North Carolina. My new address is:

Titus Barik
5601 SORRELL CROSSING DR
RALEIGH NC  27617-8301

My PC

Uncategorized — Titus Barik on April 25, 2010 at 7:56 pm

I built a computer sometime in 2006 and then subsequently upgraded several times along the way. Here are the specifications:

  • AMD Athlon 64 X2 Dual Core Processor 3800+ 2.01 Ghz
  • ASUS A8N-SLI Deluxe 939 NVIDIA nForce4 SLI Motherboard
  • CORSAIR XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM DDR 400 (PC 3200) TWINX2048-3200C2
  • Western Digital Caviar SE16 WD3200KS 320GB 7200 RPM
  • EVGA 256-P2-N363-TX GeForce 6600LE 256MB 128-bit DDR PCI Express x16 SLI

It’s been four years since then, and the machine still performs well and I can run all of the latest software that I use on a daily basis without difficulty.

Python Input/Output Idioms

Uncategorized — Titus Barik on April 24, 2010 at 11:50 am

Unlike the C programming language, Python assignments are statements, not expressions. Therefore the common C idiom of:

while (line = fgets(f)) {
    /* do something with the line */
}

is not possible to implement directly.

However, effbot.org provides several alternatives using iterators or the while True idiom. I recently discovered the built-in iter() function as well:

for line in iter(f.readline, "END"):
    ... do something with line ...

Popcount in Python

Uncategorized — Titus Barik on April 23, 2010 at 4:52 pm

While working a problem from the Waterloo Programming Contents, I found that the sample solution used the GCC internal function used the GCC internal function __builtin_popcount(unsigned int x).

This function returns the number of 1-bits in x, and we can emulate a similar operation in Python 2.6 (PEP 3127) or above using the quick and dirty snippet:

bin(x).count('1')

Command-Line Arguments in IDLE

Uncategorized — Titus Barik on April 19, 2010 at 6:16 pm

Sometimes you want to be able to run a script through the interactive Python Shell that comes with IDLE, but using a different text editor (such as UltraEdit). In this case, you want to run IDLE from another program. To do so:

idle.py -r scriptname.py

or

idle.pyw -r scriptname.py

Strangely, the -r command-line argument doesn’t appear to be in the Python documentation for IDLE at all.

Note: The idle.py script is typically located at C:\Python31\Lib\idlelib, or very close to it.

Some other notes on specific to UltraEdit:

  • An example Command Line is: C:\Python31\Lib\idlelib\idle.pyw -r "%f".
  • For Program Type, set to Dos Program, not Windows Program.
  • Do not capture any Command Output.

NetBeans 6.8 and Python 3 Unit Tests

Uncategorized — Titus Barik on April 18, 2010 at 8:29 pm

It looks like the NetBeans IDE is unable to do unit tests if you are developing your code using a Python 3 interpreter. You’ll hit the following wall when trying to run a test:

File "C:\Program Files\NetBeans 6.8\python\
\nb_test_runner.py", line 216
    except ValueError, e:
                 ^
SyntaxError: invalid syntax

Finished in 0.0 seconds.
0 tests, 0 failures, 0 errors

Perhaps NetBeans 7.0 will address this issue.

MySQL Manually Remove Service Instance

Uncategorized — Titus Barik on April 16, 2010 at 9:02 am

How do you manually remove a MySQL Server Instance? I have MySQL Server 7.0 listed as one of the server instances when running the MySQL Server Instance Configuration Wizard.

Next Page »
titus@barik.net | The Weblog of Titus Barik