Skip to content

Instantly share code, notes, and snippets.

View JasonRammoray's full-sized avatar

Viacheslav Moskalenko JasonRammoray

View GitHub Profile
@JasonRammoray
JasonRammoray / async-tasks-checker.js
Last active December 21, 2018 17:03
Async tasks checker
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 09:59
slack-sock-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 March 9, 2018 20:36
Get depth of a DOM tree with a list of nodes included into longest path
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 June 27, 2017 19:07
This is a snippet, which is capable to cause sending of potentially unlimited number of sms containing verification codes through Nvidia grid sms gateway
/*
* 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';
/*
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);
};