Integrate Facebook event and Google Calendar

Hi folks

I am using Google Calendar to track what I am doing and about to do to avoid collisions.

It is pretty annoying to synchronize facebook events with Google Calendar manually but there is a way to automate that

However the built-in way is far away from being perfect. Normally you would like to track in your calendar only events you’ve marked as ‘Going’ and don’t track ‘Maybe’ events.

Here is the magic site comes to help
It generates webcal url from your Facebook events which you can later on add as a custom calendar into your Google Calendar.

That’s very handy

Here how it looks like in my Google Calendar UI


Stay tuned

Posted in Uncategorized | Leave a comment

Download Google Drive file via AJAX ignoring CORS

Hi folks

I have a csv file in Google Drive which I wanted to use from my JavaScript site.

If you copy share link from Google Drive you’ll get something like

Which is interactive url. So we need to get a download link

It can be done via

And then we get a link

But when you try to get it via AJAX

var xhr = new XMLHttpRequest();'GET', '');
Failed to load Redirect from '' to '*/1_cG2NrtGfuHv_aQGOHWOAZx7wapBlEah?e=download' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://my-server-url' is therefore not allowed access.

Not good. I spent a lot of time and finally found

Prepend this magic url with my url and the problem solved

...'GET', '');


Stay tuned

Posted in Uncategorized | Leave a comment

HFS – Send large file P2P

Hi folks

Sometimes I need to send a large file to someone. There are many services but all of them have some limitations such as file limit
Normally you just want to send your stuff to one person, so using any cloud-based services would be an unnecessary overkill.

So we are looking for a free P2P service supporting files of any size.

1. uTorrent Remote – FAIL!

In the past that was the easiest solution. Just drag&drop your file into uTorrent. It will create a private tracker and gives you an url you can share with your coworker and he downloads your stuff via torrents.

This stuff seems to be broken now. It keeps saying that your computer is turned off, which is not true.
The shared link leads you to… but most of the links on that page are broken. Magnet link is working but still the download is not starting.
I tried advanced settings such as bt.enable_tracker but it made no difference.

Result – FAIL!

2. JustBeamIt – FAIL!

This is the only free P2P service with unlimited file size support I could find. I used it in the past and it used to be very helpful.
But now I tried to send my 14Gb file and it broke two times.

Result – FAIL!


I installed the tool, showed which file I would like it to share for me.

Then I found an open port checking with

Then I gave a direct link and my coworker could download my big file!

HFS supports download resumes in case of failures. So I think this approach is the way to go!

Result – SUCCESS!


Posted in Uncategorized | Leave a comment

My new favorite SQL toy – ApexSQL Refactor

Hi folks

A while ago I’ve had a blogpost about how I suffer working with unformatted SQLs.

Sometimes ago I found the tool the suits me the most – ApexSQL Refactor . It has a lot of settings, much more than all competitors I’ve tried before. I’ve managed to configure it to produce results that annoy me as little as possible. My settings can be downloaded and imported. It still has some shortcomings and hopefully they will add more features in future versions.

There are a few gotchas here though. On my current project I have to use SQL Server 2008 R2 and I kept installing this exactly version just to ensure we’re not using features from neweer versions. Actually we a lucky, as before we had to support SQL Server 2005 which had even more limitations.

But recently ApexSQL Refactor dropped support for the SQL Server Mangement Studio older than 2012, and I was not able to download the latest version that still supports SSMS 2008. I’ve written to the tech support team and they were kind enough to send me the link for the version that works with SSMS 2008

Recently I’ve scripted and reformatted every single object from the database. Then we discovered some strange behavior in the system we are working on. After some investigation I found that actually the formatter caused it! Reformatter broke the logic.

So the problem is the following

Let’s reformat the following script

If you do that you’ll see that

IF (@@ROWCOUNT = 0) -- Username not found

SELECT p.PageSettings FROM dbo.aspnet_PersonalizationPerUser p WHERE p.PathId = @PathId AND p.UserId = @UserId

is formatted as

IF (@@ROWCOUNT = 0) -- Username not found
    RETURN SELECT p.PageSettings FROM dbo.aspnet_PersonalizationPerUser p WHERE p.PathId = @PathId AND p.UserId = @UserId;

