Skip to content

Instantly share code, notes, and snippets.

View igenex's full-sized avatar

igenex igenex

  • Minsk
View GitHub Profile
@igenex
igenex / raf-boilerplate.js
Created June 16, 2018 17:13 — forked from bendc/raf-boilerplate.js
rAF tutorial: boilerplate code
"use strict";
// animation utils
// ===============
const trackTime = id => {
const [entry] = performance.getEntriesByName(id);
if (!entry) {
performance.mark(id);
@igenex
igenex / MultiExporter.jsx
Created June 13, 2018 21:09 — forked from TomByrne/MultiExporter.jsx
An Illustrator script for exporting layers and/or artboards into separate files (PNG8 / PNG24 / EPS / PDF / SVG / JPG / FXG).See http://www.tbyrne.org/export-illustrator-layers-to-svg-files
// MultiExporter.jsx
// Version 0.1
// Version 0.2 Adds PNG and EPS exports
// Version 0.3 Adds support for exporting at different resolutions
// Version 0.4 Adds support for SVG, changed EPS behaviour to minimise output filesize
// Version 0.5 Fixed cropping issues
// Version 0.6 Added inner padding mode to prevent circular bounds clipping
//
// Copyright 2013 Tom Byrne
// Comments or suggestions to tom@tbyrne.org
@igenex
igenex / WebWorker.html
Created January 31, 2018 13:22
Simple WebWorker Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
</head>
<body>
<button id="littleButton">Отправить запросы</button>
<div id="content"></div>
<script>
function sendRequest (url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.send();
xhr.addEventListener('load', () => {
resolve(xhr.response);
@igenex
igenex / es6-examples4.js
Created November 9, 2017 12:12
ES6 - работа с числами
/*========================================
= Работа с числами =
========================================*/
//Теперь можно сразу писать числа в двоичном виде,
//добавив 0b перед числом
{
let a = 0b00001111;
@igenex
igenex / es6-examples3.js
Created November 9, 2017 10:57
ES6 - объекты и стрелочные функции
/*==========================================
= Стрелочные функции и литералы объекта =
==========================================*/
// Простой пример стрелочной функции
let circleArea = (pi, r) => {
let area = pi * r * r;
return area;
}
@igenex
igenex / es6-examples2.js
Created November 8, 2017 14:14
ES6 - Деструктивное присваивание
/*==================================================
= Деструктивное присваивание =
==================================================*/
{
let myArr = [1, 2, 3];
let a, b, c;
[a, b, c] = myArr;
//Или еще более короткий
@igenex
igenex / es6-examples1.js
Created November 8, 2017 13:42
ES6 - оператор расширения
//Значения по умолчанию
function myFunction(x = 1, y = 2, z = 3) {
console.log(x,y,z); //Выведет "6 7 3"
}
myFunction(6,7);
/*===========================================
= Оператор расширения =
===========================================*/
@igenex
igenex / sort-in-obj.js
Created October 23, 2017 17:25
Sort prop in object (сортировка свойтсва в объекте)
var products = [{ name: "Grapefruit", calories: 170, color: "red", sold: 8200 },
{ name: "Orange", calories: 160, color: "orange", sold: 12101 },
{ name: "Cola", calories: 210, color: "caramel", sold: 25412 },
{ name: "Diet Cola", calories: 0, color: "caramel", sold: 43922 },
{ name: "Lemon", calories: 200, color: "clear", sold: 14983 },
{ name: "Raspberry", calories: 180, color: "pink", sold: 9427 },
{ name: "Root Beer", calories: 200, color: "caramel", sold: 9909 },
{ name: "Water", calories: 0, color: "clear", sold: 62123 }
];
function compareSold (colaA,colaB) {
@igenex
igenex / scrollTo
Created October 23, 2017 17:24
scroll to element (прокрутка до элемента jquery)
function (e) {
var elementClick = jQuery(this).attr("href");
var destination = jQuery(elementClick).offset().top;
jQuery('body').animate({ scrollTop: destination }, 1100);
return false;
e.preventDefault();
}