Cacomania: Articles


Develop a Firefox add-on using GhostText as example

Guido Krömer - 1496 days ago - Tags: , ,

During the last months it might seem that my blog is dead, but it is not. I spend my most open source time developing GhostText. I already mentioned it here SublimeTextArea, which was the old name this project. But Federico and I decided renaming the project since it does not have to be restricted to Sublime Text. If you have no idea what GhostText is I recommend this video which show the the Chrome extension version.

read more

Comment [1]

Kill all long running MongoDB queries at once

Guido Krömer - 1575 days ago - Tags: ,

If of some very running queries killing your MongoDB server you should try to execute the following piece of code in the shell. It kills all long running queries at once. You can define the maximum execution time by using the first parameter, which is set to 120 seconds by default.

(function (sec) {db.currentOp()['inprog'].forEach(function (query) { 
    if (query.op !== 'query') { return; } 
    if (query.secs_running < sec) { return; }  

    print(['Killing query:', query.opid, 
           'which was running:', query.secs_running, 'sec.'].join(' '));
})})(120 /*The maximum execution time!*/);

This is the output generated by my little emergency helper:

Killing query: 598841625  which was running: 1892 sec.
Killing query: 598818776 which was running: 1931 sec.
Killing query: 598771338 which was running: 2048 sec.
Killing query: 577527534 which was running: 73569 sec.
Killing query: 577589300 which was running: 73404 sec.
Killing query: 577540188 which was running: 73535 sec.
Killing query: 598254342 which was running: 3114 sec.
Killing query: 597396058 which was running: 4811 sec.
Killing query: 597609629 which was running: 4382 sec.
Killing query: 597403975 which was running: 4801 sec.
Killing query: 597423364 which was running: 4766 sec.
Killing query: 597389768 which was running: 4842 sec.

I hope my little posting helped you, please let me know if you liked or disliked it.

Comment [1]


Guido Krömer - 1665 days ago - Tags: , ,

Recently I wrote about "Get rid of those textarea with Chrome and Sublime Text 3" a Chrome extension which connects a HTML textarea through a WebSocket with a Sublime Text 3 plugin, for live editing the textarea's content in a decent editor.

After a request on GitHub, I finally released my SublimeText 3 plugin at Package Control and created a packed Chrome extension for easily installing at Chrome/Chromium.

So check it out if the browser textarea bothers you, too. Fell free to leave a comment here if you like or dislike my little extension.

Comment [2]

Get rid of those textarea with Chrome and Sublime Text 3

Guido Krömer - 1741 days ago - Tags: , , , ,

My recent project is a proof of concept connecting a HTML textarea with Sublime Text 3 using WebSockets, which lets you use all nice features of Sublime Text in a common textarea. Therefore I wrote a Chrome extension and a Sublime Text 3 plugin, the Sublime Text plugin starts a simple, single threaded, WebSocket Server awaiting a connection from the Chrome extension for sending and receiving the text when it has been changed.

I made a short video of this concept, which can be watched at YouTube.

read more

Comment [6]

Test your RESTful API with Frisby

Guido Krömer - 1753 days ago - Tags: ,

Writing a RESTful API is easy, but ensuring that small changes/fixes to the API does not break compatibility with existing clients consuming the API is not easy.

Not easy without functional tests, with the usage of a framework specified in REST API testing like Frisby even the tests are written easily. Frisby is build on top of Jasmine a node.js based BDD framework.

read more

Comment [7]

A simple AngularJS client side pagination module

Guido Krömer - 2026 days ago - Tags: ,

After my last tutorial, I wanted to do some more complex with AngularJS and solve my news feed problem in a similar way I solved my bookmark chaos. During this, I ran into the problem that displaying large lists, containing hundred of entries, can slow down the app significant using ng-repeat. On slow browsers like the Firefox or Opera the application hangs for some seconds during rendering the list of feed items. Since the JSON encoded and GZIP compressed list with 1.000 feed items for example is transferred quite fast, I did not want to do the pagination on the server side instead of this I wanted to paginate the list on the client. Doing the pagination on the client has the benefit that other filters could be used at the same time, too.

Client side pagination with AngularJS

read more

Comment [37]

A simple RESTful AngularJS bookmark app

Guido Krömer - 2052 days ago - Tags: , ,

Welcome to the second part of my AngularJS tutorial, you can read the first part here which covers a RESTful API build with the Slim PHP micro framework. AngularJS is a JavaScript framework for building single page applications in a MVC style. Unlike the traditionally way with jQuery you do not have to add event listeners on CSS classes and select HTML elements by querying them.

AngularJS Bookmark App, list view.

read more

Comment [6]

RESTful API with Slim PHP and SQLite

Guido Krömer - 2060 days ago - Tags: , , ,

