Create Custom Widgets using InkScape and NetBeans Visual Library

Posted: May 5th, 2010 | Author: | Filed under: java | 3 Comments »

This blog entry shows one how to create a special widget using InkScape and NetBeans Visual Library. This is part of my effort to create a Java-based implementation of MIT’s Scratch, which is implemented in Squeak Smalltalk.

Step 1 Create JScratch Block Graphics:

First I created the image using Inkscape (steps to follow), import the image to IDE, then create two LayerWidgets, one transparent, and another opaque. Add the image to the background LayerWidget, adn the Swing component to the front LayerWidget. Finally, use the BorderFactory.createEmptyBorder function to limit the size of the swing component at the front layer.

To create the Scratch blocks, I used InkScape, the Open Source SVG editor. Here are the steps I took to create the graphic:

Read the rest of this entry »


Turn on Code Highlighting in Joomla CodeCitation Plugin

Posted: May 2nd, 2010 | Author: | Filed under: web | No Comments »

Just got CodeCitation to work on my Joomla site and here are the steps I took:

Read the rest of this entry »


libtool and glibtool

Posted: April 12th, 2010 | Author: | Filed under: iphone | 1 Comment »
This is the content of a typical autogen.sh (for Linux and Unix systems) script which utilize auto tools such as aclocal, libtool, and automake to generate necessary files for building a project.
#! /bin/sh
# a quick hack script to generate necessary files from
# auto* tools.
#
# WARNING: if you run this you will change the versions
# of the tools which are used and, maybe, required!
        touch Makefile.am configure.ac
{
        echo "running libtoolize"
        glibtoolize --force --copy --automake
}  {
        echo "running aclocal"
        aclocal
} {
        echo "running autoheader [ignore the warnings]"
        autoheader
}  {
        echo "running automake"
        automake --force-missing --foreign -a -c
}  {
        echo "running autoconf"
        autoconf
}
        echo "autogen complete"  ||
        echo "ERROR: autogen.sh failed, autogen is incomplete"

For MacOS, just replace libtool with bligtool, and libtoolize with glibtoolize.

        echo "running libtoolize"
        glibtoolize --force --copy --automake

JScratch Dev

Posted: March 26th, 2010 | Author: | Filed under: java | No Comments »

JScratch Development Notes

This article documents how I set up my development environment for JScratch development. It’s helpful and often crucial for a project’s success to have a detailed documentation on how a development environment is set up.

Read the rest of this entry »


Build OpenCV on Snow Leopard

Posted: January 15th, 2010 | Author: | Filed under: iphone | 2 Comments »

t took me whole day yesterday to build OpenCV for my Snow Leopard. I still need to add the FFMPEG support but for now, it is turned off. I’ve followed the Mac OS X OpenCV Port doc.

svn co https://code.ros.org/svn/opencv/trunk opencv
cd opencv mkdir opencv/build cmake ..
ccmake .

Hit ‘t’ to toggle advanced mode.

Set
CMAKE_CXX_COMPILER to “/usr/bin/g++-4.0″ and CMAKE_C_COMPILER” to /usr/bin/gcc-4.0″.

I also need to turn off FFMPEG and LIBDB1394, because I could not get them to install properly yet on Snow Leopard.

Turn on the BUILD_EXAMPLE. Hit ‘c’ to configure and then ‘g’ to generate the config files and exit ccmake.

make -j8 su
make install

To build the example, I need to change the opencv/sample/c/build_all.sh to the following: (change gcc to gcc-4.0 and g++ to g++-4.0, and also add “-arch i386″)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
if [[ $# > 0 ]] ; then
	base=`basename $1 .c`
	echo "compiling $base"
	gcc-4.0 -arch i386 -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base
else
	for i in *.c; do
		echo "compiling $i"
		gcc-4.0 -arch i386 -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
	done
	for i in *.cpp; do             
		echo "compiling $i"             
		g++-4.0 -arch i386 -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
done fi

To build the c sample, just type:
./build_all.sh

Next step for me would be to build the universal library for OpenCV from Snow Leopard. Reference:


Connect to SQL Server in Perl and in VBScript

Posted: October 15th, 2009 | Author: | Filed under: database | No Comments »

Say my database name is Jessica_DB, my user name is jessica, and my password jessica_pwd.

Perl

To connect to Microsoft SQL Server using Perl with Win32::ODBC module

use Win32::ODBC;
my $dsn = "DSN=Jessica_DB;UID=jessica;PWD=jessica_pwd;";
my $DB = Win32::ODBC->new($dsn);
$DB->Sql("SELECT f1, f2, f3 FROM MyTable");
$DB->FetchRow();
($f1, $f2) = $DB->Data("f1", "f2");
print "f1 = ". $f1;
$DB->Close();

VBScript

To connect to MS SQL Server using VBScript

Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
 "Provider=MSDASQL.1;Data Source=Jessica_DB;" & _
 "Trusted_Connection=Yes;" & _
 "User ID=jessica;Password=jessica_pwd;"
objRecordSet.Open "SELECT * FROM MyTable", _
 objConnection, adOpenStatic, adLockOptimistic
 
objRecordSet.MoveFirst
Wscript.Echo objRecordSet.RecordCount

Python

To connect in Python, check out pymssql


Connect PC to Cisco Switch or Router

Posted: October 6th, 2009 | Author: | Filed under: networking | No Comments »

To connect a PC which has two network interfaces (one Ethernet and another wireless) to a LAN, you will want to create a default route to the wireless interface, assuming you are using the wiressless network to get to the Internet (WAN). Here is a link on how to set up a default route on a Windows machine:

Here is the command to add a default route(assume 192.168.201.1 is your WAN gateway)

route add 0.0.0.0 mask 0.0.0.0 192.168.201.1

You will also need to add a static route so that all traffic going to LAN are directed to the LAN gateway, instead of to WAN. Here is how:

route add 10.100.0.0 mask 255.255.0.0 10.100.0.1

Useful links:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/route.mspx?mfr=true


Set up a Cisco switch

Posted: October 5th, 2009 | Author: | Filed under: networking | 14 Comments »

This entry shows the step I took to set up a Cisco switch at work

Read the rest of this entry »


Reflection in Inkscape, GIMP, and Photoshop

Posted: September 27th, 2009 | Author: | Filed under: computer graphic | No Comments »

Ever wonder how to create those cool images with reflection, such as the image below? You can create them using Inkscape and GIMP, two free Open Source tools, and of course, with Photoshop. When I need to add reflection to an image quickly, I usually use Inkscape. Check it out! It’s great for making simple site logo as well.

reflection-red

InkScape

http://aqeeliz.com/2007/03/12/inkscape-tutorial-reflection/

Photoshop

http://pstutorialsblog.com/81/reflection-tutorial/

http://pstutorialsblog.com/82/3d-object-reflection-tutorial/

GIMP

http://gimp-tutorials.net/node/236


Add a NextPage button on WorldPress Editor

Posted: September 17th, 2009 | Author: | Filed under: web | 1 Comment »

Open the functions.php in your theme directory. For example, if your theme is tigra, then open the functions.php in <wordpress-path>/wp-content/themes/tiga.[...] Read the rest of this entry »