- Install pm2 globally
npm i -g pm2
- Login to https://counttoamillion.com/ site
- Use https://httptoolkit.com/ to intercept websocket request
- Update header and cookie values in the script
- Run
pm2 start --no-daemon npm -- start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findString(length=1) { | |
// const num1 = String(Math.floor(Math.random() * Math.pow(10, length))); | |
const string1 = new Array(length).fill(Math.floor(Math.random() * 10)).join(""); | |
const string2 = new Array(length).fill("a").join(""); | |
const string3 = new Array(length).fill("a").join(""); | |
console.log(string1 , string2, string3) | |
// create 100000 strings, with only the last string being the matching one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For: https://www.reddit.com/r/webdev/comments/1frg8r2/i_built_a_website_that_will_be_won_by_the_first/ | |
// Writeup: https://medium.com/@ankurparihar/count-to-million-challange-javascript-2c1b534c2040 | |
var WebSocketClient = require('websocket').client; | |
var client = new WebSocketClient(); | |
client.on('connectFailed', function(error) { | |
console.log('Connect Error: ' + error.toString()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
performance | |
.getEntries() | |
.filter(({entryType}) => entryType === "resource") | |
.map(p => p.name) | |
.filter(domain => !domain.match(new RegExp(`^${window.location.origin}`))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://medium.com/@amatewasu/how-to-record-a-canvas-element-d4d0826d3591 | |
const canvas = document.getElementsByTagName('canvas')[0] | |
const videoStream = canvas.captureStream(30) | |
const mediaRecorder = new MediaRecorder(videoStream) | |
var chunks = [] | |
mediaRecorder.ondataavailable = function (e) { | |
chunks.push(e.data) | |
} | |
var video = document.createElement('video') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i input.mp4 -vf "fps=30" -loop 0 output.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
float H(int); // Histogram data function | |
int value = 0; // color value [0-255] used in result | |
int result[255]; // store the ranges | |
int max_recursion = 8; // 8 recursion as mentioned in paper 2^8 = 256 intervals | |
/** | |
* Find intermediate cut C for which sum(H[start-C]) is equal to sum(H[C-end]) | |
* for a given range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*----- Find host name from IP address -----*/ | |
#include <stdio.h> | |
#include <netdb.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <arpa/inet.h> | |
int main(int argc, char* argv[]){ | |
struct hostent* hent; // host structure |