Skip to content

Instantly share code, notes, and snippets.

View avorona's full-sized avatar

Vitalii Parshykov avorona

View GitHub Profile
@avorona
avorona / gulpfile.js
Last active August 6, 2017 11:43
gulp sass-css+watch+error+browser-sync
// You can change location of the files to fit you project structure
// This is defenitialy not mine snippet. I took it from here - > > > https://browsersync.io/docs/gulp
// Extra snippet update - prevent exiting when error catched--- from here https://gist.github.com/pornel/ca9631f5348383b61bc7b359e96ced38
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
//Enable switching celsius/f
var tempUnit = "c";
$('#switchBtn').on("click", function() {
var tempEl = $('#temp');
var tempVal = parseFloat(tempEl[0].innerHTML);
if(tempUnit=="f"){
@avorona
avorona / perlin(webpack).js
Last active October 8, 2017 16:39
Perlin noise (webpack ready)
export default function noise(x, y, z) {
var p = new Array(512)
var permutation = [ 151,160,137,91,90,15,
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
@avorona
avorona / open_object.js
Created October 17, 2017 17:58
get the value from object using cascad of keys
function handleResponse(obj, arrayyOfObjects) {
var object = obj;
var newObj = {};
var keyArray = [];
var arrayEl = '';
arrayyOfObjects.forEach(function(el) {
for (var key in el) {
@avorona
avorona / align-blocks.css
Created October 17, 2017 18:25
old hack for aligning elements (like justify-content do) , thanks to akella
ul {
font: 14px Verdana, Geneva, sans-serif;
text-align: justify;
/* Обнуляем для родителя*/
line-height: 0;
font-size: 1px; /* 1px для Opera */
/* Лекарство для IE6-7*/
text-justify: newspaper;
@avorona
avorona / debug.js
Created October 28, 2017 16:00
Put it in your console to debug your html markup
$$('*').map(A=>A.style.outline=`1px solid hsl(${(A+A).length*9},99%,50%`)
@avorona
avorona / Validator.js
Last active April 29, 2018 11:53
I love mtb cycling so i wrote my own bicycle - form validator
import './polyfills';
export default class Validator {
constructor(selector) {
this.forms = selector;
this.validationParams = [];
this.init();
@avorona
avorona / vscode_settings.json
Created November 21, 2017 19:31
vscode settings ( sublime keymap)
{
"workbench.panel.location": "bottom",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"editor.tabCompletion": true,
"editor.quickSuggestions": {
"other": true,
"comments": true,
function isJSON(text) {
// console.log(text)
if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
return true;
} else {
return false;
}
}
import io from 'socket.io-client/dist/socket.io';
import config from '../config';
class SocketsApi {
constructor() {
this.socket = null;
}
initialize(token) {
this.socket = io(config.api_url, {