Posts

Showing posts from 2011

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"

Linux rfcomm serial communication

Scan to discover Bluetooth device Pair with Bluetooth device Connect with SPP In one shell/terminal - pipe the input from the Bluetooth device to a file      less -f /dev/rfcomm0 then ctrl+F or      tail -f /dev/rfcomm0 or      cat /dev/rfcomm0 > datalog.txt In another shell/terminal - echo some command to the Bluetooth device      echo "8;" > /dev/rfcomm0 Quit the cat command Inspect the output      less datalog.txt

Windows Soft Link

mklink (a windows softlink)

Manifest classpath

Manifest classpath examples

Message Digest

MD5 throughput was ~15 GBytes/minute on a quad core Intel i5 @ 2.67GHz running Ubuntu Linux 10.04 and Java(TM) SE Runtime Environment (build 1.6.0_22-b04) Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode) The throughput was the same whether the digest was computed from bytes on disk or memory. org.apache.commons.codec.digest.DigestUtils org.apache.commons.codec.binary.Hex From file String filename = "src/test/resources/somefile"; is = new FileInputStream(filename); assertEquals("bd6b1dc1ac767b018003572a767d2d0d", DigestUtils.md5Hex(is)); Pipe filter stream is = new DigestInputStream( new BufferedInputStream(new FileInputStream(filename)), MessageDigest.getInstance("MD5")); /* * Implementations using DigestInputStream would not need the byte handling as it would be just one filter in a pipe * that is being pumped for some other purpose. */ final byte[] buf = new byte[2048]; while (dis.read(buf)

JVM thread dump

Java options, which lets you direct thread dumps generated via “kill -3” to a file: -XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log Pretty cool, but there’s one small catch: the thread dumps still get written to the JVM’s TTY as well as the file.

File Locking

File locking example

Interviewing developers

Some developers can't code

Thread dump example

2011-04-12 09:18:25 Full thread dump OpenJDK 64-Bit Server VM (19.0-b09 mixed mode): "Attach Listener" daemon prio=10 tid=0x0000000000b0d000 nid=0x33ef waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "DestroyJavaVM" prio=10 tid=0x00007f3a2408d000 nid=0x3391 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE "File I/O" prio=10 tid=0x00007f3a2408b800 nid=0x33a2 runnable [0x00007f3a3157e000] java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.read(Native Method) at ThreadDumpTest$4.run(ThreadDumpTest.java:97) at java.lang.Thread.run(Thread.java:636) "Blocked" prio=10 tid=0x00007f3a24081000 nid=0x33a1 waiting for monitor entry [0x00007f3a3167f000] java.lang.Thread.State: BLOCKED (on object monitor) at ThreadDumpTest$3.run(ThreadDumpTest.java:74) - waiting to lock <0x00000007d68b4068> (a java.lang.Object) at java.lang.Thread.run(Thread.java:636) "Blocking" pri

Oracle find all constraints

Find all cascade constraints SELECT lc.table_name loc_table, lc.constraint_name loc_cons, ln.column_name loc_col, lc.r_constraint_name rem_cons, rc.table_name rem_table, rn.column_name rem_column, lc.status, lc.delete_rule, lc.deferrable, lc.deferred, lc.validated FROM user_cons_columns ln, user_cons_columns rn, user_constraints lc INNER JOIN user_constraints rc ON lc.r_constraint_name = rc.constraint_name WHERE (rc.table_name IN ('TABLE_NAME') OR lc.table_name IN ('TABLE_NAME')) AND ln.constraint_name = lc.constraint_name AND rn.constraint_name = rc.constraint_name ORDER BY lc.table_name;

Oracle data pump

Export: 1. Ensure that a directory is setup for the data pump in oracle a. Create the directory on the physical system b. Login via SQLPlus as a dba account i. CREATE DIRECTORY <friendly_name> AS ‘/path/to/dump/dir’; ii. commit; iii. GRANT READ, WRITE ON DIRECTORY <friendly_name> to <schema_user> iv. commit; 2. Run the export a. expdp username/password<@SID> DUMPFILE=<output_filename.dmp> LOGFILE=<logfile.log> DIRECTORY=<friendly_name> Import: 1. Ensure that a directory is setup for the data pump in oracle a. Create the directory on the physical system b. Login via SQLPlus as a dba account i. CREATE DIRECTORY <friendly_name> AS ‘/path/to/dump/dir’; ii. commit; iii. GRANT READ, WRITE ON DIRECTORY <friendly_name> to <schema_user> iv. commit; 2. Run the import a. impdp username/password<@SID> DUMPFILE=<input_filename.dmp> LOGFILE=<import_log.log> DIRECTORY=<friendl

DataScienceToolkit

CataScienceToolkit A collection of the best open data sets and open-source tools for data science, wrapped in an easy-to-use REST/JSON API with command line, Python and Javascript interfaces. Available as a self-contained VM or EC2 AMI that you can deploy yourself. It's essentially a specialized Linux distribution, with a lot of useful data software pre-installed and exposing a simple interface. For full documentation, see http://www.datasciencetoolkit.org/developerdocs.

FlyCam

FlyCam

Kinect your internet of things

How the world will interact with things in the future

Universal text editor

Sublime Text  2 Install package management { "font_size": 13, "highlight_modified_tabs": true, "ignored_packages": [ "Vintage" ], "save_on_focus_lost": true, "tab_size": 2, "translate_tabs_to_spaces": true }

Code rewrite

Hacher News post Joel on software