PHP sleep2next function

I had a project done for a client, where I needed a code to run again every second, since cron-tabs work every minute I use an inner function to keep the code running.

I did it for them before, I used the simple sleep function, but this code needed a more precise timing, i can’t miss a second of data.

So I came up with a simple function that solves it:

function sleep2next() {
  usleep( intval( ( ( time() + 1 ) - microtime(true) ) * 1000000 ) );

The code calculates the miliseconds until next round second and pauses the code for that period of time,  the further code will now start as soon as possible after the next second.

Notice: on windows platforms it might act somewhat strange.

Chrome Pre-Install cleaning

I stumbled into Google Chrome extensions made by various providers, that viciously use the Pre-Install option in order to stay even when the user uninstalls it, every user will get highly annoyed by this “Feature”.

After getting annoyed myself by one of them (Shameless I looked it up.

Apparently, the pre-install keys exist under this key:


Or here for 64bit operating system


Since I provide technical support for people, I needed a tool to automate the removal action, so I created a REG file to remove this registry key.


Notice: This file cleans up every extension registered to be pre-installed, but it doesn’t remove them.

No free source allowed!!! OK, what else is new?

I guess that by now you already heard, read or any way else got to know about the weird terms Microsoft puts in front of application developers for Windows Phone. if not, read about it at Jan Wildeboer.

Here is the highlight: Microsoft says no to open source licenses or programs based on libraries that are under open source licenses. and they even mentioned GPLv3 as an example.

Well, my first move reading this was to share it with friends and use the old mantra “Microsoft is evil…”, at second thought, they may be, but what exactly are we doing to stop feeding them?

All we do is cry and weep how Microsoft behaves, how they corrupted the regular users with dummy interfaces, and flashy processor eating applications, yeah, they did, so what, they are a business after all, they have to feed their children, right?

So instead of complaining how M$ is trying to push away Open Source, and how Apple is going in their way and vice versa, lets make some better Linux Distributions for Dummies, some greater User Interfaces that people can do things also without a command line, cause using “ls -l” is cool for me, but my dad just wants to read his damn email and some news.

Lets not make it worth for cellphone companies to use Windows as an OS, lets not make it worth for M$ to disallow Open Source applications.

Youtube hates when I frame them

As part of my work on Qliqa, I bumped in to the fact that Facebook blocks embedding itself in HTML frames, instead it provides the Facebook logo and a link to the location you tried reaching.

Today, during a routine check on some updates, I realized that the a link on our test site that points to a Youtube video shows a generic non-same-origin-frame-blocked error with a link to the original address of the iframe. Although blocking framing ruins a lot of my plans, yet I understand their choice, as a webmaster I know that there is more then one reason to block framing your website.

But, here is the thing, Facebook didn’t block framing with a general HTTP header, they provided their own error page, its a clear fail-safe choice, Youtube on the other hand chose to block it by setting a header ordering the browser to block embedding the content if it is not originated from the same domain.

Now, the funny thing is, that for some reason the Webkit engine does not supply a Same-Origin error page, Webkit is used in Safari, Chrome and more, while I’ll know that Facebook is blocking their content, If I would have been using Chrome and trying to access a Youtube link from StumbleUpon, I would never know why the content is blank.

Frame it or not, no UI is not always the best UI…

Facebook Remove-all-apps JavaScript

Lately many of my friends on Facebook found out that applications can indeed be harmful. messages were sent in their name, chats were opened with other friends inviting them to go to a specific link.

The only good deed I could have done is send them back the link to the apps management page and explain them that they need to remove all apps that are not useful.

So after looking around the Facebook interface for a link to fast removing apps, I created this script.

var cid = 0;
var d = document;
var w = window;
function t(item, next) {
if (d.getElementsByName(item)[0] == undefined) {
w.setTimeout("t('" + item + "','" + next + "')", 500);
w.setTimeout(next + "()", 500);
function x() {
var a = d.links[cid];
if (a.className == undefined) {
if (a.className.indexOf('fbSettingsListItemDelete') > -1) {
eval(unescape(a.href.substr(11, (a.href.length - 12))));
t("remove", "ok");
} else {
function ok() {
t("ok", "next");
function next(add) {
if (add != null) cid++;
if (d.links.length) return;

Same code, for address bar use:


This script takes all links on the page and searches for the links that are the ‘X’ where you can remove the application. Then it clicks on the remove and waits until the window to confirm the removal appears, when it does, the ‘Remove’ button is clicked. The same routine as above is done for the window that approves the removal of the application. Then the script goes on to the next application. This script can be ran from the console window, or from the address bar with ‘javascript:’ before the script.