Recent Notes
Displaying keyword search results 1 - 10
Created by freyo on February 06, 2013 21:10:47
Last update: February 06, 2013 21:12:18
I have an old Samung phone to be used as a toy. After restoring back to factory image and power on, I was stuck at the activate service screen. Unfortunately, the four corner magic touch did not work. So I did quite a bit of digging and this is what worked on my Samsung Continuum: Press emergency call button, then at the dialer, press * # 8 3 7 8 6 6 3 3 , press the Home key From the home screen, tap phone icon, Dial * # 2 2 7 4 5 9 2 7 Enter SPC code: ______ displays tap in white box to show virtual keyboard, enter 6 digit code (default: 000000), tap OK Select “Hidden menu Enable”, tap OK From...
Created by James on August 01, 2012 14:26:53
Last update: August 01, 2012 14:26:53
The jQuery size() function returns the number of elements in the jQuery object.
According to jQuery doc:
The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call.
Created by Fang on January 04, 2012 09:54:05
Last update: January 04, 2012 09:54:05
There are two ways to validate a form with JSF: jsf validation on the page with <f:validate...> tags (for example: <f:validateLength> , <f:validateRegex> , etc.), or JSR303 bean validation. This note is about how to customize messages for JSR303 bean validation. The validation message is specified in the message attribute for each validation annotation type. The mesage attribute is not a literal string, but a string that is interpolated in various ways. For example, the default validation message for AssertFalse is {javax.validation.constraints.AssertFalse.message} , which is replaced with the corresponding string in ValidationMessages.properties (or ValidationMessages_tr.properties , ValidationMessages_es.properties , depending on the locale). This is the contents of ValidationMessages.properties in the hibernate validator reference implementation:
javax.validation.constraints.AssertFalse.message =... To customize the messages, just provide the new value in...
Created by magnum on September 11, 2011 19:46:09
Last update: September 11, 2011 19:46:09
A pair of C functions convert between an Internet address and a string (ASCII):
#include <arpa/inet.h>
/*
* Returns a poin...
However , these functions do not support IPv6. The new pair is:
#include <arpa/inet.h>
/* Convert a Internet ad...
Examples:
#include <sys/socket.h>
#include <netinet/in.h>...
Created by freyo on August 31, 2011 15:49:54
Last update: August 31, 2011 15:49:54
Got this error while trying to build Android app:
[apkbuilder] Creating AppInfo-debug-unaligned.ap...
Solution:
Delete the Android debug keystore:
$ rm ~/.android/debug.keystore
Build again:
$ ant debug
The new key is valid for 30 years (keystore password is 'android'):
$ keytool -list -v -keystore ~/.android/debug.keys...
Created by Dr. Xi on February 17, 2011 12:34:58
Last update: August 10, 2011 09:04:32
String comparison operators: Operator Meaning -n str the length of str is nonzero. -z str the length of str is zero (0). str1 = str2 str1 and str2 are the same (note one equal sign, not two!). str1 != str2 str1 and str2 are not the same. str str is not a null string Examples:
# empty string is not null if [ '' ]; then ... Numerical comparisons ( integer expressions only! ): Operator Meaning int1 -eq int2 int1 and int2 are numerically equal int1 -ne int2 int1 and int2 are numerically NOT equal int1 -gt int2 int1 is greater than int2 int1 -ge int2 int1 is greater than or equal to int2 int1 -lt int2 int1 is less than int2 int1 -le...
Created by alfa on May 04, 2011 12:08:57
Last update: July 15, 2011 12:31:41
To read a whole file at once into a byte array:
File theFile = new File("test.bin");
byte[] byt...
It is important that the total number of bytes read is used for the while condition. Changing the loop to the following may result in an infinite loop !
int m = 0, n = 0;
while (n >= 0) {
n = i...
Created by alfa on April 11, 2011 21:40:51
Last update: April 11, 2011 21:40:51
Integer.bitCount counts the number of one-bits in the two's complement binary representation of the specified int value. Example code:
public class CountOnes {
public static void...
For long , there's Long.bitCount()
Created by Dr. Xi on March 29, 2011 16:06:57
Last update: April 01, 2011 12:33:52
This utility class retrieves SSL certificates from the server and print them out to the stdout. The output can be saved to a file and imported to a Java keystore. This is useful in your test environment where the SSL certificate is self-signed.
import java.io.InputStream;
import java.io.Outp...
Retrieve and import the a certificate:
E:\test>java RetrieveSSLCert 192.168.69.144 8081 >...
Created by Dr. Xi on March 30, 2011 13:43:05
Last update: March 30, 2011 13:45:27
Method 1 - use javap with verbose flag:
$ javap HelloWorld -verbose | head
Compiled fro...
Method 2 - use a utility class:
import java.io.*;
import java.nio.ByteBuffer;
...
According to the VM Spec , a Java class file has this structure:
ClassFile {
u4 magic;
...