Recent Notes
Displaying notes 51 - 60
Created by Dr. Xi on January 25, 2010 16:29:04
Thanks for the IDE tips. I wrote this tool out of a specific need: debugging errors at deployment time or issues in a production environment.
Created by google.P3SY7GMD on January 25, 2010 16:11:01
Simple have your project in eclipse, and your jars in the build path. Type CTRL-SHIFT-T... Just entre the name of the class and eclipse show from where it come from.
Created by voodoo on January 24, 2010 06:29:11
Last update: January 24, 2010 19:31:22
SIKULI is Jython. AutoPy is Python. Both use bitmaps to find areas of interest. It seems that SIKULI comes with an IDE but AutoPy doesn't. A sample SIKULI script captured from the project site: A sample AutoPy script from the project site: import autopy def where_is_the_monkey_i_say(): """Look for the monkey. Tell me if you found it.""" monkey = autopy.bitmap.Bitmap.open('monkey.png') barrel = autopy.bitmap.Bitmap.open('barrel.png') pos = barrel.find_bitmap(monkey) if pos: print "We found him! He's at %s!" % str(pos) else: print "There is no monkey... what kind of barrel is this?!" where_is_the_monkey_i_say()
Created by voodoo on January 17, 2010 00:15:47
A runlevel is used to group the daemons (services) to start. For the Fedora/Redhat based Linux systems, the primary runlevels are: runlevel 1: Single-User Mode runlevel 2: Multi-User Mode runlevel 3: Multi-User Mode with Networking runlevel 5: X11 (runlevel 3 + X Window System) The typical workstation runs in runlevel 5. Servers without X-server runs in runlevel 3. To determine what runlevel you are using: # /sbin/runlevel To determine what runlevel your system will boot with: # cat /etc/inittab | grep :initdefault: id:5:initdefault: To switch runlevels (replace RUNLEVEL with appropriate number): # /sbin/init RUNLEVEL When you switch runlevel, be sure that you are at a text console so that you don't accidentally kill your session when X-server is killed.
Created by woolf on January 15, 2010 05:00:14
Last update: January 15, 2010 05:03:49
Video taken with the Canon SD1200 camera comes in the AVI format, where the video is MJPEG and the audio is PCM. For some weird reason it doesn't play on my Windows XP box! The video is sluggish and the audio is often interrupted. But it works fine on my old Windows 2000 box. Since it's taking too much space anyway, I used mencoder to compress the video with XVID encoding and audio with MP3. This is the script. #!/usr/bin/perl $destdir = "C:/Documents and Settings/woolf/My Documents/My Videos"; $encodelog = "C:/tmp/mencoder.log"; $MEDIAINFO = "mediainfo"; # where is mediainfo executable? $MENCODER = "C:/local/MPlayer-athlon-svn-29319/mencoder"; if ($#ARGV < 0) { print "Usage $0 <inputfile>\n"; exit 1; } $srcfile = $ARGV[0]; if (not -f $srcfile) { print "File \"$srcfile\" does ...
Created by Dr. Xi on January 14, 2010 00:28:27
Last update: February 16, 2010 20:01:46
A task that a Java developer does so frequently is to find out where a certain class can be found - to resolve compilation errors, classpath issues, or version conflicts of the same class introduced by multiple class loaders. A long while back I wrote a simple Perl script to perform the task. Later I was informed that there are Swing based Jar Browser and Jars Browser . Then, there are a couple of shell one-liners: # one liner 1 find -name "*.jar" -print0 | xargs -0 grep -i SomeClassName # one liner 2 for i in $(find . -iname \*.*ar) ; do echo $i ;jar tf $i | grep $1; done But all of them share the same problem: if a class is in ...
Created by Fang on January 10, 2010 00:19:30
Last update: January 10, 2010 21:46:09
Maven is a powerful yet complex tool. When I started learning Maven, the first obstacle was, of course, its complexity. The second, was the lack of documentation that can get me off the ground quickly. This tutorial is an attempt to create a pragmatic guide that aims to get you familiar with Maven in the quickest way possible. The main theme is to get you on some hands on experience to start out and lead you through the creation of a simple Java EE project as quickly as possible. Instead of trying to give you a good read, I try to get you on the journey right away. The topics are roughly ordered by the logical sequence but you can jump around in any way ...
Created by Dr. Xi on January 08, 2010 03:53:37
Last update: January 08, 2010 03:54:56
This is an Ant custom task to merge Properties files I lifted from http://marc.info/?l=ant-user&m=106442688632164&w=2 , with some minor bug fixes. Example usage: <taskdef name="mergeProperty" classname="ant.task.addon.MergeProperties"/> <mergeProperty baseFile="${src.config}/config.properties" overrideFile="${src.config}/${target.env}.properties" destFile="${dest.config}/config.properties"/> Implementation: package ant.task.addon; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.InputStream; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Properties; import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; /** * MergeProperties provides functionality to merge two separate .properties * configuration files into one while preserving user comments. */ public class MergeProperties extends Task { /** determines source .properties file */ private File baseFile; /** determines property override file */ private File overrideFile; /** determines where final properties are saved */ private File destFile; /** stores a collection of properties ...
Created by Dr. Xi on January 07, 2010 23:56:00
This is a utility that generates a script to grant privileges for an existing schema for Oracle. import java.io.*; import java.sql.*; public class GenerateTablePrivilegeScript { private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver"; private static final String JDBC_URL = "jdbc:oracle:thin:@10.200.100.80:1521:MY_SCHEMA"; private static final String JDBC_USER = "MY_SCHEMA"; private static final String JDBC_PASSWD = "MY_PASSWORD"; public static void main(String[] args) throws Exception { if (args.length < 1) { usage(); System.exit(1); } String granteeName = args[0]; Class.forName(JDBC_DRIVER); Connection conn = null; try { conn = DriverManager.getConnection(JDBC_URL, JDBC_USER, JDBC_PASSWD); generateScript(conn, granteeName); } finally { if (conn != null) conn.close(); } } private static void generateScript(Connection conn, String granteeName) throws Exception { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery( "SELECT " + "owner, " + "table_name, " + "privilege, ...
Created by Dr. Xi on January 07, 2010 23:51:44
Last update: January 07, 2010 23:53:57
This is a utility to generate a "create synonym" script for Oracle for an existing schema. import java.io.*; import java.sql.*; public class GenerateSynonymScript { private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver"; private static final String JDBC_URL = "jdbc:oracle:thin:@10.200.100.80:1521:MY_SCHEMA"; private static final String JDBC_USER = "MY_SCHEMA"; private static final String JDBC_PASSWD = "MY_PASSWORD"; public static void main(String[] args) throws Exception { if (args.length < 1) { usage(); System.exit(1); } String schemaName = args[0]; Class.forName(JDBC_DRIVER); Connection conn = null; try { conn = DriverManager.getConnection(JDBC_URL, JDBC_USER, JDBC_PASSWD); generateSynonymScript(conn, schemaName); } finally { if (conn != null) conn.close(); } } private static void generateSynonymScript(Connection conn, String schemaName) throws Exception { Statement stmt = conn.createStatement(); // public synonyms ResultSet rs = stmt.executeQuery( "SELECT * FROM dba_synonyms where TABLE_OWNER = '" ...