So SELECT moved from outside IF block inside it, which actually causes the problem.

But the code itself is very easy to fix, just move SELECTs out of IFs. It won’t break it again on the next reformatting because of the BEGIN/END blocks.

I’ve already written an email tech support team and they said they will reply to me shortly.

But even with this bug, I am in love with the tool!

Stay tuned!

Posted in Uncategorized | Leave a comment

Nightmare on Skype street, or Skype on old computer

Hi folks

We often install Skype on our relatives’ computers and educate them how to call us and respond to our calls.

One of my 80 years old relative had Skype configured and it suddenly stopped to work a while ago.

The PC is 15 years old and has Windows XP on it.

If only I had TeamViewer running there, I might look at the problem, but it is extremely difficult to explain someone 80 years old how to run TeamViewer by phone even if its shortcut is on the desktop already. I regret I didn’t configure unattended mode in TeamViewer before…

Once I get someone to run TeamViewer for me, I started working on that issue.

1. I installed latest version of Skype 7.22 but it fails on startup with Runtime error 216, which I could not fix.
2. Then I decided to install some older version and found Skype 6.11. Installed and ran successfully but could not login. After a while I found that Microsoft deprecated Skype versions below 6.14
3. Then I found another Skype version 6.21, and could login successfully. But I could not make video calls, Skype was saying that my CPU does not have SSE2 feature and they don’t support video calls on such CPUs anymore.
4. The same issue with Skype 6.14
5. I found some link, where some special version for SSE CPUs used to live. But the installer seemed to be the same as on step 1
6. Then I gave up and decided to install something else. I tried Jitsi but it fails on run. ooVoo and VSee fails on installer run with Runtime error 005.

Here I stuck. I couldn’t find anything for a good Skype replacement. It appeared to be a pretty difficult task. A wasted a lot of time and didn’t make any progress. Such a shame!

7. Eventually I found a special hacked version of Skype 4.2 which works everywhere,

This version worked including video calls!!! Hurrah!!

Finally! Microsoft, why did you do that to me?! Why are you dropping support for old versions?! Do you realize that many of us have old relatives that cannot just go and buy new computers whenever you decide to drop support for old computers? Why can’t you check the requirements during installation? Why can’t you keep some version which would work on old computers?

Jitsi, ooVoo, VSee guys, if you state that you support Windows XP, do you bother to ensure they really work?!


Stay tuned

Posted in Uncategorized | Tagged , | 3 Comments

JavaScript propertyChanging, propertyChanged, propertyGetting events

Hi folks

A while ago I described how to debug native DOM element changes.

I needed to use it more often and that became too annoying to write all that boilerplate code over and over.

I decided to implement an event-driven helper. For setter I create propertyChanging, propertyChanged and propertyGetting events. You can just subscribe to an appropriate one and put any conditional logic in the event handler. This should be much neater than the previous approach.

This helper must work in all modern browsers and IE9+

