Skip to content

Instantly share code, notes, and snippets.

@oboshto
oboshto / Space
Created September 27, 2016 11:25 — forked from nathanacurtis/Space
$space-inset-default = 16px 16px 16px 16px;
$space-inset-xs = 4px 4px 4px 4px;
$space-inset-s = 8px 8px 8px 8px;
$space-inset-m = 16px 16px 16px 16px;
$space-inset-l = 32px 32px 32px 32px;
$space-inset-xl = 64px 64px 64px 64px;
$space-stack-default = 0 0 16px 0;
$space-stack-xs = 0 0 4px 0;
$space-stack-s = 0 0 8px 0;
$space-stack-m = 0 0 16px 0;
@oboshto
oboshto / style.less
Created September 27, 2016 17:29
Calc with .less
* {
width: calc(100% ~"-" 250px ~"-" 1.5em);
}
@oboshto
oboshto / VK audioplayer.js
Created October 13, 2016 15:50
VK audio player (13/10/2016) vk.com/js/al/audioplayer.js
function TopAudioPlayer(t,i){this.ap=getAudioPlayer(),this._el=t,this._playIconBtn=ge("top_audio"),this.init()}function AudioPlaylist(t,i,e){if(this.constructor!=AudioPlaylist)throw new Error("AudioPlaylist was called without 'new' operator");getAudioPlayer().addPlaylist(this);var o={};return t&&isFunction(t.getId)?(this._ref=t,void getAudioPlayer().addPlaylist(this)):(isObject(t)?o=t:(o.ownerId=i,o.type=t,o.albumId=e||++AudioPlaylist.plIndex),this._type=o.type,this._ownerId=o.ownerId||vk.id,this._albumId=o.albumId||0,this._list=[],this.mergeWith(o),this)}function AudioPlayer(){if(this._currentAudio=!1,this._isPlaying=!1,this._prevPlaylist=null,this._currentPlaylist=null,this._playlists=[],this.subscribers=[],this._tasks=[],this._listened={},this._statusExport={},this._currentPlayingRows=[],this._allowPrefetchNext=!1,!vk.isBanned){AudioUtils.debugLog("Player creation"),this._initImpl(),this._initEvents(),this._restoreVolumeState();var t=this;setTimeout(function(){t._restoreState(),AudioUtils.toggleAudioHQBody
@oboshto
oboshto / Array.prototype.find.js
Created October 24, 2016 11:27
Array.prototype.find (polyfill)
if (!Array.prototype.find) {
Array.prototype.find = function(predicate) {
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
@oboshto
oboshto / duplicates.js
Created October 25, 2016 09:00
Remove duplicates in properties in array of objects.
var keys = {};
$scope.newFilters = $scope.newFilters.filter(function (elem) {
if (!keys[elem.pattern]) {
keys[elem.pattern] = 1;
return true;
}
});
@oboshto
oboshto / style tag remove.js
Created November 17, 2016 17:56
tinymceeditor angular find and remove <style>
var editorContent = editor.getContent({format: 'raw'});
if (editorContent.match(/<style.*?>[^<]*<\/style>/igm)) {
editorContent = editorContent.replace(/<style.*?>[^<]*<\/style>/igm, '');
editor.setContent(editorContent, {format: 'raw'});
}
@oboshto
oboshto / password regexp
Last active January 25, 2017 12:55
12+ password regexp. 1+ special character, 1+ digit, 1+ uppercase
^(?=.*?[А-ЯЁA-Z])(?=.*?[а-яёa-z])(?=.*?[\d])(?=.*[^а-яА-ЯёЁa-zA-Z\d\s]).{12,}$
@oboshto
oboshto / email-domain regexp
Last active January 25, 2017 12:56
email or (domain with [at]) regexp
^((([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@)?(([^<>()\.,;\s@\"]+\.+)+[^<>()\.,;:\s@\"]{2,})$
@oboshto
oboshto / debounce.js
Created January 12, 2017 13:26
Debounce function for events
// debounce function that will wrap our event
function debounce(fn, delay) {
// maintain a timer
let timer = null;
// closure function that has access to timer
return function() {
// get the scope and parameters of the function
// via 'this' and 'arguments'
let context = this;
let args = arguments;
const CASES = [2, 0, 1, 1, 1, 2];
export default function proschet(titles) {
return function bindedProschet(amount) {
return titles[
(amount % 100 > 4 && amount % 100 < 20) ? 2 : CASES[(amount % 10 < 5) ? amount % 10 : 5]
];
};
}