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
http://swiss-knife.blogspot.fr/search?q=ubuntu
to see all posts, or backup blogger blogs:
http://swiss-knife.blogspot.fr/search?max-results=1000&start=0


  • 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;" >
    .
  • Saturday, April 17, 2010

    maven

  • 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
  • To create an exe from Eclipse
  • Maven System Properties
      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 
      1. from the command line:
      2.  mvn archetype:generate -DgroupId=com.yourcompany.engine.api -DartifactId=EngineApi -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
        1. cd EngineApi
        2. mvn install
        3. mvn eclipse:eclipse
        4. Import the project into Eclipse as a maven project
        5. Right click on the Eclipse project: "Maven / Enable Dependencies Management" then "Maven / Update Project Configuration"
      • Maven/Eclipse problem
        1. Right-click on your project, select Maven -> Remove Maven Nature.
        2. Open you terminal, go to your project folder and do mvn eclipse:clean
        3. 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)


    1. Servlet container, no EJB support

    2. /conf
      Ubuntu: /var/lib/tomcat6/conf
      W7: C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0
      /usr/share/tomcat/bin/catalina.sh

    3. To see access log on your Tomcat, add the following to your conf/server.xml :

      &lt Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common"/ &gt

    4. to administer the modules
      http://localhost:8080/manager/html
      default user: "admin / no pw"
      Otherwise, you can add
      &lt user name="username" password="secret" roles="standard,manager" / &gt
      in /Tomcat 6.0/conf/tomcat-users.xml

    5. default location for war files
      /var/lib/tomcat6/webapps
      then you do: http://192.168.0.12:8082/sample/

    6. for security reasons, slashes cannot be url encoded, like:
      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

    7. for memory setting like

      JAVA_OPTS="-Djava.awt.headless=true -server -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"

    8. to make sure you don't use openJDK
      edit /etc/init.d/tomcat6 and look for JDK_DIRS

    9. if JAVA_HOME is not found when doing sudo /etc/init.d/tomcat start, do:
      sudo -E /etc/init.d/tomcat start

    10. other things:
      ./usr/share/tomcat6/bin/catalina.sh
      /var/lib/tomcat6/conf/logging.properties
    11. "too many open files" in catalina
      • ulimit -a
        • pipe size (512 bytes, -p) 8
      .
    12. Wednesday, February 17, 2010

      Android development

    13. when you plug in a nexus and you do
      ./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
    14. Friday, January 8, 2010

      Tesseract

      To use Tesseract, you need an uncompress Tiff file. To do that:

      C:\tools\ImageMagick-6.5.8\VisualMagick\bin\convert.exe c:\tmp4\toto.jpg c:\tmp4\toto.tif
      C:\tools\Tesseract>tiffcp -c none c:\tmp4\toto.tif c:\tmp4\unc_toto.tiff
      C:\tools\Tesseract>tesseract c:\tmp4\unc_toto.tif out

      Go and read the OCR result in out.txt

      Saturday, December 26, 2009

      ImageMagick

      • Windows7 / VisualStudio 2008 , To build it, get:
      • ftp://ftp.imagemagick.org/pub/ImageMagick/windows/ImageMagick-windows.zip unzip
        When you open, build, and run: VisualMagick/configure/configure.sln
        you get: VisualMagick/VisualStaticMT.sln
        Now you can build ImageMagick.
        To build a release of an exe using ImageMagick, I ran into VisualStudio libraries conflicts using STATIC_MAGICK. I built the "dynamic" ImageMagick using configure, and then I could have it to work fairly easily.
      • To convert pictures using the command line:
        C:\tools\ImageMagick-6.5.8\VisualMagick\bin>convert "C:\Users\x\Downloads\2010-05-16 16.05.43.jpg" -resize 10% toto.jpg
      • Ubuntu
      • $tar xvfz ImageMagick.tar.gz
        $ cd ImageMagick-6.6.3-1
        $ ./configure
        $ make
        $ sudo make install
        ImageMagick-6.7.8-8/utilities/convert DSC_6093.JPG   -resize 40%   out2.jpg

      Monday, December 7, 2009

      Axis2 Web Service (Tomcat v6)

      These are informations that complements
      http://people.apache.org/~ruchithf/hw-axis2/
      http://www.roseindia.net/webservices/axis2/axis2-client.shtml

    15. Install Tomcat6/Axis2 1.5.1 (Axis2 servlet)
      Tomcat configuration on Windows:
      C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\conf\server.xml
    16. Install eclipse-jee-galileo-SR1-win32.zip (version 3.5)
      (to be able to build "Dynamic Web Project")
    17. install "Service Archive Wizard - Eclipse Plug-in" (aar generation). You can get it from the axis2 page: download/tools

    18. Do File/New/"Dynamic Web Project"
      (Target Runtime: "Apache Tomcat v6.0")
    19. New Package
    20. New ws Class
    21. Create a file services.xml in WebContent/META-INF (that is what will be exposed as service features).
    22. Create the aar file:
      File/New/Others/AxisServerArchiver
      - "Class File Location": C:\EclipseWorkSpace\MyWs\build\classes\
      - do "not include .class only"
      - Next
      - Skip WSDL
      - Next
      - Next
      - Set the service XML file: "c:\eclipseworkspace\myws\webcontent\meta-inf\services.xml"
      - Next
      - "Ouput file location": C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis2\WEB-INF\services
      - WARNING: on Windows 7, eventhough I enter this path, the aar file ends up in
      C:\Users\lefla\AppData\Local\VirtualStore
      not sure why, must be a privilege problem. I have to copy the aar file in the correct folder afterwards.

      Restart Tomcat

      if you did:

      public String echo(String value) {
      return "Hello : " + value;
      }

      You should see the wsdl generated when click on your service from:
      http://127.0.0.1:8082/axis2/services/listServices
      (need to "view source" on the blank page on Chrome browser)

      and also you should see the echo response (with "null" as parameter)
      < ns:echoResponse >
      < ns:return > Hello : null < /ns:return >
      < /ns:echoResponse >
      http://127.0.0.1:8080/axis2/services/myws/echo

    23. If you want a Java client for the Axis WS:
      The following command creates the two stubs java files for the client:
      (if you use the -t option, it also generates the client java test source code)
      C:\tmp>wsdl2java -uri http://127.0.0.1:8080/axis2/services/myws?wsdl -o client

    24. If you want to use a JSP to connect to the WS
      You can create a new "Dynamic Web Project"
      Reuse the same stub files as in the Java client above in your project
      I had to add httpcore-4.0.jar and berkeleydb-1.5.0.jar (sleepycat collections classes) to the project WebContent/WEB-INF/lib.
      Put your .jsp files in WebContent
      Once done, you can right-click "Export" as a WAR file and put it in
      C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps\MyJspProject.war
      You have to remove the folder MyJspProject in
      C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps
      before restarting Tomcat.
      Look at
      C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\logs\localhost.20xx-xx-xx.log to debug

    25. Please note the typo in the ruchithf apache tutorial. According to the original echo(String value) command, the associated client instruction should be:
      request.setValue("Hello world");
      and not:
      request.setParam0("Hello world");
    26.