This file contains hidden or 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
const path = require('path'); | |
const { spawn } = require('child_process'); | |
(async () => { | |
try { | |
await zip(path.resolve(__dirname, 'foo.js'), path.resolve(__dirname, 'bar.zip')); | |
console.log('OK'); | |
} catch (err) { | |
console.error('Failed to zip!', err); |
This file contains hidden or 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
/* | |
Example: | |
parseQueryString('?foo=hi&bar=World%20Hello') | |
{ | |
foo: "hi", | |
bar: "Hello World" | |
} | |
*/ | |
/** |
This file contains hidden or 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
/** | |
* Minimal Ajax library | |
* @param {object} options Options | |
* @param {string} options.url Url | |
* @param {string} [options.method='GET'] Method GET|POST|PUT|DELTE | |
* @param {string} [options.data] Body of the request | |
* @param {string} [options.contentType='application/x-www-form-urlencoded'] Set the content type of the body | |
* @param {number} [options.timeout] Timout in milliseconds | |
* @param {boolean} [options.withCredentials=false] withCredentials | |
* @return {Promise} Returns a promise |
This file contains hidden or 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
/** | |
* url hash manager | |
* @author Victor N <[email protected]> | |
*/ | |
const param = (function HashParams() { | |
function parse(string) { | |
var params = {}; | |
string.replace(/^[#?]/, '').split('&').forEach(text => { | |
var p = text.split('='); |
This file contains hidden or 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
/** | |
* domReady for IE6+ | |
* @param {Function} callback Callback | |
* | |
* @author http://beeker.io/jquery-document-ready-equivalent-vanilla-javascript | |
* @date 2016-10-04 | |
*/ | |
function domReady(callback) { | |
var ready = false; | |
var detach = function() { |
This file contains hidden or 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 shuffle(arr) { | |
const a = arr.slice(); | |
for (let i = a.length; i; i--) { | |
let j = Math.floor(Math.random() * i); | |
[a[i - 1], a[j]] = [a[j], a[i - 1]]; | |
} | |
return a; | |
} |
This file contains hidden or 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 sortBy(arr, fields) { | |
if (typeof fields === 'string') fields = [fields]; | |
function compareFn(a, b) { | |
return fields | |
.map(field => { | |
let dir = 1; | |
if (field[0] === "-") { | |
dir = -1; | |
field = field.substring(1); | |
} |
This file contains hidden or 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() { | |
var html = `<div style="position: fixed; top: 50px; left: 50px; z-index: 99999999; background-color:black; color: white; padding: 5px;"> | |
<div style="display: flex;"> | |
READ: | |
<button class="readAsJsonBtn">as JSON</button> | |
<button class="readAsEnvBtn">as ENV</button> | |
WRITE: | |
<button class="writeFromJsonBtn">from JSON</button> | |
<button class="writeFromEnvBtn">from ENV</button> | |
<span style="flex-grow: 1;"></span> |
This file contains hidden or 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
// All rules | |
// (R=Recommended,F=Fixable) | |
// Use .json5 highlighting | |
{ | |
// Possible Errors | |
// These rules relate to possible syntax or logic errors in JavaScript code: | |
"for-direction": "error", // (R,) enforce “for” loop update clause moving the counter in the right direction. | |
"getter-return": "error", // (R,) enforce return statements in getters | |
"no-async-promise-executor": "error", // (R,) disallow using an async function as a Promise executor | |
"no-await-in-loop": "off", // (,) disallow await inside of loops |
This file contains hidden or 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
/** | |
* Enable Bootstrap tooltips using Vue directive | |
* @author Vitim.us | |
* @see https://gist.github.com/victornpb/020d393f2f5b866437d13d49a4695b47 | |
* @example | |
* <button v-tooltip="foo">Hover me</button> | |
* <button v-tooltip.click="bar">Click me</button> | |
* <button v-tooltip.html="baz">Html</button> | |
* <button v-tooltip:top="foo">Top</button> | |
* <button v-tooltip:left="foo">Left</button> |