Skip to content

Instantly share code, notes, and snippets.

const {
Worker
} = require('worker_threads');
// const NUM_WORKERS = os.cpus().length;
const NUM_WORKERS = 12;
const START = 100;
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
const os = require('os');
if (isMainThread) {
// Main thread
const NUM_WORKERS = os.cpus().length;
const START = 100;
const END = 100_000_000;
const CHUNK_SIZE = Math.ceil((END - START) / NUM_WORKERS);
const maxNum = num => +[...`${num}`].sort((a, b) => b - a).join('');
const minNum = num => +[...`${num}`].sort((a, b) => a - b).join('');
const reachedNums = new Set([]);
const seen = {};
const findKaprekar = (i, _min, _max, prev, step) => {
let diff = _max-_min;
{
description = "flake empty env";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; # unstable Nixpkgs
outputs =
{ self, ... }@inputs:
let
supportedSystems = [
@cemdrk
cemdrk / flake.nix
Created November 20, 2025 14:53
Flake empty template
{
description = "flake empty env";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; # unstable Nixpkgs
outputs =
{ self, ... }@inputs:
let
supportedSystems = [
services:
browsercontrol:
build: .
environment:
- TZ=Europe/Istanbul
- CHROME_CLI=--remote-debugging-port=9222
- MCP_CDP_ENDPOINT=http://127.0.0.1:9222
# - MCP_CDP_ENDPOINT=http://host.docker.internal:9222 # local browser access
ports:
- "127.0.0.1:3000:3000" # HTTP Chromium desktop gui
FROM lscr.io/linuxserver/chromium:latest
USER root
COPY ./conf/autostart /defaults/autostart
RUN chmod +x /defaults/autostart
# install node 22 (current LTS)
RUN curl -sL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get update && apt-get install -y nodejs
@cemdrk
cemdrk / promiseque.js
Created April 24, 2025 13:15
Promise Que in JS
class PromiseQue {
constructor(concurrentCount = 5) {
this.todo = [];
this.running = [];
this.maxTask = concurrentCount;
}
runNext(){
return ((this.running.length < this.maxTask) && this.todo.length);
}
@cemdrk
cemdrk / nodejsdag_template.py
Last active August 5, 2024 08:58
Airflow Dag To Run Node JS Jobs
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
from airflow.utils.dates import days_ago
from airflow.models import Variable
from airflow.decorators import dag, task
default_args = {
"owner": "me",
"start_date": days_ago(1),
}
@cemdrk
cemdrk / Makefile
Last active October 14, 2023 07:39
Pass argument to Makefile Goal
.PHONY: up down shell
down:
docker compose down --rmi local --volumes --remove-orphans
up:
docker compose up $(filter-out $@,$(MAKECMDGOALS))
shell:
docker compose exec app bash