My BLOG on DIY, Hacking and notes

This includes mostly useful information for myself and my BLOG about various free time projects. Which are currently mostly hardware and electronics hacks .

Besides this I'm fully occupied with programming the final parts of MPL, extending my software generation tools such as the precompiler. And finishing my PhD thesis text which is about Creating the integrated programming environment Multi Precision Lab using source code generation tools.

First time visitors, people with comments or questions are welcome to sign my guestbook . Some of my projects in my blog hit the masses like www.hackaday.com featuring binary clock and makezine featuring my Wii-remote hack resulting in 10000 new visitors on the day they appeared in my blog. Cya and have a nice day .

Simple fragment cache and some javascript ninja code for the win!

Written by Walter on 10/09/2013 15:43:00.

Today I decided to optimize one of our most complex pages.
It was long overdue. The view rendering was now taking a whopping 9 seconds and the javascript which dynamically added tri-state selects another +7 seconds or more on a slow pc.



1. Solving the server side view render time :
Basically we have a dynamic permission checker that iterates all controllers and actions and shows an overview for each role. Turns out after some profiling, fetching the actions from routes are not expensive it's rendering +500 checkboxes that screeches our rails app to a halt. Easy 5 min. fix was using a clever fragment cache like so:



<h1>Manage permissions</h1>

<% app_controller_actions, app_controller_paths = Permission.routes_hashes %>
<% permission_cache_key = Digest::MD5.hexdigest( app_controller_actions.to_s+app_controller_paths.to_s ) %>

<%= cache "permissions_#{permission_cache_key}" do %>

... complex view code iterating all controllers and showing the action checkboxes for each login role...

<%end%>



What's nice about this is that it will auto invalidate the cache if the md5 of the set we use to iterate over changes. So if any new controller or action is defined we immediately create a new cached copy. Ow yes and view render time now dropped to 120ms vs the original +9000ms

2. Solving the client side (jquery javascript). We also iterated each row of checkboxes and wanted to minimize/collapse it all (this turns out to not be so slow) what did take time was determining to show a custom label in case some checkboxes we're checked. This was harder to make faster but we could solve it in another way. By (ab)using setInterval we can simulate an asynchronous process. In more modern browsers the issue will solve itself easily with javascript workers. But for now you can use the following ninja scripting:

CODE BEFORE:


$(".select_all").updateTriSelect(); //nice and short alas this hogs the browser and locks it untill all elements are processed


CODE AFTER:


unction batchUpdateTriSelect( inputList ){
var i=0, limit = inputList.size(), busy=false;
var processor = setInterval( function(){
if( !busy ){
busy = true;

//update a single tri-select
if( i < limit ){
element = $(inputList[i]);
updateSelectAll( element.data('controller'), element.data('role') ); //updateTriSelect of single element but unrolled to shave a few milli seconds off...
}

if( ++i == limit ){
clearInterval( processor ); //stop processing, our list is updated.
}
busy = false;
}

}, 1 );
}


The net effect is the browser is responsive straight after the pageload and is processing in the background without disturbing the user experience. woohooo!


Acetone vaping my 3d printed yoda

Written by Walter on 19/07/2013 18:01:42.

Adventures in acetone vaping. My home grown 3d printers are well callibrated and tuned.
The yoda print quality is already really good. But can we make it better?

Printed yoda on WalleBOT v2.1:




Vaping yoda in a 20 dollar rice cooker (add few tea spoons of acetone, pop in your printed part, turn on cooker and wait 2 minutes):



Here's our printed custom Yoda after acetone vaping:





Bling bling

Check out 3Dkits.be shop will be open soon you can have
the same quality 3d printer at an unbeatable price. Kit assembly takes around 8hrs for a beginner...


Facebook RFID sharing at werchter 2013

Written by Walter on 19/07/2013 13:14:37.

This was one of the many RFID crowd projects I made for werchter 2013.
You scanned your wristband and it posted a message on your facebook profile saying which band was playing and where you we're located on the festival terrain:

We had 8 of these points here is a vid in daytime (main stage):



Here is a video at night time (we fitted an rgb light and the second we tested it, loads of people started using it :




This is what it looked like on your facebook wall seconds after your scan:




This is some analytics (I blurred the figures because my employer doesn't want me to share numbers. But rest assured it was the most popular of the rfid projects Three cheers for Zuckerberg):