Displaying keyword search results 1 - 10
Created by magnum on October 22, 2012 20:03:05 Last update: October 22, 2012 20:03:05
First, the test command that sleeps random number of seconds ( sleeper.sh ):
#!/bin/bash stime=$[$RANDOM % 20] sleep $sti...As comparison, synchronous pipe code:
#include <sys/wait.h> #include <stdio.h> #in...Asynchronous pipe code:
#include <sys/wait.h> #include <stdio.h> #in...
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> coreWhile 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 September 11, 2012 12:10:03 Last update: September 11, 2012 12:10:46
Sample code for UDP client and server in C. The server simply echos back the client message. The client stays in "receive" loop to demonstrate the connection-less nature of the UDP protocol. Server code:
#include <stdio.h> #include <stdlib.h> #incl...Client code:
#include <stdio.h> #include <stdlib.h> #incl...Try it out: Start the server with:
./udpserver 8888Send message to server:
./udpclient localhost 8888 "Hi, it's me! "Server console displays:
Received from 127.0.0.1:41776: Hi, it's me!UDP is connectionless. Send a message from a second client to the first client:
$ ./udpclient localhost 41776 "From client 2"First client console displays:
$ ./udpclient localhost 8888 "Hi, it's me! " Re...It should be noted that the distinction between client and server is blurry. The only major...
Created by Dr. Xi on August 15, 2012 12:05:39 Last update: August 15, 2012 12:05:39
Use OpenSSL's s_client command to fetch a page manually:
$ openssl s_client -connect localhost:443 -state -...Sample session for Google:
$ openssl s_client -connect www.google.com:443 -st...Resource: SSL/TLS Strong Encryption: FAQ
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 Fang on September 07, 2009 20:44:15 Last update: November 03, 2011 14:43:19
Step 1: Repackage a web app as EAR A Java EE application is a multimodule Maven project. At the very least you'll need to package a WAR and an EAR. To get started, I'll simply re-package the simple webapp as an EAR. Create a directory named javaee-app Copy the webapp from here to javaee-app . Rename struts1app to webapp . Create pom.xml under javaee-app :
<project> <modelVersion>4.0.0</modelVersion>...Create a directory named ear under javaee-app . Create pom.xml under ear :
<project> <modelVersion>4.0.0</modelVersion>...Modify pom.xml in the webapp directory so that it looks like this:
<project> <modelVersion>4.0.0</modelVersion> ...Build with " mvn package " in the javaee-app directory. You can see that ear-1.0.ear is successfully generated in javaee-app/ear/target . Maven successfully resolves dependencies between the sub-projects....
Created by freyo on September 09, 2011 11:43:36 Last update: September 09, 2011 11:45:45
When you run automated Android tests with Eclipse or from the command line, you get text output, which isn't good for reporting purposes. If you run a large set of test cases with automated build, the text report isn't very helpful. Fortunately, Android CTS generates test reports in XML with accompanying XSL to make it look nice in a browser. To run your own tests with Android CTS: Download Android CTS Make a new directory MyRepository under android-cts , alongside the existing repository directory. Copy host_config.xml from repository to MyRepository Create directory plans under MyRepository , add a test plan ( MyTests.xml ):
<?xml version="1.0" encoding="UTF-8"?> <TestPla...Create directory testcases under MyRepository . Copy TestDeviceSetup.apk from repository/testcases to MyRepository/testcases Under MyRepository/testcases , create a test...
Created by freyo on September 07, 2011 16:46:14 Last update: September 07, 2011 19:23:00
The Android unit test framework is based on JUnit 3 , not JUnit 4. Test cases have to extend junit.framework.TestCase or a subclass (such as android.test.InstrumentationTestCase ). Tests are identified by public methods whose name starts with test , not methods annotated with @Test (as in JUnit 4). An Android test suite is packaged as an APK, just like the application being tested. To create a test package, first you need to identify the application package it is testing. Google suggests to put the test package source in a directory named tests/ alongside the src/ directory of the main application. At runtime, Android instrumentation loads both the test package and the application under test into the same process. Therefore, the tests can invoke methods on...
Created by Dr. Xi on July 15, 2011 09:25:15 Last update: July 15, 2011 09:25:15
Some methods to search for a substring within a string: To know that a substring indeed exists within a string:
boolean found = wholeString.contains(substring);To find where the substring is contained:
int index = wholeString.indexOf(substring);If the substring is regex:
boolean match = wholeString.matches(".*" + substri...Case insensitive match: convert both whole string and substring to lowercase, then compare. Or, use case insensitive flag for regex. Test code:
import java.util.regex.*; public class Stri...