edwin

Fixing WordPress’ Syntaxhighligther and Bootstrap Incompatibility

Today’s i just updated my wordpress’ theme, from the old one to a much better one. I like the newer one because it has more flexibility, and also for its responsive design.

But i had an issue, somehow my syntaxhighlighter gives an extra row space and it happen only in Firefox. Here is the screenshot,

syntax highlighter issue

Somehow my latest wordpress theme shows incompatibility with Sytaxhighlighter css file. After sometime googling, i found out that i need to override a css property so my Syntaxhighlighter would works.

div.syntaxhighlighter .container:before,div.syntaxhighlighter .container:after {
    content:none;
}

Well i hope it helped others, have fun 🙂

Binding Date Property to SpringMVC’s @ModelAttribute

Let say i have this java bean,

public class MyBean implements Serializable {
    private Integer id;
    private String userid;       
    private Date contacttime;
	
	// other setter and getter	

And i have a SpringMVC Controller like this, using @ModelAttribute as the method’s parameter,

@RequestMapping(value = "/doSomething", method = RequestMethod.POST)
public @ResponseBody Object doSomething(@ModelAttribute MyBean myBean) {
	// do something
}

Im sending HTTP Post which format is like this

id=2&
userid=3abc&
contacttime=130314101010

But it shows error on my server side, which looks like this,

Failed to convert from type java.lang.String to type java.util.Date for value '130314101010'; 
nested exception is java.lang.IllegalArgumentException

Usually, i have to manually use SimpleDateFormat to parse my “ddMMyyHHmmss” String into Date, but SpringMVC provide a very elegant way of handling with this kind of conversion. Just by using @DateTimeFormat

import org.springframework.format.annotation.DateTimeFormat;

public class MyBean implements Serializable {
    private Integer id;
    private String userid;       
	
	@DateTimeFormat(pattern = "ddMMyyHHmmss")
    private Date contacttime;
	
	// other setter and getter	

Dont forget to include JodaTime on your pom.xml

<dependency>
	<groupId>joda-time</groupId>
	<artifactId>joda-time</artifactId>
	<version>2.3</version>
</dependency>

If not, you will find this kind of error,

org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value '130314101010'; nested exception is java.lang.IllegalStateException: JodaTime library not available - @DateTimeFormat not supported

Have fun with SpringMVC 😀

How to Sniff Network Packages on HPUX Filtered By A Specific IP

Well on most of Linux distros, it’s very easy sniffing network packages using tcpdump, but on this case i need to sniff packages on HPUX, which doesnt have tcpdump installed.

So basically i have 2 options, install tcpdump on my hpux (which is very tricky because of limitation the sysadmin gave me), or simply by using HPUX’s build function for network sniffing, which is “nettl”.

On this example, im trying to sniff packages to and from a specific ip, first is creating a file which contain the target ip.

filter ip_saddr 192.168.0.11
filter ip_daddr 192.168.0.11

and i save it as /tmp/myfilter.

Next step is running nettl,

#this command is to start nettl
nettl -tn 0x30800000 -e ns_ls_ip -size 1024 -tracemax 99999 -f /tmp/raw.tr

#this command is to check nettl status
nettl -status TRACE

#this command is to filter sniffed network packages using filter
netfmt -N -n -l -c /tmp/myfilter -f /tmp/raw.tr.TRC000 > /tmp/trace.output

#this command is to stop nettl
nettl -tf -e all 

How to Inserting 0 To an AutoIncreament Field on MySql

Let say i have this table,

CREATE TABLE `refproductscale` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `scale` varchar(255) NOT NULL,
  `del` set('y','n') NOT NULL DEFAULT 'n',
  PRIMARY KEY (`id`)
)

I dont know why, but everytime im inserting ‘zero’ as its id, suddenly it changes into an increament number.
But with this script, im able to insert ‘zero’ as its id. This is my script,

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
insert into refproductscale values(0, 'none', 'n');

And this is the result,

All i have to do is use NO_AUTO_VALUE_ON_ZERO before i do insert query. 😉