Ever wanted to launch less or vi from a console Java program to show or edit a file, only to find that they won’t work like when you launch them from the terminal?
Category Archives: Programming
The JVM ate my variable!
Consider this code: Object obj = new Object(); WeakReference<Object> ref = new WeakReference<Object>(obj); List<byte[]> filler = new LinkedList<byte[]>(); while (ref.get() != null) { filler.add(new byte[1000]); } System.out.println(“Filler size ” + filler.size()); When executed it should always run out of memory: ref.get() will not return null because the referenced object cannot be garbage collected. The local …
Grouping data
Suppose you are faced with the task of taking a list of things and grouping them by some attribute, like turning the following list country-city pairs… input=[(“USA”, “New York”), (“USA”, “San Francisco”), (“USA”, “Los Angeles”), (“UK”, “London”), (“UK”, “Manchester”), (“UK”, “Edinborough”), (“Spain”, “Madrid”), (“Spain”, “Barcelona”), (“Spain”, “Granada”), (“Finland”, “Helsinki”), (“Finland”, “Oulu”), (“Finland”, “Kuopio”)] into lists of …
Crazy fast AJAX search suggest in CakePHP
The fastest AJAX call is the one that is never made. Network latency makes using AJAX applications like Google instant search, or even the common autocomplete field, feel like running in treacle*. Having the browser run to the server for more data every time the user pushes a key just doesn’t work well. Many times …
Continue reading “Crazy fast AJAX search suggest in CakePHP”
Tutorial: Role-Based Access Control with CakePHP
In an earlier post I talked about access control with CakePHP‘s AclComponent and how it might be used for the simple-yet-powerful roled-based access control, where users can have multiple roles and permission checks are reduced to verifying if the user has a certain role. In this tutorial we’ll add role based access to the CakeBB sample app. It …
Continue reading “Tutorial: Role-Based Access Control with CakePHP”