Skip to content

Instantly share code, notes, and snippets.

View neyasbltb88's full-sized avatar
🥉
Javascript developer

Denis Mashkov neyasbltb88

🥉
Javascript developer
View GitHub Profile
@neyasbltb88
neyasbltb88 / baseConverter.js
Created April 5, 2019 12:51 — forked from faisalman/baseConverter.js
Convert From/To Binary/Decimal/Hexadecimal in JavaScript
/**
* Convert From/To Binary/Decimal/Hexadecimal in JavaScript
* https://gist.github.com/faisalman
*
* Copyright 2012-2015, Faisalman <[email protected]>
* Licensed under The MIT License
* http://www.opensource.org/licenses/mit-license
*/
(function(){
@neyasbltb88
neyasbltb88 / russia
Created April 3, 2019 18:40 — forked from gorborukov/russia
Регионы и города россии в формате JSON
[
{
"region": "Москва и Московская обл.",
"city": "Москва"
},
{
"region": "Москва и Московская обл.",
"city": "Абрамцево"
},
@neyasbltb88
neyasbltb88 / concat.array.buffers.js
Created March 24, 2019 01:37 — forked from 72lions/concat.array.buffers.js
Concatenates two ArrayBuffers
/**
* Creates a new Uint8Array based on two different ArrayBuffers
*
* @private
* @param {ArrayBuffers} buffer1 The first buffer.
* @param {ArrayBuffers} buffer2 The second buffer.
* @return {ArrayBuffers} The new ArrayBuffer created out of the two.
*/
var _appendBuffer = function(buffer1, buffer2) {
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
@neyasbltb88
neyasbltb88 / gulpfile.js
Created February 26, 2019 11:46 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@neyasbltb88
neyasbltb88 / index.js
Created February 9, 2019 22:54 — forked from just-boris/index.js
Gulp wrap pipe
/**
* Wrap gulp streams into fail-safe function for better error reporting
* Usage:
* gulp.task('less', wrapPipe(function(success, error) {
* return gulp.src('less/*.less')
* .pipe(less().on('error', error))
* .pipe(gulp.dest('app/css'));
* }));
*/
function updateURL() {
if (history.pushState) {
var baseUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
var newUrl = baseUrl + '?tyapk=awesome';
history.pushState(null, null, newUrl);
}
else {
console.warn('History API не поддерживается');
}
}
@neyasbltb88
neyasbltb88 / color-log.js
Last active January 13, 2019 00:15
Add color style for console.log
// Monokai цвета, которые можно использовать в консоли, например:
// console.log('%c%s', window.log_color.orange, 'Инициализация скрипта');
window.log_color = {
green: [
'color: #272822;',
'background-color: #A6E22E;',
'padding: 2px 10px;',
'width: 100%'
].join(' '),
red: [
function data2blob(data, isBase64) {
var chars = "";
if (isBase64)
chars = atob(data);
else
chars = data;
var bytes = new Array(chars.length);
for (var i = 0; i < chars.length; i++) {
@neyasbltb88
neyasbltb88 / httpRequest.js
Created January 12, 2019 12:23 — forked from MrSwitch/httpRequest.js
httpRequest, quick and easy
//
// httpRequest
// Make Cross Origin http requests for JSON data.
// The first path is url, the second is a callback, as a JSON object.
// If XHR CORS is not supported then JSONP is used. "&callback=" is appended to the request URL.
// @author Andrew Dodson
function httpRequest(url,callback){
// IE10, FF, Chrome
if('withCredentials' in new XMLHttpRequest()){
@neyasbltb88
neyasbltb88 / camelToKebab.js
Created January 9, 2019 09:34 — forked from nblackburn/camelToKebab.js
Convert a string from camel case to kebab case.
module.exports = (string) => {
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
};