Posts

Remote JMX client

Java 6 JMX Code Example Add these properties to the target VM to specify the jmx port and allow remote connections so you can get to it from other systems without the need for authentication. JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=9999" JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false" JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false" The example below demonstrates the following: Connection Listing all MBeans Listing all MBean attributes, types, and mutability Listing all MBean operations, parameters, and return types Getting an attributes current value Setting an attributes value Invoking operations import java.io.IOException; import java.util.Iterator; import java.util.Set; import javax.management.Attribute; import javax.management.AttributeNotFoundException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.InvalidAttributeVal...

Batteries

CR14505

I2C addressing

what-i2c-address-should-i-choose usb_i2c_tech

HOWTO install Flashplayer 11 on Firefox 8 on Ubuntu 10.04 64bit LTS

Download Flashplayer here Copy libflashplayer.so to /usr/lib/firefox-8.0/plugins Create symbolic link: sudo ln -s /usr/lib/firefox-8.0/plugins/libflashplayer.so /usr/lib/firefox-addons Restart Firefox

Curl Rest Examples:

GET curl -X GET -H "Content-Type:application/xml" "http://localhost:8080/some/path/505?username=foo&password=bar" Create curl -X PUT -H "Accept: *" -d @someFile.xml "http://localhost:8080/some/path?username=foo&password=bar" Create or Update curl -X POST -H "Content-Type:application/xml" -d @someFile.xml "http://localhost:8080/some/path/save?username=foo&password=bar" Delete curl -X DELETE -H 'Content-Type:application/xml' -d @someFile.xml "http://localhost:8080/some/path?username=foo&password=bar" Upload file curl -X PUT -H 'Content-Type:multipart/form-data' -F "someFile.csv=@someFile.csv;type=text/csv" "http://localhost:8080/some/path/505?username=foo&password=bar" --verbose Download file curl -H "Accept: *" "http://localhost:8080/some/path/506?username=foo&password=bar" --O "foo.bar" --verbose PUT data...

Maven

mvn -version Create html dependency report: mvn versions:display-dependency-updates mvn dependency:tree mvn project-inf-reports:dependencies Create project: mvn archetype:generate -DgroupId=com.foo.someproject -DartifactId=some-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false Create eclipse project: mvn eclipse:clean eclipse:eclipse Run jetty from maven: mvn jetty:run Create packge: mvn package mvn -U clean package -DskipTests Compile test: mvn clean compile test Generate Javadoc: mvn javadoc:javadoc see here for howto create and embed UML in javadoc automatically sudo apt-get install graphviz <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9</version> <configuration> <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet> <docletArtifact> <groupId>org.umlgraph</groupId> ...

Hibernate criteria aliases

If you create an alias, then create a criteria and join to another table, etc., it is only going to resolve {alias} to the root table that the alias was created for. hibernateCriteria.createCriteria("orderItems", "i", Criteria.LEFT_JOIN ).add( Restrictions.or(Restrictions.sqlRestriction("orderNo=?", orderNo, Hibernate.Long), Restrictions.sqlRestriction("{alias}.item_id in (SELECT item_id FROM items WHERE item_id = ?)", itemId, Hibernate.LONG) ) ); Lessons Learnt Blog: Criteria c = session.createCriteria(BaseTable.class, "base"); Criteria secondCriteria = c.createCriteria("secondTable","second", CriteriaSpecification.LEFT_JOIN); secondCriteria.add(Restrictions.sqlRestriction("{alias}.id = someCoolCondition"); From the Hibernate docs: List cats = sess.createCriteria(Cat.class) .createAlias("kittens", "kt") .createAlias("mate", "mt"...