Skip to content

Instantly share code, notes, and snippets.

Avatar

Viacheslav Moskalenko JasonRammoray

View GitHub Profile
View async-tasks-checker.js
class Foo {
constructor(time, answer) {
this._time = time;
this._answer = answer;
}
get time() {
return this._time;
}
is() {
return new Promise(res => setTimeout(() => res(this._answer), this._time));
@JasonRammoray
JasonRammoray / pac
Created May 16, 2018
slack-sock-pac
View pac
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*.slack-msgs.com")) {
// Use SOCK proxy,
// or fall back to a DIRECT traffic.
// ssh -D 8000 [user]@[server]
return "SOCKS 83.174.203.210:1080; DIRECT";
}
return "DIRECT";
@JasonRammoray
JasonRammoray / dom-tree-depth-level.js
Created Mar 9, 2018
Get depth of a DOM tree with a list of nodes included into longest path
View dom-tree-depth-level.js
function getDomDepthLevel(root = document.documentElement) {
let pathInfo = {
route: [],
level: 0
};
for (let i = 0, j = root.children.length; i < j; i++) {
const curNodePathInfo = getDomDepthLevel(root.children[i]);
if (curNodePathInfo.level > pathInfo.level) {
pathInfo = curNodePathInfo;
}
@JasonRammoray
JasonRammoray / Nvidia - noisy sms flow
Last active Jun 27, 2017
This is a snippet, which is capable to cause sending of potentially unlimited number of sms containing verification codes through Nvidia grid sms gateway
View Nvidia - noisy sms flow
/*
* This is a noisy scenario, which tests sms gateway api,
* when user is trying to get a verification code on his / her
* smartphone
*/
(function() {
'use strict';
/*
View Module pattern example
All in one file example:
var buisnessModule = (function() {
var SomeConstructor = function SomeConstructor() {
if( !( this instanceof SomeConstructor ) ) {
return new SomeConstructor(arguments);
}
this.params = Array.prototype.slice.call(arguments);
};