Recent Notes

Displaying keyword search results 1 - 10
Created by magnum on October 22, 2012 15:46:44    Last update: October 22, 2012 15:46:44
Example code from the Linux Programmer's Manual: #include <stdio.h> #include <stdlib.h> #incl...
Created by voodoo on September 17, 2012 15:02:15    Last update: September 17, 2012 15:02:15
Start gdb with the executable and coredump: $ gdb <path to executable> core While in the debugger, use the following commands: (gdb) where ("shows a summary of the stack") ... Example debug session from Debugging Under Unix: gdb Tutorial : Use backtrace (or bt ) to see the callstack: (gdb) backtrace #0 Node<int>::next (this=0x0) ... Inspect the value of item_to_remove at address 0xffbef014 (the value is 1): (gdb) x 0xffbef014 0xffbef014: 0x00000001 (g... Note: The program must be compiled with the debug switch -g in order to see the source code. More resources: Linux software debugging with GDB Debugging with gdb
Created by magnum on October 06, 2011 14:35:20    Last update: October 06, 2011 14:35:20
The longjmp function jumps to the line where setjmp was last called. In return, setjmp returns the value passed in as the second parameter to longjmp . #include <stdio.h> #include <stdlib.h> #incl... Result: $ ./longjmp val is 0 val is 1 --> val is ...
Created by magnum on October 06, 2011 12:32:21    Last update: October 06, 2011 12:32:21
What's the value of INADDR_ANY ? You can look it up in header files, but it's equally easy to get it with a little code: #include <stdio.h> #include <arpa/inet.h> ... Output: $ ./inaddrvalue INADDR_ANY value: 0.0.0.0
Created by woolf on June 30, 2011 16:17:29    Last update: July 01, 2011 07:26:26
Code: #include <stdlib.h> #include <string.h> #inc... Prints: Value of i: 6867666564636261 Value of i: 616263... Actually, the second part is better written as: i = 0L; int j; for (j = 0; j < 8; j+...
Created by alfa on May 27, 2011 11:19:29    Last update: May 31, 2011 07:56:26
This is a utility to convert a string value to one of the primitive type values. It is useful in Java reflection code where the value comes in as a string (e.g., from XML parsing), and the type of the value cannot be decided until runtime. import java.util.*; import java.lang.reflect.*;... Note: This method can be extended to convert string to more complex types by writing a converter for the destination type. For example, to convert string to date: public class DateConverter { public static ... Usage: Date d = (Date) ConvertUtil.convert("10/12/2010", ...
Created by alfa on May 24, 2011 14:52:53    Last update: May 26, 2011 19:52:12
import java.lang.reflect.Method; public cla...
Created by jinx on May 16, 2011 20:21:38    Last update: May 16, 2011 20:21:38
PHP compares two arrays element for element for equality. Two arrays are considered equal when they have the same number of elements, and for each element key and value both match. Test code: <?php $cmp = array( array(array(1), array(1... Outputs: array(1) { [0]=> int(1) } array(2)...
Created by Dr. Xi on April 20, 2011 21:44:15    Last update: May 02, 2011 20:56:58
The String.format() method provides versatile formatting capabilities. This tutorial tries to present these capabilities in a accessible manner. The format string A format string can contain zero, one, or more format specifiers . The general form of a format specifier is: %[argument_index$] [flags] [width] [.precision]co... where things in square brackets are optional, and conversion is a character indicating the conversion to be applied to the corresponding variable value. The only required characters in the format specifier is the percent sign % and the conversion character. A simple example: public static void simpleFormat() { System.out... The Argument index The argument index is specified by a number, terminated by the dollar sign $ . The same argument may be repeated multiple times in a format string. Unindexed...
Created by freyo on April 18, 2011 15:08:21    Last update: April 18, 2011 15:12:20
Generate android project $ ~/android-sdk-linux_86/tools/android create proj... Create XML file res/xml/books.xml : <?xml version="1.0"?> <catalog> <book id=... Edit layout ( res/layout/main.xml ): <?xml version="1.0" encoding="utf-8"?> <Lin... Edit code ( src/com/android/xmlres/XMLResource.java ): package com.android.xmlres; import java.io.... Change activity label from app_name to booklist ( AndroidManifest.xml ): <?xml version="1.0" encoding="utf-8"?> <manifes... Add value for string resource ( res/values/string.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc... Deploy and test: ant install
Previous  1 2 Next