function injectPropertyEvents(element, propertyName) {
    if (!(propertyName in element))
        throw new Error("Element does not have property " + propertyName);

    var propertyHolder = element;
    var descriptor;
    while (propertyHolder !== null) {
        descriptor = Object.getOwnPropertyDescriptor(propertyHolder, propertyName);
        if (descriptor)
        propertyHolder = Object.getPrototypeOf(propertyHolder);

    if (!descriptor)
        throw new Error("Could not find property desciptor " + propertyName);

    if (propertyHolder.propertyEventsInjected)

    function raiseEvent(element, eventName, eventDetails) {
        var event;
        var bubbles = true;
        var cancelable = false;
        try {
            event = new CustomEvent(eventName, {
                bubbles: bubbles,
                cancelable: cancelable,
                detail: eventDetails
        } catch (e) {
            event = document.createEvent("CustomEvent");
            event.initCustomEvent(eventName, bubbles, cancelable, eventDetails);

    Object.defineProperty(propertyHolder, propertyName, {
        configurable: true,
        get: function get() {
            var eventDetails = {
            raiseEvent(this, propertyName + "Getting", eventDetails);
            return eventDetails.value;
        set: function set(value) {
            var eventDetails = {
                newValue: value
            raiseEvent(this, propertyName + "Changing", eventDetails);
  , eventDetails.newValue);
            raiseEvent(this, propertyName + "Changed", eventDetails);

    propertyHolder.propertyEventsInjected = true;

Besides being able to set breakpoints, this approach allows you many nice tricks. You can, for example, override the newValue event argument within propertyChanging event

document.getElementById("myTextBox").addEventListener("valueChanging", function valueChangingHandler(e) {
    if (e.detail.newValue === "something bad")
        e.detail.newValue = "making it better";

You can play with the examples in

Stay tuned

UPD: With slight modifications and polyfills, added support for IE8:

UPD2: I modified bubbles to true as I found it much more useful to real usage purposes, especially for writing an event handler for elements that not exist yet.

$(document).on("valueChanged", "input", function valueChangedHandler(e) {
    var newValue = e.originalEvent.detail.newValue;
    // ...
Posted in Uncategorized | Tagged | Leave a comment

WTF! MicrosoftAjax.js vs ‘use strict’ vs Firefox vs IE

Hi folks

I fixed a very weird bug today.

Initially the bug was raised that some actions causes JavaScript error in Firefox:

TypeError: access to strict mode caller function is censored

This was not happening in IE or Chrome.

I started to debug and found that the problem is within MicrosoftAjax framework. I am working on a legacy ASP.NET WebForms project which uses and relies on it heavily.

For the blogging purposes I looked for a debug/unminified version of the problematic script and found it here:

I would like to refer to some lines so I uploaded the same file to gist.

The problematic line was

while (caller.arguments.callee.caller && --recursionLimit) {

where at some stage caller.arguments.callee variable equals to the function that is defined in some script with

"use strict";


and therefore it prohibited to call its caller

And the reason why this issue occurred in Firefox only is the line

var event = window.event;

window.event is undefined in Firefox. This event variable is not really needed. The only place it is used would be called under pretty rare condition according to the code flow.

activeElement = event ? ( || event.srcElement) : null;

So in order to fix the problem I think it is pretty safe to fake **window.event** for this function.

So I’ve written a hack

 * This is required to fix a bug in MicrosoftAjaxWebForms.js
 * in Firefox where if window.event is not initialized, it loops stack
 * via arguments.callee.caller chain and breaks because of the
 * "use strict" mode
function hackEventWithinDoPostBack() {
    var originalDoPostBack = window.__doPostBack;

    window.__doPostBack = function hackedDoPostBack() {
        if (!window.event)
            window.event = {};
        return originalDoPostBack.apply(this, arguments);

And this worked fine in Firefox. I thought it would work fine in IE and Chrome as well because I am checking for window.event before overriding but it was not!

IE11 started to fail in other places with the following error

Assignment to read-only properties is not allowed in strict mode

That was caused by the

window.event = {};

line written above. I found that window.event still can be undefined but you are not allowed to set it explicitly.

That appeared to be a bit tricky to overcome and eventually I came up with a pretty sophisticated solution

 * This is required to fix a bug in MicrosoftAjaxWebForms.js
 * in Firefox where if window.event is not initialized, it loops stack
 * via arguments.callee.caller chain and breaks because of the
 * "use strict" mode
 * Hacking window.event property is required because it is
 * not settable in Internet Explorer
function hackEventWithinDoPostBack() {
    var originalEventDescriptor = Object.getOwnPropertyDescriptor(Window.prototype, "event");
    var hackEventVariable = false;
    var eventPropertyHolder;
    Object.defineProperty(window, "event", {
        configurable: true,
        get: function get() {
            var result = originalEventDescriptor ? originalEventDescriptor.get.apply(this, arguments) : eventPropertyHolder;
            if (result || !hackEventVariable)
                return result;
            return {};
        set: function set(value) {
            if (originalEventDescriptor)
                originalEventDescriptor.set.apply(this, arguments);
                eventPropertyHolder = value;

    var originalDoPostBack = window.__doPostBack;

    window.__doPostBack = function hackedDoPostBack() {
        hackEventVariable = true;
        originalDoPostBack.apply(this, arguments);
        hackEventVariable = false;

This works in IE, Chrome and Firefox.

Such a workaround, isn’t it?!

Stay tuned

Posted in Uncategorized | Tagged , | 4 Comments