The Revolver’s Notepad

Blog transferred to new domain

Posted in Uncategorized by Vincent on June 1, 2012

Now I have setup a new domain to host my WordPress blog The Revolver’s Notepad. Updates to the old one on WordPress.com will be discontinued soon after the transition is finally done. Please subscribe to the RSS feed of the new blog (but with the same name, The Revolver’s Notepad) for a more broad range of posts!

Also, the blog is now a part of my website Pi Identity. This site (now under construction) will mainly be dedicated to my need in weekend-hobbism to host various smaller projects.

Tagged with: ,

List of unsuccessful MacPorts installations

Posted in Quick References by Vincent on February 1, 2012

So far, I have gathered a list of installations from MacPorts which have failed me.

  • Maude 2.6: Fortunately, the developers of Maude have a precompiled version on their website.
  • Ipe 7.1.1: An update with MacPorts to version 7.1.2 works.
  • Boost 1.48.0_4: Fortunately, an old version 1.48.0_2 works for me. Update: An update of MacPorts to version 2.0.4 installs Boost 1.49.0_0 successfully.
  • rb-gnome, rb-poppler, poppler, gconf: This set of modules is newly discovered when I try to install UPPAAL DBM Ruby bindings. No solution yet.
Tagged with: , , ,

Installing UPPAAL DBM library, the Ruby binding, and the Python binding on MacOSX

Posted in Quick References by Vincent on February 1, 2012

This is another build / configure post here. Another MacPorts failure in building the rb-gnome module (which in turn depends on poppler, failing for me).

Here is a partial list of modules that MacPorts has failed me.

Installing the DBM Library

The process of installing DBM library is a standard procedure.

AR=ar ./configure
make
make install

The AR=ar fixes a weird error of the script which reports rucs: command not found (see this discussion). Googling “rucs” gets almost nothing, except that it thinks I am searching “rush.”

Installing the Ruby Binding

Compiling the Ruby binding files are also straightforward following the README file. Only one error reports “error: cast from ‘void*’ to ‘int’ loses precision”. Change int in Line 317 of the udbm.cpp file to intptr_t solves the problem, according to this StackOverflow discussion.

Unfortunately, the graphical features requires the rb-gnome module, which the official website refers to MacPorts, which fails.

Nonetheless, the binding seems to be working pretty well without the capability of doing the GUI.

Installing the Python Binding

This installation has been the smoothest. First grab the source of SWIG, compile and install, then build and install the Python Binding according to the README file.

Batch converting graphic files for Mac with AppleScript and ImageMagick

Posted in Quick References by Vincent on January 30, 2012

It is often desirable to convert a few graphic files into other formats, for example .eps and .pdf when you work with LaTeX. The convert utility from the ImageMagick software suite makes conversion an easy job, but some batch work should be done automatically, right?

This AppleScript utility, which can be saved as a MacOSX application also, simply automates the process. You select a few graphic files, you specify extensions of formats that you want to convert them to, and this script does the rest, putting the converted files (same basenames as the originals, but different formats with different extensions you specified) to where the originals are.

-- customized split function
-- From julifos @ http://macscripter.net/viewtopic.php?id=24473
to split(someText, delimiter)
	set AppleScript's text item delimiters to delimiter
	set someText to someText's text items
	set AppleScript's text item delimiters to {""} --> restore delimiters to default value
	return someText
end split

-- From http://www.macosxautomation.com/applescript/sbrt/index.html
on remove_extension(this_name)
	if this_name contains "." then
		set this_name to ¬
			(the reverse of every character of this_name) as string
		set x to the offset of "." in this_name
		set this_name to (text (x + 1) thru -1 of this_name)
		set this_name to (the reverse of every character of this_name) as string
	end if
	return this_name
end remove_extension

on get_extension(this_name)
	if this_name contains "." then
		set this_name to ¬
			(the reverse of every character of this_name) as string
		set x to the offset of "." in this_name
		--set this_name to (text (x + 1) thru -1 of this_name)
		set this_name to (text 1 thru (x - 1) of this_name)
		set this_name to (the reverse of every character of this_name) as string
	end if
	return this_name
end get_extension

-- get the raw files to convert
set fileNames to ¬
	(choose file with prompt ¬
		"Select the graphic files to convert." with multiple selections allowed)
if fileNames is -128 then exit repeat

-- ask for the other formats to convert to
set exts to text returned of ¬
	(display dialog ¬
		"Enter a list of extnesions you want to convert to, separated by space." with title "Convert to... " default answer "eps pdf")
set extItems to split(exts, {" ", "  ", "   ", "    ", "     "})

-- start converting
repeat with filename in fileNames
	repeat with ext in extItems
		set n to POSIX path of (filename as text)
		set bn to remove_extension(n)
		set nn to bn & "." & ext
		set cmd to "convert " & (quoted form of n) & " " & (quoted form of nn)
		-- if ext the same then skip
		if not (get_extension(n) as string = ext as string) then
			do shell script cmd
		end if
	end repeat
end repeat

beep
display dialog "Conversions successful!" with title "Congratulations!"

Note: Make sure that the ImageMagick software is correctly installed on your system. Also, make sure that the convert utility is found in your $PATH$; otherwise specify where it is. Also, note that if unsupported files by convert are selected, the script may complain.

Update: It is highly recommended that ImageMagick is compiled from source, instead of using (a) the one from MacOSX itself, or (b) the one from MacPorts, or (c) the one from the ImageMagick’s binary distributions. Lots of my conversion fail but the one that I compiled by myself works best.

