Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on November 12, 2011 21:03:03    Last update: November 12, 2011 21:03:03
Experts may disagree but I found it absolutely stunning that JSF EL does not provide an operator for string concatenation. The Java "+" operator is there for the take. Java, which is a strongly typed compiled language, overloads the "+" operator in such a way that any object can be concatenated with a string. But JSF EL, which definitely isn't as strongly typed as Java, restricts the "+" operator to numerical values only! Of course, experts may argue that the "+" operator overloading is a huge design flaw of the Java language. But even so, JSF EL is not the right place to fix it! In some cases, a concatenation operator isn't needed, for example: <ui:repeat var="tab" value="#{tabs}"> <img ... But in case the concatenated...
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 Fang on October 28, 2011 13:49:40    Last update: October 30, 2011 19:23:25
This is a simple example to demonstrate the templating power of JSF facelets. If you've used struts tiles before, you'll recognize the simplicity of templating with facelets. I've stripped out everything else except the pages themselves, just to put our focus on facelets. This is a Maven based project, and you need Tomcat (or any servlet container) to run the resulting webapp. To begin with this is the list of files: ./pom.xml ./src/main/webapp/home.xhtml ./src... I left faces-config.xml in there for completeness sake, it may not be needed. The Maven POM ( pom.xml ): <?xml version="1.0" encoding="UTF-8"?> <project... Web app configuration ( WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Empty WEB-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <!-- Thi... index.jsp is simply a redirect to home.jsf : <% response.sendRedirect("home.jsf"); %>...
Created by magnum on September 27, 2011 11:57:49    Last update: October 05, 2011 12:20:00
This procedure sets up an IPSec vpn server on Linux with Preshared Key (PSK) using Openswan . Install Openswan: # yum install openswan Edit /etc/ipsec.conf . This is about the minimum needed to run IPSec server. Instead of running L2TP on port 1701, I'm running TCP on port 8080 so that I can test the setup with nc later. # /etc/ipsec.conf - Openswan IPsec configurati... Edit /etc/ipsec.secrets . # # Preshared key for clients connecting from a... Start IPSec: # /etc/init.d/ipsec start Check status: # ipsec auto --status Monitor IPSec log: # less /var/log/secure If IPSec is running KLIPS, you should see a new nic ( ipsec0 ). There's no ipsec0 if IPSec is running NETKEY. # ifconfig eth0 Link encap:Ethernet HWadd...
Created by magnum on September 19, 2011 08:52:35    Last update: September 20, 2011 09:14:02
This is a step-by-step guide: How to setup pptp vpn server on linux (fedora 14) It looks like that the only PPTP server on Linux that had any influence was Poptop , which was last updated in 2007. There doesn't seem to be much interest in keeping pptpd up-to-date on Linux, and the reason could be that PPTP itself isn't much secure. From Wikiperia : PPTP has been the subject of many security analyses and serious security vulnerabilities have been found in the protocol. The known vulnerabilities relate to the underlying PPP authentication protocols used, the design of the MPPE protocol as well as the integration between MPPE and PPP authentication for session key establishment. In fact, the maintainers of PPTP Client and Poptop recommend...
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 June 28, 2011 11:11:03    Last update: June 28, 2011 11:11:03
This exception occurs when trying to get a private key: PrivateKey privateKey = (PrivateKey) keyStore.getK... Stack trace: Exception in thread "main" java.security.Unrecover... which was caused by giving a wrong private key password. The solution is to correct the key password in your code, or change the password in the keystore to match that in your code: keytool -keypasswd -alias mykey -keypass oldpasswo...
Created by freyo on May 17, 2011 12:45:18    Last update: May 17, 2011 13:03:57
This works for JDK1.6 and later. Export the key to a PKCS#12 store, using -importkeystore ! keytool -importkeystore -srckeystore ~/.keystore \... Use openssl to convert the key to PEM (which produces a des3 encrypted key): openssl pkcs12 -in androidplatform.p12 -out androi... If you don't want DES encryption: openssl pkcs12 -in androidplatform.p12 -out androi... Convert both private key and cert to PEM: openssl pkcs12 -in androidplatform.p12 -out androi...
Created by jinx on May 03, 2011 09:42:12    Last update: May 03, 2011 09:42:12
The @ operator suppresses error messages. A usual example is: <?php $v = @$a['non-existing-key']; ?> which suppresses the "undefined index" PHP notice. Another example is: <?php @include('non_existent_file'); ?> In this case, @ not only suppresses error messages for non-existing file, it also suppresses any error messages coming from the included file when it does exist. Create file test.php : <?php @include('test.inc'); ?> Create test.inc : <?php <?php garbage ?> The "undefined constant" PHP notice message is suppressed by @ .
Created by jinx on April 14, 2011 21:51:22    Last update: April 15, 2011 08:04:41
Using ksort to sort a PHP array by key. Example 1: <?php $a = array( 'd' => 'lemon', ... Outputs: array(4) { ["a"]=> string(5) "apple" ... Example 2: <?php $a = array( 'd' => 'lemon', ... Outputs: array(4) { ["b"]=> string(6) "banana" ... This makes no sense (most likely a bug)! Re-arrange the initial array above: <?php $a = array( 'd' => 'lemon', ... Outputs: array(4) { ["b"]=> string(6) "banana" ... So, the sorted result depends on the initial order of the array, even though all of the keys are distinct! Bug? ksort takes an optional second parameter - sort flags, which can be: SORT_REGULAR - compare items normally (don't change types) SORT_NUMERIC - compare items numerically SORT_STRING - compare items as strings SORT_LOCALE_STRING -...
Previous  1 2 3 Next