Skip to content

Instantly share code, notes, and snippets.

View js2me's full-sized avatar
🚙
I may be slow to respond.

Sergey S. Volkov js2me

🚙
I may be slow to respond.
View GitHub Profile
@js2me
js2me / gist:a35870fe7318041bd179d041808ac980
Created March 23, 2017 10:42
calculateHeightOfCartesian2.CesiumJS
ye sure,
//adding first time model to viewer
------------------------------------------------------------
var longitude,latitude,altitudeCode,timestamp,heading;
altitudeCode = (altitudeCode * 0.3048);
var start = Cesium.JulianDate.fromDate(new Date(timestamp * 1000));
var time = Cesium.JulianDate.addSeconds(start, 0, new Cesium.JulianDate());
function declareOfNum(number,tiles = ['го','х','и','а']){
let num = typeof number === 'string' ? +number : number;
let lastNum = num % 10;
return lastNum ? (lastNum > 1 && lastNum < 5 && tiles[1] || lastNum > 4 && tiles[2] || tiles[0]) : lastNum === 0 && tiles[num > 100 ? ((num + '')[1] === '0' ? 3 : 2) : 2] || 'NaN';
}
@js2me
js2me / momentFeature.js
Created October 11, 2017 08:23
moment feature! get current week number in the current month
let moment = require('moment-timezone') || require('moment');
moment.prototype.weekOfMonth = function weekOfMonth(m) { // eslint-disable-line
return this.week() - moment(this).startOf('month').week() + 1;
};
@js2me
js2me / jsExtensions.js
Created October 11, 2017 08:26
Basic JavaScript classes extension
if (!Array.prototype.last){ //last element of Array :) If you like to write better .last() then [array.length-1]
Array.prototype.last = function(){
return this[this.length - 1];
};
};
if (!Array.prototype.first){ //similarly, but first element of array [0]
Array.prototype.first = function(){
return this[0];
@js2me
js2me / HTMLExtensions.js
Created October 11, 2017 08:31
If you write only on VanillaJS and you dont use jQuery, that gist for you! He include features, which help to you work with DOM elements
Element.prototype.remove = function () {
this.parentElement.removeChild(this);
};
NodeList.prototype.remove = HTMLCollection.prototype.remove = function () {
for (var i = this.length - 1; i >= 0; i--) {
if (this[i] && this[i].parentElement) {
this[i].parentElement.removeChild(this[i]);
}
}
};
@js2me
js2me / __animation-variables.scss
Created March 1, 2018 09:30
Famous animations as variables in scss
$ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
$ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
$ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22);
$ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06);
$ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
$ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
$ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
$ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
$ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
$ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
@js2me
js2me / validateString.js
Last active March 29, 2018 22:41
NICE STRING VALIDATOR
const _validators = {
required: value => !!value.length,
'min-length': (value, min) => value.length >= +min,
'max-length': (value, max) => value.length <= +max,
number: value => isNaN(+value),
equals: (value, equals) => value === equals,
regexp: (value, regexp) => new RegExp(regexp).test(value),
}
/**
@js2me
js2me / change-remote-url-git.sh
Last active April 6, 2018 12:15
set origin remote url with token [GIT]
git remote rm origin
git remote add origin https://<USERNAME>:<MYTOKEN>@github.com/<COMPANY/USERNAME>/<PROJECT>.git
@js2me
js2me / requestify.js
Created October 31, 2018 11:24
requestify module
import { BASE_URL } from 'api'
let abortableRequests = {}
const createRequest = (
method,
path,
{ body, successStatus, abortableKey } = {}
) => {
let request = new XMLHttpRequest()
@js2me
js2me / logObject.js
Last active October 31, 2018 20:10
Better object log using console in web
console.logObject = function(...args) {
const log = args.reduce((logs, object, index) => {
if (typeof object === 'object' && !(object instanceof Array)) {
logs.push(`\r\n{ `)
logs.push.apply(
logs,
Object.keys(object).reduce((values, key) => {
values.push(
`\r\n ${key}:`,
typeof object[key] === 'function' ? '[function]' : object[key],