FaWave cannot select Sina Weibo and other accounts simultaneously, a quick fix for Mac

Posted in Quick References by Vincent on January 30, 2012

The title basically says everything about the problem with the Chrome plugin for multiple SNS account management. One of the reviews for the Chrome plugin mentions a solution for Windows machines here.

Under Mac OSX, the fix is essentially the same, only that the wrong popup.js file is located at

/Users/yourid/Library/Application Support/Google/Chrome/Default/Extensions/aicelmgbddfgmpieedjiggifabdpcnln/2012.1.21.0_0

A working copy of the popup.js file can be downloaded here.

Tagged with: , , ,

Using Uppaal for trace interpretation

Posted in Quick References by Vincent on October 26, 2011

Uppaal is a model checking tool for timed automata. When a counterexample is generated by Uppaal, or when a random / manual trace is present in the Simulator, it is able to save the trace in Uppaal’s .xtr format. However, this format is human-unreadable. This article records the steps to compile and use the tracer utility for showing Uppaal traces outside of the GUI. Assuming we are working under the Ubuntu 11.04 environment.

Installing Necessary Packages

The libboost-dev and libxml2-dev packages are needed by the Uppaal Timed Automata Parser Library.

sudo apt-get install libboost-dev libxml2-dev

Compiling the UTAP library

The installation is a simple process as usual.

./configure
make
make check
sudo make install

For some reasons, however, there are errors when compiling the code. Essentially there are three groups of things to fix.

  1. #includes in the source sometimes include string, which should be modified to string.h for some functions like strcmp, and strncpy to work.
  2. There are missing #includes so that certain functions do not work. E.g., the for_each function is in the algorithm package of Boost but not properly included.
  3. Some type definitions are not found, such as int32_t. Changing this to int works fine for the moment.

Once these are fixed, the installation process went through smoothly.

Using the tracer Utility

The tracer utility takes a Uppaal intermediate format and a saved .xtr file as the only two inputs. To get the Uppaal intermediate format for a model in the .xml format, one should use

UPPAAL_COMPILE_ONLY=1 verifyta model.xml - > model.if

The dash here is a placeholder for the query file, which is not necessary for intermediate format generation but helps pass syntax check by verifyta.

With the generated intermediate format, one can reconstruct the trace is a readable format.

tracer model.if trace.xtr

Also, one can use the pretty utility to pretty-print a Uppaal model in a C-like format.

pretty model.xml

Update: Compiling the UTAP library under MacOSX

Under Mac OS X, the boost library is not by default available (if it is installed separately, with MacPorts for example). If this is the case, it is necessary to add options to ./configure as follows.

./configure LDFLAGS=-L/opt/local/lib CXXFLAGS=-I/opt/local/include

Update: Issues with aclocal.m4

For some unknown reasons the aclocal.m4 file changes quite a bit; it even changes from plain text to binary files. This makes the compiling process fail. Just replace it with the pristine version that comes with the libutap library and the compiling should be fine.

Downloading and configuring Java Pathfinder

Posted in Quick References by Vincent on October 10, 2011

Downloading and Installing

First install Mercurial.

sudo apt-get install mercurial

Then grab the source for jpf-core and jpf-symbc packages. They are the main files for Java Pathfinder.

hg clone http://babelfish.arc.nasa.gov/hg/jpf/jpf-core
hg clone http://babelfish.arc.nasa.gov/hg/jpf/jpf-symbc

Site Configuration

Create a site configuration file with the name ~/.jpf/site.properties.

# JPF site configuration

jpf-core = ${user.home}/Software/jpf/jpf-core

# numeric extension
jpf-numeric = ${user.home}/Software/jpf/jpf-numeric

# symbolic extension
jpf-symbc = ${user.home}/Software/jpf/jpf-symbc

extensions=${jpf-core},${jpf-numeric},${jpf-symbc}

#... and all your other installed projects

Building Java Pathfinder

cd jpf-core
bin/ant test
cd ../jpf-symbc
bin/ant test
cd ../jpf-numeric
bin/ant test

Installing the Eclipse plugin

Use Eclipse 3.5+ and Java 1.6+, and this update site link: http://babelfish.arc.nasa.gov/trac/jpf/raw-attachment/wiki/install/eclipse-plugin/update/
To find out that it is properly installed, see in the preference window if there is a page for Java Pathfinder.

Tips on customizing Windows 7 (to be continued)

Posted in Quick References by Vincent on August 20, 2011
Tagged with:

Configuring a Windows machine with necessary installations

Posted in Quick References by Vincent on June 30, 2011

Here is a list of software to install on a new Windows machine.

Tagged with:

Must-have firefox extensions

Posted in Quick References by Vincent on May 6, 2011

Here is a list of Firefox extensions that I cannot live without.

  • Download Status Bar
  • Adblock Plus
  • Flagfox
  • ActiveInbox for Gmail
  • Colorful Tabs
  • LeechBlock

Additionally, here are some more useful ones. I am not sure they are updated often to come up with Firefox 5 now.

  • BBDict
  • CHM Reader
  • Delicious Bookmarks
  • Firebug
  • FireGestures
  • FireShot
  • Google Notebook
  • Greasemonkey
  • IE Tab
  • Speed Dial
  • Tab Mix Plus
  • Web Developer
Tagged with: ,
Follow

Get every new post delivered to your Inbox.