Skip to content

Instantly share code, notes, and snippets.

@Solomko2
Solomko2 / fileSize.ts
Created August 29, 2017 14:15
fileSize pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'fileSize'
})
export class FileSizePipe implements PipeTransform {
private units = [
'bytes',
'KB',
@Solomko2
Solomko2 / .travis.yml
Created May 14, 2017 09:45
.travis.yml
language: node_js
sudo: required
dist: trusty
node_js:
- '6.9'
addons:
apt:
sources:
- google-chrome
@Solomko2
Solomko2 / клас висотою екрана.js
Created November 3, 2016 12:27
клас висотою екрана
$( document ).ready(function() {
if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
var h = $('.height-fix').height();
$('.height-fix').height(h);
}
});
@Solomko2
Solomko2 / delete class after animate.js
Created September 22, 2016 10:04
delete class after animate
$checkout_box.one('webkitAnimationEnd oanimationend msAnimationEnd animationend',
function (e) {
$checkout_box.removeClass('tada');
});
@Solomko2
Solomko2 / array_remove_element.js
Created August 29, 2016 18:44
удаление элемента из массива
function remove(array, element) {
return array.filter(e => e !== element);
}
const vowelsAndX = ["a", "e", "i", "o", "u", "x"];
const vowels = remove(vowelsAndX, "x");
vowels.toString(); // "a,e,i,o,u"
@Solomko2
Solomko2 / wheel.js
Created August 17, 2016 17:54
Showing the use of JavaScript code to track mouse wheel events on a specific object on the page, in a manner that normalizes across browsers the distance and direction that the wheel has travelled.
//http://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
var wheelDistance = function(evt){
if (!evt) evt = event;
var w=evt.wheelDelta, d=evt.detail;
if (d){
if (w) return w/d/40*d>0?1:-1; // Opera
else return -d/3; // Firefox; TODO: do not /3 for OS X
} else return w/120; // IE/Safari/Chrome TODO: /3 for Chrome OS X
};
@Solomko2
Solomko2 / swipeEvents.js
Created August 4, 2016 09:03 — forked from Tivoli/ swipeEvents.js
Javascript Swipe Events
function getSwipeEvent(deltaX, deltaY) {
switch(true) {
case deltaX >= 50: return new Event('swipeLeft');
case deltaX <= -50: return new Event('swipeRight');
case deltaY >= 50: return new Event('swipeUp');
case deltaY <= -50: return new Event('swipeDown');
}
}
function swipeEvents() {
var $string = $string.charAt(0).toUpperCase() + $string.slice(1);
@Solomko2
Solomko2 / select to list.js
Last active July 29, 2016 10:37
Звменить select обычным списком
$('#yearfilter').parent().append('<ul id="newyearfilter" name="yearfilter"></ul>');
$('#yearfilter option').each(function(){
$('#newyearfilter').append('<li value="' + $(this).val() + '">'+$(this).text()+'</li>');
});
$('#yearfilter').remove();
$('#newyearfilter').attr('id', 'yearfilter');
function constructselect(id, name, newId, newName) {
var $id = $('#' + id);
@Solomko2
Solomko2 / clear hash.js
Last active July 29, 2016 10:38
Очистить HASH
Best is Homero Barbosa's answer below:
history.pushState("", document.title, window.location.pathname);
... or, if you want to maintain the search parameters:
history.pushState("", document.title, window.location.pathname + window.location.search);
EDITED, old, do not use, badwrongfun:
var loc = window.location.href,