Skip to content

Instantly share code, notes, and snippets.

View paveleremin's full-sized avatar

Pavel Eremin paveleremin

View GitHub Profile
@paveleremin
paveleremin / Cisco.vbs
Created February 24, 2017 06:45
Cisco AnyConnect: save password
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""
WScript.Sleep 1500
WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
@paveleremin
paveleremin / gist:86dafdb4341244fc3a94
Last active February 10, 2019 14:23
Brackets are correctly nested (two different approaches)
/**
* Implement function check (text) which checks whether brackets within text are correctly nested.
* You need to consider brackets of three kinds: (), [], {}.
*/
/**
* STACK approach
*/
function check(str){
var brackets = "()[]{}",
@paveleremin
paveleremin / doomsday.js
Created January 9, 2019 17:17
Google Solar Doomsday
function sum(arr) {
return arr.reduce((sum, n) => sum + n, 0);
}
function answer(initArea) {
var list = [];
var area = initArea;
var i = 1;
function equals(arr1, arr2) {
return JSON.stringify(arr1) === JSON.stringify(arr2);
}
function flatten(arr) {
return arr.reduce((result, toFlatten) => {
return result.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
window.getByXpath = function() {};
document.getByXpath = function() {};
getByXpath = function() {};
alert(123);
alert(typeof getByXpath);
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!u&&c)return c(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var a=n[o]={exports:{}};t[o][0].call(a.exports,function(n){var r=t[o][1][n];return s(r?r:n)},a,a.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(t,n,r){(function(n){"use strict";function define(t,n,e){t[n]||Object[r](t,n,{writable:!0,configurable:!0,value:e})}if(t(295),t(296),t(2),n._babelPolyfill)throw new Error("only one instance of babel-polyfill is allowed");n._babelPolyfill=!0;var r="defineProperty";define(String.prototype,"padLeft","".padStart),define(String.prototype,"padRight","".padEnd),"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(functi
@paveleremin
paveleremin / index.js
Last active September 3, 2016 20:24
Siteimprove test
'strict mode';
/**
* > You choose programming language, any external libraries
* > and strategi for implementation.
* > You should build a solution from scratch.
*
* I chose Javascript that work on a server (NodeJS)
*/
<?php phpinfo(); ?>
@paveleremin
paveleremin / chunk.js
Created November 4, 2015 17:19
Array chunk
Array.prototype.chunk = function(len) {
var chunks = [];
for (var i = 0, l = this.length; i < l; i += len) {
chunks.push(this.slice(i, i + len));
}
return chunks;
};
@paveleremin
paveleremin / gist:f3ad1f6ec22447e8ce47
Created October 13, 2015 10:16
Array shuffle, without creating new array
var array = [1, 2, 3, 4, 5, 6];
Array.prototype.shuffle = function() {
var i = this.length,
tmp,
randIndex;
while (--i) {
randIndex = Math.floor(i * Math.random());
tmp = this[i];
this[i] = this[randIndex];