You need to get out on your whale, into the big scary ocean, and start learning and creating again.
Thursday, May 17, 2012
Cisco VPN client with certificates only
I hope it will also help someone else in the future. It is definitely going to help me when I have to do it again.
Wednesday, May 9, 2012
Disqus - revisit
Right, so it's been a while since we last discussed, Disqus (see what I did there).
Original post: Disqus is pissing me off
And let me save you from any sort of suspense you may have regarding whether my feelings have changed: they have not. That is why my vote is to: drop it. As soon as possible.
As highlighted in that post, there are issues surrounding administering Whaleventures / Disqus while logged into your own, personal Disqus/Google accounts. There are issues where the thing marks innocent comments as spam. It forces the revealing of firstnames and lastnames, and our resident incognito users don't like that. Then you've got the issue where you can't embed links. Oh, don't forget the issue with code formatting. It seems you need to be a Disqus formatting guru to get it to preserve whitespace.
I have exported our comments as of this moment (2012-05-09 19:50), and they provide you with a nice XML file. The content of the XML file looks straightforward enough. If we get consensus, I will figure out a way to re-import our old comments back into whatever new system we choose, even if I have to generate each of you your own customized python script or whatever with your comments in it.
So, who's with me? Are we gonna drop Disqus?
Tuesday, May 8, 2012
Code weirdness
<boolean-expression> ? <statement> : <statement>;
See if you can spot it. The idea is as follows. If the number is a round number (i.e. 4.0 or 8.0) then the number should be displayed without the trailing .0. However, if it is not, the fractional part should display. Here's the test class containing three tests... Which test(s) fails and why?
Friday, May 4, 2012
Find the bug - part 3 (Windows edition)
I have come across a strangeness with Java on Windows with regards to file handling, i.e. the following code:
The code works fine on Linux, but on Windows it complains that the "from" file cannot be deleted, when the file is supposed to be moved using the Google Guava Files.move(File from, File to) method. There is a very subtle thing one has to do to get it to work on Windows. What is it?
Post your answers in the comments and then I will let you know after a while :)
Monday, April 23, 2012
A "Guicier" Apache XML-RPC
- The examples were too trivial to extend to real applications.
- The more complicated examples were doing really horrid things. (Like a singleton class that keeps the injector available for lazy and even not-so-lazy instantiations. Sorry, but why is this better? That's like taking an orange-overall crook, dressing him in a suit and calling him an honest politician. Uhh... wait... that's not what I mean...)
- Guice does not lend itself well to already badly written code, hence the difficulty to find examples that deals with those situations.
- You have one injector and one injector only. Inject once and throw it away. The only exception I make to this is a cool trick in anonymous inner classes (more on this, later).
- Keep the modules few, and put them in the same package as the program entry point. It is after-all the place where the module is used.
- Do not go too far. You can easily over-guice and this DOES make matters worse.
- Do not force Guice down the throat the people that will make use of your code (i.e. if you are writing a library). There is enough of that in the computer world.
Regardless, in order to get this working another injector needs to be passed to the servlet, violating my first rule. However... I found a workaround. I'll let the code speak for itself. Here goes:
First the main class where everything gets wired up. Simple and self-explanatory:
Secondly, the servlet. This merely redirects traffic to the handler and sets the factory. Note the injection. Also note the absense of an injector:
Thirdly the handler with some test injection (demonstrating that we can inject anything we want). It merely echoes the request:
...and lastly, the module. The magic happens in the getRequestProcessorFactoryFactory provider. Have you ever had the need to write an anonymous local inner class within yet another anonymous local inner class? Well, now you do. I call it the Russion-doll pattern (anti-pattern?) Guice has access to the injector so you can merely inject it here as well:
So, the order of creation. The main class gets an instance of the SimpleServer, which needs an instance of a ServletContextHandler, which needs a RequestProcessorFactoryFactory which needs an injector to inject an instance of a new handler. Basically boils down to lazy instantiation which is set up in the module.
Wednesday, April 18, 2012
Doto
Nothing wrong with it, but wouldn't it be nice to be able to chain those calls and avoid declaring that local variable?
(doto (new java.util.HashMap) ; or just (java.util.HashMap.)
(.put 1 "One")
(.put 2 "Two"))
new HashMap<Integer, String>(){{
put(1, "one");
put(2, "Two");
}};
I would love to see some alternate solutions/improvements or maybe event implementations in other languages!
Friday, April 13, 2012
These Steps
- A hierarchy of steps, with current edge steps ordered, unordered, tabs and options with leaf steps youtube, image, code.
- Sharing of steps via a link or to another registered user.
- Exporting to PDF.
- Reference steps from other areas in the hierarchy.
- Editing: copy, cut and paste steps (nodes).
- Keyboard shortcuts for navigation and editing.
- Exporting to Json.
- Websockets for real time collaboration.
- Cucumber support, such that steps are confined to the structure of a cucumber file, this would be awesome for collaboration between the developers and clients.
- Gist support, such that a leaf step can reference a gist.