Skip to content

Instantly share code, notes, and snippets.

View ankurparihar's full-sized avatar
💭
I may be slow to respond.

Ankur Parihar ankurparihar

💭
I may be slow to respond.
View GitHub Profile
@ankurparihar
ankurparihar / array-indexof.js
Created November 26, 2024 06:28
Array indexOf performance
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
@ankurparihar
ankurparihar / count-to-million.js
Last active September 28, 2024 20:34
count-to-a-million-challenge-script
// 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());
});
@ankurparihar
ankurparihar / README.md
Last active September 28, 2024 20:27
counttoamillion-challenge-script
@ankurparihar
ankurparihar / find-external-resources.js
Last active January 24, 2024 16:06
ChromeDevTools: Filter url not matching with domain
performance
.getEntries()
.filter(({entryType}) => entryType === "resource")
.map(p => p.name)
.filter(domain => !domain.match(new RegExp(`^${window.location.origin}`)))
@ankurparihar
ankurparihar / README-Template.md
Created August 10, 2020 08:29 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ankurparihar
ankurparihar / RecordCanvas.js
Created August 3, 2020 11:51
Record canvas and save as mp4 (tested on Google Chrome)
// 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')
@ankurparihar
ankurparihar / mp4togif.sh
Created August 2, 2020 13:47
ffmpeg convert mp4 to gif
ffmpeg -i input.mp4 -vf "fps=30" -loop 0 output.gif
@ankurparihar
ankurparihar / LuminousComponent.c
Created February 24, 2020 11:29
The development of the algorithm for the luminance component [Paper:Novel Histogram Processing for Colour Image Enhancement]
#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
/*----- 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