Skip to content

Instantly share code, notes, and snippets.

@Eccenux
Eccenux / logPreservation.js
Last active October 11, 2016 18:02
Utility for console logs preservation.
/**
* Utility for console logs preservation.
*
* @example Enable logs preservation for next page load:
* logPreservation.enable();
*
* @example Dump, but keep log entries for another dump:
* logPreservation.dump(true);
*
* @author Maciej Nux Jaros
@Eccenux
Eccenux / .Ext.ux.grid.RestoreFilters.js
Last active August 22, 2016 11:15
ExtJS Restore filters grid plugin
/* global Ext */
/**
* Restore filters grid plugin.
*
* To use this plugin just add to your grid
* 1. `'Ext.ux.grid.RestoreFilters'` in `requires` property
* 2. `ptype: 'gridrestorefilters'` in `plugins` property
* 3. and `restoreableFilters` array as a setting for the plugin (see below)
*
@Eccenux
Eccenux / localStorageSize.js
Created April 1, 2016 14:06
localStorage size check (obviously it only works for current domain)
var keys = Object.keys(localStorage);
var total = 0;
for (var i in keys) {
var key = keys[i];
var size = localStorage[key].length;
console.log(key, ' size ', getReadableFileSizeString(size));
total += size;
}
console.log('\n-------\ntotal size ', getReadableFileSizeString(total));
@Eccenux
Eccenux / DataCache.js
Created April 1, 2016 13:28
Class providing caching for data objects (e.g. translations).
/**
* Class providing caching for data objects.
*
* It's assumed that the data comes from some remote service (otherwise there is no point in caching).
*
* @param {String} dataKey Globally(!) unique key to store data.
* @param {Storage} storageService Storage service that should have two functions:
* storageService.set(key, value) -- set data
* storageService.get(key) -- get data
* Will attempt fallback to `$.jStorage` if not secified.
@Eccenux
Eccenux / NuxPadder.js
Last active March 31, 2016 17:20
Pad left class :-]
/**
* Pad class.
*
* @author Maciej "Nux" Jaros
* @license CC-BY
*
* Note! The class becomes faster with new itterations.
*/
NuxPadder = function (character)
{
@Eccenux
Eccenux / CascadeWindows.js
Last active February 2, 2016 19:32
Cascade window position plugin.
/* global Ext */
/**
* Cascade window position plugin.
*
* To use this plugin just add to your window
* 1. `'Ext.ux.CascadeWindows'` in `requires` property
* 2. `ptype: 'cascadewindows'` in `plugins` property
*
* @author Maciej "Nux" Jaros
@Eccenux
Eccenux / DefaultFilters.js
Last active December 9, 2015 11:17
Ext.ux.grid.DefaultFilters
/**
* Helps applying default filter values from grid to store.
*
* @example In your window with grid you could do:
* <pre>
initComponent: function() {
this.callParent();
// apply default filters from grid to store
var grid = this.down('grid');
@Eccenux
Eccenux / CB.smartOpenWebPanel.code.js
Last active November 24, 2015 04:31
Custom Buttons (FF) - smartOpenWebPanel (replacement for openWebPanel)
this.smartOpenWebPanel("Translate", "https://translate.google.pl/");
@Eccenux
Eccenux / CB.openInBrowser.code.js
Created November 24, 2015 04:31
Custom Buttons (FF) - open URL from current tab in any browser
// IE
this.openCurrentUrl("c:\\Program Files\\Internet Explorer\\iexplore.exe");
// Firefox Developer Edition
this.openCurrentUrl("C:\\Program Files\\Mozilla\\Firefox Developer Edition\\firefox.exe");
// Chrome
this.openCurrentUrl("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
// Edge
// for whatever reason this doesn't work for local files (i.e. "file:///...")
this.openCurrentUrl("c:\\windows\\system32\\cmd.exe", ["/c", "start", "microsoft-edge:%u"]);
@Eccenux
Eccenux / FramePostman.js
Last active October 13, 2015 21:39
Simple Frame Postman
/**
Simple Frame Postman
version 1.1.2
Author: Maciej "Nux" Jaros
License: CC-BY or MIT (at ones choosing)
Usage (simple setup):