Skip to content

Instantly share code, notes, and snippets.

@tytskyi
tytskyi / choco_install.bat
Created December 9, 2014 22:34
Install bunch of cool windows programs by 1 command.
:: archivers
choco install 7zip.install
:: messaging/collaboration
choco install skype
choco install teamviewer
:: iso/usb
choco install cdburnerxp
choco install poweriso
@tytskyi
tytskyi / inheritance.js
Last active August 29, 2015 14:11
Quickstart jQuery plugin boilerplate.
// Example of creation new plugin based on this one.
(function ($) {
var pluginName = 'myBoilerplate';
var parent = $.fn.boilerplate;
var defaults = {};
var Constructor = function (element, options) {
this.element = element;
this._settings = $.extend({}, defaults, options);
var formatThousands = function (input, separator) {
var output = [];
input = String(input).split('').reverse();
if (separator === void 0 || separator == null) {
separator = ',';
}
for (var i = 0, len = input.length, lastIndex = len - 1; i < len; i++) {
/**
* Get position of given element in array or given sub-string in string
*
* @raram {String|Array} source
* @param {String|Number|Boolean} term
*
* @return {Number} Position of term in source or -1
*/
var indexOf = (function () {
var NEGATIVE = -1;
getCleanTodayTimestamp = function () {
return new Date().setHours(0, 0, 0, 0);
}
var redirect = (function () {
var isFirefox = false;
var browser = window.navigator.userAgent;
var location = window.location;
var fixFirefoxHistory = function () {
var hash = window.location.hash;
var timestamp = Date.now();
if (isFirefox) {
var extend = (function () {
var own = function (parent, child) {
return Object.prototype.hasOwnProperty.call(parent, child);
};
return function (out) {
out = out || {};
for (var i = 1, len = arguments.length; i < len; i++) {
if (!arguments[i]) {
@tytskyi
tytskyi / easyEvents.js
Last active February 25, 2016 20:09
An easy way to realise event delegation in jQuery version-agnotic way
/**
* An easy way to realise event delegation jQuery in version-agnotic way
*/
var easyEvents = (function () {
var easyEvents = function (bindings, jQuery) {
easyEvents._jq = window.jQuery || jQuery;
if (!easyEvents._jq) {
window.mmcore || (window.mmcore = {});
window.mmcore.waitFor || (window.mmcore.waitFor = function () { return {then: function () {}}; });
window.mmcore.waitFor(function () {
@tytskyi
tytskyi / type.js
Last active August 29, 2015 14:05
type = (function(global) {
var re = /\s([a-z|A-Z]+)/;
return function(obj) {
if (obj === global) {
return 'global';
}
return Object.prototype.toString.call(obj).match(re)[1].toLowerCase();
}
})(window);
var bindNativeEvent = function (domElement, eventType, callback) {
if (!domElement || !eventType) {
return;
}
var eventMethod = window.addEventListener ?
['addEventListener', ''] :
['attachEvent', 'on'];
domElement[eventMethod[0]](eventMethod[1] + eventType, function (event) {