Skip to main content

How to prevent Windows from waking up by itself after entering sleep mode

Standby, also known as sleep mode, is one of the most useful features of the latest windows builds: when properly used it allows any user not only to save a tremendous amount of power, but also to extend the expected life of your hardware by many years: that is, of  course, assuming it works, which happens to not always be the case.

There is a rather common issue, experienced by many users, when the PC keeps waking up right after it’s put into sleep mode. It usually occurs after few minutes, but it can also be a matter of seconds… or hours. Whichever the timeframe is, this obonoxious issue makes the whole feature completely useless. Having experienced this scenario ourselves, we wrote this post hoping to help anyone facing it to fix their system so that they can sleep safe and sound – without wasting power and hardware. Let’s see how we can do that.

Read More

PHP lock and thread-synchronization using WinCache and/or APC

Raise your hand if you’re a PHP developer and felt at least once the urge to prevent simultaneous access to a property, function or class method from multiple threads/processes. If you do, you’re in good company, as it is a very common requirement for any maintenance-like script or task. For example, when you want to trigger the execution to a certain DB query during the first user access on each day, without relying to a dedicated cron job.

Truth being told, if you’re stumbled upon this post chances are that you are looking for something like that – a fast and affordable way to implement some thread-synchronization features in your application code, something like what we can achieve in some other programming languages such as C# using locks:

The above code gets straight to the point: we got an object who acts as lock, preventing all threads from going further until it gets released – which happens only when the first-entered thread completes the execution of that very same code block.

Such behaviour is not natively supported by PHP and its process-isolated architecture: a common workaround among developers is to resolve using flock(), which is a IO lock technique based upon the filesystem. While being a rather viable approach, it has at least two major issues: sub-optimal performances and the mandatory use of path, which can easily bring permissions/authorization issues.

Luckily enough there are easier ways to achieve the same results, assuming that the PHP distribution installed on your machine/host a user-caching extensions supporting some key features. The most common ones are:

Either one has its own method to acquire the lock status for the active process/thread: let’s see what it is and how we can implement it in our code.

Notice that OPCache, which is the most used choice for either Windows and Linux, isn’t being included in our list: that’s because – at least for now – the great opcache extension by Zend does not support any user cache we can use to achieve a viable lock. Meaning that, if you’re using OPCache and want to achieve this kind of lock, you’ll also need to install WinCache (in user-cache only mode) or APC and follow the methods explained below.

Read More

Volume Shadow Copy Service Error: Unexpected error querying for the IVssWriterCallback interface – how to fix that

If you’ve setup some native or third-party backup procedures on your system (in our case we had Cobian Backup) it might happen to stumble upon the following error message in the Event Viewer log:

The issue, as the error says, is most likely related to the lack of permissions of the Volume Shadow Copy service.

Solution 1: Registry settings

The first thing you should try in order to solve the issue is to add the appropriate permissions for the account executing the service: you can do that my altering the registry settings of the affected machine. Here are the required steps to do that:

Read More

dir2json – a PHP CLI script to output the contents of a folder tree into a JSON object

When you’re working with Javascript frameworks such as or CraftyJS you often need to retrieve a set of resources – such as images, videos, sounds & more – from your project asset folders and load/preload them into your code. It’s easy when you already know the URL, but it can be tricky if you need to rely to your assets folder tree only, because… well, because Javascript simply isn’t allowed do that: as a matter of fact, for security reasons, it cannot issue IO calls at all. The only thing it could do would be to load a structured index of sort – possibly built using a standard, readable format – which can be used to “browse” in order to retrieve the needed contents.

That’s when dir2json comes to help.

Read More