Recent Notes

Displaying keyword search results 11 - 20
Created by freyo on June 09, 2011 15:52:12    Last update: June 09, 2011 15:52:30
Follow these steps to add a device administrator application to Android, i.e., make the application appear in the "Select device administrators" screen (Settings -> Location & Security -> Select device administrators): Add a receiver in AndroidManifest.xml : <receiver android:name="android.app.admin.DeviceAd... All elements and attributes listed above are needed. The attribute android:description must be a string resource, not a literal string. The meta-data element points to an XML resource. Create the meta-data resource res/xml/admin_app_resource.xml : <device-admin xmlns:android="http://schemas.androi... Define values for string resources ( res/values/strings.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc...
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 jinx on April 29, 2011 15:03:10    Last update: April 29, 2011 15:04:02
The PHP function is_callable verifies that a variable can be invoked as a function. Example: <?php define('F', 'f'); function... Output: var_dump: string(1) "f" is_callable: 1 Calla...
Created by Dr. Xi on April 26, 2011 20:12:01    Last update: April 28, 2011 15:28:12
An XML schema is a definition of XML files, in XML. It plays the same role as old-time DTDs. Overall, an XML schema file looks like this: <schema attributeFormDefault = (qualified | u... The attribute meanings: targetNamespace : The name space targeted by the current schema definition. It can be any URI. id and version : For user convenience, the W3C spec defines no semantics for them. xml:lang : Natural language identifier defined by RFC 3306 . attributeFormDefault and elementFormDefault : Set default values for the form attribute for attribute and element declarations. blockDefault and finalDefault : Set default values for the block and final attributes for attribute and element declarations. The W3C defined some built-in datatypes . Examples of primitive datatypes are: string ,...
Created by jinx on April 17, 2011 20:40:12    Last update: April 17, 2011 20:40:56
For JavaScript in the <script> block or JavaScript included with a src attribute: nothing more is needed than escaping the single quote or double quote - depending on how the JavaScript string is quoted. Example: var a = 'My name is <?php echo str_replace('\'', '... For inline JavaScript, escape HTML special characters : <?php echo '<a href="test" onclick="alert(\...
Created by freyo on April 12, 2011 13:05:33    Last update: April 12, 2011 13:06:26
android:sharedUserId (from Android doc): The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process. Declare sharedUserId in AndroidManifest.xml : <manifest xmlns:android="http://schemas.android.co... Retrieve sharedUserId programmatically: import android.content.pm.PackageManager; impor...
Created by Dr. Xi on March 28, 2011 20:51:30    Last update: March 28, 2011 20:53:46
HTTP basic authentication is just Base64 encoded user name and password passed in as the Authorization header. So the following code works: // encode user name and password String credent... However, since JDK 1.2, there's a more Java friendly way: Authenticator.setDefault(new Authenticator() { ... Test code: import java.net.*; import java.io.*; pub...
Created by Dr. Xi on March 28, 2011 11:11:33    Last update: March 28, 2011 11:13:21
grep is a versatile command with many variations (grep, egrep, fgrep, then various implementations). It uses a regula expression (regex) pattern to filter input. But then there are basic and extended flavors of regex - leading to even more confusion. And, beware that there are lots of bad examples of regex in the wild... There are two critical questions to ask when you use grep: which grep implementation are you using? what is the flavor of the regex? Here are some examples for gnu grep v2.7: # Find all numbers (no decimal point), basic regex... Use the -o flag to show only the matching part instead of the whole matching line: grep -o -E '\b[0-9]{2}\b' The good thing about the gnu grep is that it...
Created by magnum on March 02, 2011 19:38:41    Last update: March 02, 2011 19:38:41
Once you apply a filter to a URL pattern: <filter-mapping> <filter-name>theFilter</fi... there's no option in web.xml to exclude a more specific pattern such as: /public/* . But you can put the exclusion logic in the filter itself: <filter> <filter-name>theFilter</filter-nam... And in the filter code: public void init(FilterConfig cfg) throws ServletE...
Created by Dr. Xi on August 31, 2008 20:43:44    Last update: January 22, 2011 12:48:08
It's probably more useful to make the JavaScript executor a bookmarklet. That way it gains access to the page on which it is invoked. Therefore, more helpful while debugging. Here's the code: <html> <body> <a href="javascript:(funct... Or, you can add this link to your bookmarks, name it "JS Executor". For a full featured JavaScript console, you may need Jash
Previous  1 2 3 4 5 Next