I needed a small RESTful API, primarily for playing around with AngularJS. The Slim Framework perfectly fits my needs. It is a PHP micro framework for writing a prototype or really small applications, without the overhead and the steep learning curve of a complete framework likes Yii, Symfony or Zend. At the same time, you get stuck at the Zend2 module configuration, you could have finished a working prototype with Slim.

I used SQLite as database for the API, because SQLite is configuration free it is perfect for prototyping. For keeping the focus, of this tutorial, at the Slim Framework itself, I skipped using any kind of ORM framework. Due the use of PDO any other SQL Database like MySQL could be used, too.

To gain some practical benefit from this tutorial the REST API going to be discussed in this tutorial manages bookmarks in a CRUD style. I hope this help me with my bookmark chaos among Linux, Windows, tablet and smart phone.

read more

Comment [21]

Canvas Raycaster

Guido Krömer - 2182 days ago - Tags: , ,

When I was young I loved Games like Wolfenstein 3D, Nitemare 3D, Corridor 7: Alien Invasion and of course Doom or Duke Nukem 3D. Since Doom and Duke Nukem 3D using complex raycaster engines with a BSP for storing the map and evaluating which parts has to be drawn I'm going to try a Wolfenstein 3D like raycaster, which is very simple and can be implemented very easy in JavaScript using the canvas element for drawing. Raycaster with default settings on Opera

read more

Comment [4]

Speeding up canvas drawing by scaling it with CSS3

Guido Krömer - 2200 days ago - Tags: , ,

Playing around with HTML5 Canvas is a lot of fun, but drawing is really slow and reminds me on GDI+ or Java 2D. The larger the resolution of the drawing canvas is the worse the performance becomes. Doing a little game using the whole browser given size on a Full HD monitor can even slow down on Chromium with a relatively fast CPU (AMD A8-3870). My idea was drawing the canvas in a smaller resolution, the half of the available for example, and scale it up. This is the same way a game console like XBOX 360 and PS3 rendering Full HD or even HD Ready which sometimes is not HD Ready indeed. Scaling elements can be done using CSS3 transform.

Read more if you wants to know about the performance impact by scaling a canvas up instead rendering on a larger one:
Canvas scaled rendering performance on Firefox, Opera and Chromium

read more


Mono, WebClient and "Invalid certificate received from server."

Guido Krömer - 2203 days ago - Tags: , ,

Playing around with MVC on Mono and the Facebook API Login for Server-side Apps the System.Net.WebClient threw a TslException with the message: "Invalid certificate received from server. Error code: 0xffffffff800b010a". Invalid certificate received from server.

After that, I experimented importing all general certificates using mozroots.

$ mozroots --import --ask-remove

But the error still occurred so that importing the needed certificates directly by defining the URL using the certmgr solved the problem.

$ certmgr -ssl


Node.js Chat client with jQuery Mobile

Guido Krömer - 2214 days ago - Tags: , ,

Welcome to the last part of my node.js chat tutorial, the topic of this part is the jQuery Mobile based client. The decision choosing jQuery Mobile has the two reasons, the UI I created for "WebSockets chat with Node.js " was really ugly because I'm not a designer, so I decided taking something which looks well out of the box. The second reasons was that jQuery Mobile seems to be well tested on different browsers even if they are not WebKit based. If you have not read the server side tutorial you maybe should read it before.

The jQuery Mobile chat client
This screen shots show how the chat client will look.

read more

Comment [4]

Serving static files with Node.js

Guido Krömer - 2232 days ago - Tags: ,

Node.js isn't built for serving static files, but during testing and development it's quite handy doing this without configuring an apache or whatever http server. No configuration file is needed just two lines of JavaScript to get this server running.

var MiniHttp = require('./MiniHttp.js').MiniHttp;
var server = new MiniHttp('/tmp/', 8000, null, 'foo.html');
read more


Turn your Linux system into a sandbox with KVM

Guido Krömer - 2321 days ago - Tags: , , , ,

Using a sandbox system is in many cases really handy, but a sandbox that is a snapshot of your "main" system is a little bit more handy. For example, if you want to test how a system update will perform, especially if you are using Arch or Gentoo Linux, on your main system or just for testing new software without messing up or destroying your system.

sandbox running as kvm

This a screenshot of my Thnkpad T61 running Xubuntu 12.04 with a running sandbox vm.

read more


Updating DynDNS via Bash

Guido Krömer - 2327 days ago - Tags: , , ,

Because of my old wireless router was not able to update DynDNS, I spend a lot annoying time configuring the ddclient daemon on my home server. But the stability of this tool was really disappointing, after being blocked two times by dyndns, I decided writing my own script to update DynDNS frequently.

read more

Comment [5]