Recent Notes
Displaying keyword search results 1 - 10
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 Fang on April 16, 2012 13:18:40
Last update: April 16, 2012 13:18:40
Simply call pageContext.setAttribute() to export a variable from within a JSP custom tag:
public class MyCustomVarTag extends TagSupport {
...
The availability of the exported variable can be limited in the TLD:
<tag>
<name>setVar</name>
<tag-class...
The availability scopes are:
Value Availability
NESTED Between the start tag and the end tag.
AT_BEGIN From the start tag until the scope of any enclosing tag. If there’s no enclosing tag, then to the end of the page.
AT_END After the end tag until the scope of any enclosing tag. If there’s no enclosing tag, then to the end of the page.
Created by Fang on December 05, 2011 14:56:47
Last update: December 05, 2011 14:57:09
This works for Tomcat. It may or may not work for other servlet containers. As far as I know it's not in the standards spec.
In web.xml:
<context-param>
<param-name>env</param-name>
...
If you start Tomcat without defining env , then #{initParam['env']} is ${env} . If you start Tomcat with -Denv=dev in JAVA_OPTS , then #{initParam['env']} is dev
Created by Fang on December 05, 2011 13:04:11
Last update: December 05, 2011 13:04:11
Facelet requires strict XML syntax, so unmatched tags (start with no end, etc) generate errors. This is a trick to workaround that. The following code generates a row for every three items and for each row assigns a row id:
<!-- using ui:repeat -->
<ui:repeat var="name" ...
Created by Fang on November 10, 2011 09:26:12
Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines!
<?xml version="1.0" encoding="UTF-8"?>
<xsd:sch...
Created by freyo on August 25, 2011 09:07:40
Last update: August 25, 2011 20:45:43
This is a list of built-in Android permission values: Permission Description Since API Level android.permission.ACCESS_CHECKIN_PROPERTIES Allows read/write access to the "properties" table in the checkin database, to change values that get uploaded. 1 android.permission.ACCESS_COARSE_LOCATION Allows an application to access coarse (e.g., Cell-ID, WiFi) location 1 android.permission.ACCESS_FINE_LOCATION Allows an application to access fine (e.g., GPS) location 1 android.permission.ACCESS_LOCATION_EXTRA_COMMANDS Allows an application to access extra location provider commands 1 android.permission.ACCESS_MOCK_LOCATION Allows an application to create mock location providers for testing 1 android.permission.ACCESS_NETWORK_STATE Allows applications to access information about networks 1 android.permission.ACCESS_SURFACE_FLINGER Allows an application to use SurfaceFlinger's low level features 1 android.permission.ACCESS_WIFI_STATE Allows applications to access information about Wi-Fi networks 1 android.permission.ACCOUNT_MANAGER Allows applications to call into AccountAuthenticators. Only the system can get this permission. 5 android.permission.AUTHENTICATE_ACCOUNTS...
Created by freyo on July 29, 2011 16:04:45
Last update: July 29, 2011 16:04:45
To start the Settings application:
# am start -n com.android.settings/.Settings
St...
To start the Browser :
# am start -n com.android.browser/.BrowserActivity...
To start the phone dialer:
# am start tel:210-385-0098
Starting: Intent { ...
Help for am command:
# am
usage: am [subcommand] [options]
...
Created by freyo on July 27, 2011 13:49:26
Last update: July 27, 2011 13:52:03
Some ways to pass data from one activity to another:
Add data to the Intent :
The sending side:
// create Intent
Intent intent = new Intent();
...
The receiving side:
Bundle bundle = getIntent().getExtras();
String...
Use SharedPreferences (data is persisted in this case):
The sending side:
SharedPreferences prefs = getSharedPreferences("pr...
The receiving side:
SharedPreferences prefs = getSharedPreferences("pr...
Created by freyo on April 01, 2011 14:29:25
Last update: June 29, 2011 13:58:27
Start the emulator ( create an AVD if none exists)
$ tools/emulator -avd Simple8 Create new project $ tools/android create project \ > --package co... where " --target 2 " identifies the target platform as displayed by " tools/android list targets ", which is stored in the properties file default.properties in the project root folder. cd HelloWorld and install debug package onto the running emulator: $ ant install Buildfile: build.xml [set... Launch the Hello World application on the emulator. You'll see something like this: Edit res/values/string.xml , change the contents to: <?xml version="1.0" encoding="utf-8"?> <resourc... Edit res/layout/main.xml , change the contents to: <?xml version="1.0" encoding="utf-8"?> <LinearL... The contents of the text area now refer to a string defined in the resource file strings.xml , instead...
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