Skip to content

Instantly share code, notes, and snippets.

'use strict';
const puppeteer = require('puppeteer');
const ProxyChain = require('proxy-chain');
const uas = [
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
];
@dobakay
dobakay / sortStack.js
Created March 21, 2016 20:13
sort a stack with another stack
'use strict';
function print(arr) {
var res = '';
for (var i = 0; i < arr.length; i++) {
res += arr[i];
};
return res;
}
/*
Assume you have a method isSubstring which checks if one word is a substring of
another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using
only one call to isSubstring (i.e., “waterbottle” is a rotation of “erbottlewat”).
*/
function isRotation(str1, str2) {
if(str1.length > 0 && str1.length === str2.length) {
var concatStr = str1 + str1;
return concatStr.indexOf(str2) !== -1;
}
function stringsAreAnagrams(str1, str2) {
if(str1.length !== str2.length) {
return false;
}
for (var i = 0; i < str1.length; i++) {
if(str2.indexOf(str1[i]) === -1 ) {
return false;
}
};
return true;
@dobakay
dobakay / removeDuplicates.js
Created March 14, 2016 14:12
Remove duplicated characters from string
/*
Example input => output
aaaaaaaaaaaaaaaabc => abc
aaaaabbbac => abac
*/
function removeDuplicates(str) {
if(str === null || str === undefined) {
return null
}
@dobakay
dobakay / youtube-replay-button.js
Last active September 4, 2016 02:10
youtube replay-song button functionality
/*
Open your favourite music video, open chrome dev tools console (f12 and after that Esc).
Copy/Paste the following code.
Enjoy Replay self-clickable button! :)
*/
var playButton = $('.html5-player-chrome').children[1];
setInterval(function() {
if(playButton.classList.contains('ytp-button-replay')) {