I created a sample app that demonstrates HTML5 Canvas usage from Java through GWT. I think GWT is an excellent tool for migrating desktop apps into Web nowadays, especially for Java developers. So it’s worth giving it a try. Google has made significant progress on migrating desktop apps into Web during the last year. They propagated trend for HTML5 support and Javascript JIT compilers among modern browsers. So it’s possible to run Quake 2 or CAD software directly in browser at decent speed. Red Black Tree is a balanced BST tree. Details are described on Wikipedia. You can run this sample app directly on appspot (it works on iPhone too :-) ) Sample code can be found here: Browse on GitHub. Let’s start from initialization. First, we need to create Canvas element and add it to HTML. getContext2D is called to obtain drawing context. We register a timer to redraw frames frequently: So doUpdate is called every 50 ms and whenever redrawFrame is set to true, it redraws Canvas contents. In autoplay mode, we call processFrame in while loop. So whenever redraw procedure takes too long, we will process frames without redrawing them. This won’t slow down animation on low resources. Then, we need to draw a tree. We use drawTree procedure, which is recursive and draws nodes along with contents and connections between them: The best part is that we can do regular Java unit tests on Red Black tree to verify the correctness of implementation:
You May Also Like
New HTTP Logger Grails plugin
- byTomasz Kalkosiński
- May 7, 2013
I've wrote a new Grails plugin - httplogger. It logs:
- request information (url, headers, cookies, method, body),
- grails dispatch information (controller, action, parameters),
- response information (elapsed time and body).
It is mostly useful for logging your REST traffic. Full HTTP web pages can be huge to log and generally waste your space. I suggest to map all of your REST controllers with the same path in UrlMappings
, e.g. /rest/
and configure this plugin with this path.
Here is some simple output just to give you a taste of it.
17:16:00,331 INFO filters.LogRawRequestInfoFilter - 17:16:00,340 INFO filters.LogRawRequestInfoFilter - 17:16:00,342 INFO filters.LogGrailsUrlsInfoFilter - 17:16:00,731 INFO filters.LogOutputResponseFilter - >> #1 returned 200, took 405 ms.
17:16:00,745 INFO filters.LogOutputResponseFilter - >> #1 responded with '{count:0}'
17:18:55,799 INFO filters.LogRawRequestInfoFilter - 17:18:55,799 INFO filters.LogRawRequestInfoFilter - 17:18:55,800 INFO filters.LogRawRequestInfoFilter - 17:18:55,801 INFO filters.LogOutputResponseFilter - >> #2 returned 404, took 3 ms.
17:18:55,802 INFO filters.LogOutputResponseFilter - >> #2 responded with ''
Official plugin information can be found on Grails plugins website here: http://grails.org/plugins/httplogger or you can browse code on github: TouK/grails-httplogger.
Distributed scans with HBase
- byMarcin Cylke
- December 10, 2013
HBase is by design a columnar store, that is optimized for random reads. You just ask for a row using rowId as an identifier and you get your data instantaneously.
Performing a scan on part or whole table is a completely different thing. First of all, it is sequential. Meaning it is rather slow, because it doesn't use all the RegionServers at the same time. It is implemented that way to realize the contract of Scan command - which has to return results sorted by key.
So, how to do this efficiently?HBase is by design a columnar store, that is optimized for random reads. You just ask for a row using rowId as an identifier and you get your data instantaneously.
Performing a scan on part or whole table is a completely different thing. First of all, it is sequential. Meaning it is rather slow, because it doesn't use all the RegionServers at the same time. It is implemented that way to realize the contract of Scan command - which has to return results sorted by key.
So, how to do this efficiently?
The Future of Programming
- byMichał Trzaskowski
- August 9, 2013
A very interesting presentation: http://vimeo.com/71278954 by Bret Victor presented at Dropbox’s DBX conference on July 9, 2013. My…