RestEasy is a JBoss project that helps you build RESTful Web Services. It is JAX-RS compliant (Java API for RESTful Web Services).
It is designed for JBoss but I am actually using it with tomcat only. It is very easy to use in an Eclipse project. You can use:
JAX-RS Hello World with RESTEasy
.
Monday, July 5, 2010
Monday, June 28, 2010
Complexity of basic STL containers
| \ | . | possible implementation | insert/remove at the beginning | insert/remove at the end | find |
| vector | sequence, key not unique, back-insertion | dynamic array (malloc) | o(n) | o(1) | o(1) (operator[]) o(n) (iter or algo) |
| list | sequence, key not unique | doubly-linked list | o(1) | o(1) | o(n) (iter or algo) |
| set | sorted associative container, key unique | sorted tree | o(log(n)) | o(log(n)) | o(log(n)) |
| map | sorted associative container, key unique | sorted tree | o(log(n)) | o(log(n)) | o(log(n)) |
| hash_map | hashed associative container, key unique | hashmap | o(1) | o(1) | o(1) |
Notes:
- for insert/remove in list, assumes we have the iterator at the right position
- no push_back on associative containers
| \ | . | possible implementation | insert/remove at the beginning | insert/remove at the end | find |
| deque | sequence, key not unique o(n) in the middle | dynamic array or doubly-linked list | o(1) | o(1) | o(n) |
| slist | sequence, key not unique, single direction iterator, front-insertion | single-linked list | o(1) | o(n) o(1) if insert_after | o(n) |
1. vector
2. deque
3. list
4. slist
5. bit_vector
1. set
2. map
3. multiset
4. multimap
5. hash_set
6. hash_map
7. hash_multiset
8. hash_multimap
1. stack (LIFO)
2. queue (FIFO)
3. priority_queue
.
Thursday, May 27, 2010
templates
simple template:
Note: since the compiler replaces the templates, source code of the templates needs to be included where it is used (template source code in the .h for ex).
.
template < class F > class ClassTemp
{
public:
F test(F* feature );
};
template < class F >
F ClassTemp < F > ::test(F* feature)
{
return *feature;
};
ClassTemp < char > myInst;
int main()
{
char c = 'c';
char ret = myInst.test(&c);
}
Note: since the compiler replaces the templates, source code of the templates needs to be included where it is used (template source code in the .h for ex).
.
Wednesday, April 21, 2010
blogger / blogspot
I now backup only Ubuntu related stuff since "max-results" is not taken into account anymore in the query
to insert an array in blogger, you need to put all the HTML on one line... Otherwise, the array is displayed way down.
to insert HTML in blogger posts, haven't found easier than putting "amp lt;" < and "amp gt;" >
.
http://swiss-knife.blogspot.fr/search?q=ubuntuto see all posts, or backup blogger blogs:
http://swiss-knife.blogspot.fr/search?max-results=1000&start=0
.
Saturday, April 17, 2010
maven
- to display all the targets:
mvn -g > toto.txt
- List of targets are in project.xml, see "build" target
- "dist:" postgoals are described in maven.xml
- To add a jar like mysql, you need to add it to project.properties and project.xml
- Maven plugin for eclipse:
- http://download.eclipse.org/technology/m2e/releases
- http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven Note: use Maven/asembly and not Maven/Packaging
- mvn assembly:assembly -Dmaven.test.skip=true (doesn't build tests)
- mvn assembly:assembly -DskipTests=true (doesn't do tests, but build them)
- New Maven project for Eclipse
- from the command line:
- cd EngineApi
- mvn install
- mvn eclipse:eclipse
- Import the project into Eclipse as a maven project
- Right click on the Eclipse project: "Maven / Enable Dependencies Management" then "Maven / Update Project Configuration"
mvn archetype:generate -DgroupId=com.yourcompany.engine.api -DartifactId=EngineApi -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
- Maven/Eclipse problem
- Right-click on your project, select Maven -> Remove Maven Nature.
- Open you terminal, go to your project folder and do
mvn eclipse:clean - Right click on your Project and select “Configure -> Convert into Maven Project”
- Create a pom compatible entry to be used as a dependency from a local jar file
mvn install:install-file -DgroupId=org.winterwell -DartifactId=jtwitter -Dversion=2.8.2 -Dfile=/home/lee/tools/JTwitter/jtwitter.jar -Dpackaging=jar -DgeneratePom=true
- if you lost or removed the /target folder
- mvn compile
- or
- mvn package (creates also the package...)
- Lifecycle phases (generate-test-sources, etc)
- Snapshots
- Use a snapshot of another project in your dependencies
- need to do "mvn clean install" on the project we want a snapshot on
- <properties>
- <whatever-configuration.version>1.0-SNAPSHOT</whatever-configuration.version>
- see what snapshots you have in
- ~/.m2/repository/fr/...
- if it doesn't find it on local, it gets it from nexus
Wednesday, March 24, 2010
Tomcat survival kit (Tomcat6)
Ubuntu: /var/lib/tomcat6/conf
W7: C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0
/usr/share/tomcat/bin/catalina.sh
< Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common"/ >
http://localhost:8080/manager/html
default user: "admin / no pw"
Otherwise, you can add
< user name="username" password="secret" roles="standard,manager" / >
in /Tomcat 6.0/conf/tomcat-users.xml
/var/lib/tomcat6/webapps
then you do: http://192.168.0.12:8082/sample/
http://127.0.0.1:8080/getimagelist/http%3A%2F%2F
( %3A works but not %2F). See property
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH: true|false
JAVA_OPTS="-Djava.awt.headless=true -server -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
edit /etc/init.d/tomcat6 and look for JDK_DIRS
sudo -E /etc/init.d/tomcat start
./usr/share/tomcat6/bin/catalina.sh
/var/lib/tomcat6/conf/logging.properties
- ulimit -a
- pipe size (512 bytes, -p) 8
Wednesday, February 17, 2010
Android development
./adb devices
you get:
List of devices attached
???????????? no permissions
What you need to do:
./adb kill-server
sudo ./adb start-server
* daemon not running. starting it now *
* daemon started successfully *
./adb devices
you get:
List of devices attached
HT019P803628 device
Then, if you don't have an emulator running, you can do:
./adb install ../platforms/android-2.1/samples/ApiDemos/bin/apis.apk
To get the debug trace on the host computer:
./adb logcat
Subscribe to:
Posts (Atom)