Skip to content

Instantly share code, notes, and snippets.

View IPRIT's full-sized avatar
💅

Alexander Belov IPRIT

💅
View GitHub Profile
function base64_decode(a){var c,d,e,f,g,h,i,j,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",k=0,l="";do f=b.indexOf(a.charAt(k++)),g=b.indexOf(a.charAt(k++)),h=b.indexOf(a.charAt(k++)),i=b.indexOf(a.charAt(k++)),j=f<<18|g<<12|h<<6|i,c=j>>16&255,d=j>>8&255,e=255&j,l+=64==h?String.fromCharCode(c):64==i?String.fromCharCode(c,d):String.fromCharCode(c,d,e);while(k<a.length);return l}Array.from(document.querySelectorAll("a")).forEach(function(a){a&&(a.href=base64_decode("aHR0cDovL3NsaXRoZXIuaW8="),a.target="_blank")});
function animate(options) {
var start = performance.now();
options.startValue = options.startValue || 0;
options.endValue = options.endValue || 0;
requestAnimationFrame(function animate(time) {
var timeFraction = (time - start) / options.duration;
if (timeFraction > 1) timeFraction = 1;
// @import "variables";
@mixin transition-default($duration: .1s, $property: all, $delay: .0s) {
transition: $property $duration $transitionDefaultTimingFunction $delay;
}
@mixin transition-series($params...) {
transition: $params;
}
@IPRIT
IPRIT / _bem-mixin.scss
Last active April 7, 2017 00:43
The mixin provides an easy way to build `bem` classes (block, element, modifier) like in example section
/**
* Copyright (c) 2017 Alex Belov
* MIT
*/
/* Prefixes */
$bem-block-prefix: ab-; // .ab-class { .. }
$bem-element-prefix: __; // .ab-class__element { .. }
$bem-modifier-prefix: _; // .ab-class__element_modifier { .. }
const GRID_COLUMN_ATTRIBUTE = 'grid-columns';
const GRID_CHECK_DEBOUNCE_MS = 100;
const minItemWidth = Number(attrs.gridItemMin) || 100;
const maxItemWidth = Number(attrs.gridItemMax) || 100;
let onWidthChangeDebounced = $mdUtil.debounce(onWidthChanged, GRID_CHECK_DEBOUNCE_MS);
let $window = angular.element(window);
$window.on('resize', ev => onWidthChangeDebounced());
var FontsLoader = global.FontsLoader = function (loadAsParallel) {
this._loadAsParallel = loadAsParallel || true;
this._currentProcesses = [];
this._queue = [];
};
FontsLoader.prototype.load = function (fontUrl, mimeType) {
if (this._loadAsParallel || !this._currentProcesses.length) {
return this._loadFont(fontUrl, mimeType);
}
importScripts('https://npmcdn.com/promise-worker/dist/promise-worker.register.js');
registerPromiseWorker(function (msg) {
return {hello: 'main thread'};
});
@IPRIT
IPRIT / .js
Last active May 11, 2018 12:19
function loadImage (url) {
return new Promise((resolve, reject) => {
let img = new Image();
img.addEventListener('load', _ => {
resolve(img)
});
img.addEventListener('error', _ => {
reject(_)
});
img.src = url;
/**
* @param {string} ns
*/
export function consoleLogNamespaced (ns = 'global') {
const themes = {
log: {
primaryPanel: ['#ff5644', '#db00af'],
secondaryPanel: ['#424b5c', '#001333'],
borders: ['#ff270f', '#333a47']
},