My color scheme – 3 years after

August 21st, 2017 | Permalink

So, 3 years have passed since I published my color scheme for the last time.

3 years have passed and a lot of stuff changed, most important of which is I switched to JavaScript mainly. I use WebStorm instead of PHPStorm now, and today my color scheme looks a bit different:

SuperKewt color scheme screenshot

You can get it here if you want: Kewt21.icls

Modern JetBrains’ IDE’s allow you to simply import color scheme ;-)

Tiny Github SVG icon

June 17th, 2017 | Permalink

A tiny, super-optimized github ico for use in CSS

.icon{ width: 1em; height: 1em; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M256 0C114.6 0 0 114.6 0 256c0 113 73.3 209 175 243 13 2.3 17.5-5.7 17.5-12.4l-.3-47.7C121 454.3 106 408.6 106 408.6c-11.7-29.5-28.5-37.4-28.5-37.4-23.2-16 1.8-15.6 1.8-15.6 25.7 1.8 39.2 26.4 39.2 26.4 23 39.2 60 28 74.5 21.4 2.4-16.5 9-27.8 16.3-34.2-56.8-6.5-116.6-28.5-116.6-126.5 0-28 10-50.8 26.3-68.7-2.6-6.5-11.4-32.6 2.5-67.8 0 0 21.5-7 70.4 26.2 20.3-5.7 42.2-8.5 64-8.6 21.8 0 43.7 3 64 8.7 49-33.2 70.4-26.3 70.4-26.3 14 35.3 5.2 61.3 2.6 67.8 16.4 18 26.3 40.7 26.3 68.7 0 98.3-60 120-117 126.3 9.3 8 17.5 23.5 17.5 47.4 0 34.2-.4 61.8-.4 70.2 0 6.8 4.7 14.8 17.7 12.3 101.7-34 175-130 175-243C512 114.6 397.4 0 256 0z'/%3E%3C/svg%3E"); }

It is about 700 bytes.

Getting all custom window children.

January 12th, 2017 | Permalink

On some websites their creators store some useful functions in window scope directly. For example, when site is all AJAX-driven et cetera, like vk.com, it may be useful from both solidity and performance perspectives, I believe. Of course, they say that “littering” global ojbect is bad, but it is bad only when you’re developing a library or do not exactly do what are you doing.

Now, as in previous post, by creating the IFrame and accessing its’ contentWindow we can get a “fresh” window object. It is useful when we want to restore some redefined native
code, but also we can also get all custom children of current window object. Getting all new variables in window, grouped by their type:

(function(ifr){
    document.body.appendChild(ifr);      
    var newKeys = {};

    Object.keys(window).forEach(function(key){
        if(typeof ifr.contentWindow[key] == 'undefined'){
            var type = typeof window[key];
            newKeys[type] = newKeys[type] || {};
            newKeys[type][key]=window[key];
        }
    });
    ifr.parentNode.removeChild(ifr);
    return newKeys;
})(document.createElement('iframe'));

This comes in handy sometimes. For example, when you’re writing a userscript for some website. Or just want to dig in someone else’s code which is interesting sometimes on complicated websites (as chrome developer console, for example, allows you to right-click the function and “Show function definition”, even allowing pretty-printing minified scripts)

Restore console functions in JS

December 28th, 2016 | Permalink

Naughty boys and girls sometimes replace browser’s console object from window object to eliminate debug messages from scripts (instead of just redefining it inside closure). There IS a way to restore it. I do it like this:

(function(ifr){
  document.body.appendChild(ifr);
  window.console = ifr.contentWindow.console;
  ifr.parentNode.removeChild(ifr);
})(document.createElement('iframe'));

‘course, this should be done after the DOM is ready, I guess. Most cases I use it I’m fiddling in browser’s console and have no access to page source anyway.

Also I was lazy to hard-code the latin alphabet and did this:

Array.apply(0,Array(26)).map(function(a,i){return String.fromCharCode(i+97);});
// ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

And yea, I was bored.

MEMO: Configuring LAMP stack with MariaDB on OVH’s VPS under Ubuntu 16.04

December 3rd, 2016 | Permalink

A tiny article on configuring LAMP stack using MariaDB and Phpmyadmin under Ubuntu 16.04. This article is basically a memo. I wrote it mostly for myself as I often am doing all of these and always have to be sure I didn’t forget anything in the process.

Read on