Skip to content

Instantly share code, notes, and snippets.

View azproduction's full-sized avatar

Mikhail Davydov azproduction

View GitHub Profile
@azproduction
azproduction / dump-indexed-db.js
Created July 8, 2021 11:22
Dumps all IndexedDB databases and saves all of them into a json file
;(async () => {
async function dumpDatabase(dbName) {
var dbExists = await new Promise(resolve => {
var request = window.indexedDB.open(dbName)
request.onupgradeneeded = e => {
e.target.transaction.abort()
resolve(false)
}
request.onerror = () => resolve(true)
request.onsuccess = () => resolve(true)
@azproduction
azproduction / b_.with.jsx
Last active August 29, 2015 14:13
BEM class name generator curring – b_.with
var B = require('b_');
var Array_of = function (any) {
return Array.prototype.slice.call(any);
};
B.with = function () {
var b = this,
curriedArgs = Array_of(arguments);
@azproduction
azproduction / scrollIntoView.js
Created December 23, 2014 09:38
scrollIntoView.js
/*!
* Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
*/
/**
* Better Element.scrollIntoView() implementation
*
* @see https://github.com/jquery/jquery-ui/blob/master/ui/menu.js#L409-L425
*
@azproduction
azproduction / cl.js
Last active August 29, 2015 14:11
WebStorm Live Templates
console.log($LINE$);
// LINE = lineNumber()
@azproduction
azproduction / _action.js
Last active August 29, 2015 14:10
Vision of Flux
// Action signature should be descriptive so IDE could use it.
var actionSet = createActions({
/**
* @param {object} data
* @param {string} data.name
* @param {string} data.value
*/
a: function actionMiddleware(data) {
// Case validate data
if (validate(data)) {
@azproduction
azproduction / index.js
Last active August 29, 2015 14:01
Memory test
// node --allow-natives-syntax index.js
var before, after, a;
before = %GetHeapUsage();
a = {};
after = %GetHeapUsage();
console.log(after - before);
@azproduction
azproduction / index.md
Created April 11, 2014 13:38
Deleted prototype element or function
var encodeURIComponent, Array_push, Number_toString;
(function() {
    var iframe = document.createElement('iframe'), loaded = false;
    iframe.style.width = '1px';
    iframe.style.height = '1px';
    iframe.style.position = 'absolute';
    var onloadIframe = function() {
        if (!loaded && iframe.contentWindow) {
            loaded = true;
@azproduction
azproduction / index.md
Last active February 27, 2019 07:04
Спецификация 1CSS (статус: черновик спецификации)
/**
*
* @param {String} moduleName module name or path to file
*/
function require(moduleName) {}
/**
* Matches in-package modules
*
* @param {RegExp} regExp
@azproduction
azproduction / event.js
Last active December 16, 2015 11:09
yet another EventManager
function EventManager () {
this._events = {};
}
EventManager.prototype = {
_event: function (type) {
var events = this._events[type];
if (!events) {
events = this._events[type] = {};