This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"region": "Москва и Московская обл.", | |
"city": "Москва" | |
}, | |
{ | |
"region": "Москва и Московская обл.", | |
"city": "Абрамцево" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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')); | |
* })); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 не поддерживается'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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()){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (string) => { | |
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | |
}; |