Skip to content

Instantly share code, notes, and snippets.

View ibratoev's full-sized avatar

Ivaylo Bratoev ibratoev

View GitHub Profile
function FindProxyForURL(url, host) {
PROXY = "PROXY 192.168.6.35:808"
if (shExpMatch(host,"*.demandware.net")) {
return PROXY;
}
if (shExpMatch(host,"*.demandware.com")) {
return PROXY;
}
@ibratoev
ibratoev / gist:3723891d81b98b94f7dec04b979164ff
Created April 19, 2018 13:53
Async-await vs then with not well behaving functions
const shouldReturnPromise = () => { throw "test"; }
const withAsyncAwait = async () => {
try {
await shouldReturnPromise()
} catch (e) {
console.log('Handled: ' + e)
}
}
/**
 * This is an example namespace description.
 * @namespace
 */
var MyNamespace = {
  /**
  * This is an example namespace member.
  */
  foo: ‘foo’
};
/**
 * This is an ES6 class.
 */
class ES6Class {
}
/**
 * This is a global function
 * with description on two lines.
 * @param {number} foo - Function's first parameter called 'foo'.
 * @param bar Second parameter. Note that the dash before the description is optional. Type is optional as well.
 * @returns {boolean} Description of the return value.
 */
var globalFunc = function (foo, bar) {
  return true;
}
/**
 * This is a global const.
 * @constant
 * @default
 */
var GLOBAL_CONST = 42;
/**
 * @name virtualGlobalVar
 * @description This a virtual global variable.
 * @global
 * @type {string}
 */
/**
* This is a global variable description.
* @type {number}
*/
var globalVar = 3;
/**
* Checks if a book is read.
* @param {string} book - The title of the book.
* @returns {boolean} True if the book is read; false otherwise.
*/
function isRead(book) {
return true;
}
@ibratoev
ibratoev / updateTypings.js
Created August 25, 2016 11:58
JS script to update typings
#!/usr/bin/env node
// Script to update typings to their latest versions.
// Note that it should be executed in the folder where typings.json is.
const { exec, execSync } = require('child_process');
const path = require('path');
const typings = require(path.join(process.cwd(), 'typings.json'));
exec('typings ls', (error, _, stderr) => {
if (error) {