Skip to content

Instantly share code, notes, and snippets.

@mdtanrikulu
mdtanrikulu / distroless.md
Last active May 27, 2026 18:51
distroless 78mb nodejs@22 docker build

Dockerfile

# syntax=docker/dockerfile:1.7

# ---- builder ----
FROM node:22-slim AS builder
WORKDIR /app

# Install deps first so this layer caches when only source changes
COPY package*.json ./
@mdtanrikulu
mdtanrikulu / block_malicious.txt
Last active February 21, 2026 16:47
block daily reported malicious ip addresses with scheduled calls (source of ip feed: https://github.com/stamparm/ipsum)
# install ipset
apt update && apt install -y ipset
# create the script
cat << 'EOF' > /usr/local/bin/update-blocklist.sh
#!/bin/bash
ipset create blocklist hash:ip hashsize 4096 -exist
ipset flush blocklist
@mdtanrikulu
mdtanrikulu / main.js
Last active February 10, 2025 17:09
Firefox unregister all service workers
// Type `about:debugging` into search bar hit enter
// Open developer console, execute following
for (let k of document.getElementsByClassName("qa-unregister-button")) k.click()
@mdtanrikulu
mdtanrikulu / index.html
Created September 7, 2024 13:13
minimal raw html, viem ens starter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>blah</title>
</head>
<body>
<p>I'm the content</p>
</body>
<script type="module">

ENS Prize: $3000

The Ethereum Name Service is a decentralised naming protocol for the new internet. If your project requires users to input ETH address or display ETH address, consider integrate with ENS so that you can show human readable names.

1. Integrate with ENS (Pool prize of $1000)

Any type of ENS integration is eligible for this prize (NOTE: We do not accept projects simply hardcoding ENS names).

Please follow the quick start guide to learn how to integrate ENS names programatically.

@mdtanrikulu
mdtanrikulu / dnsWireFormat.js
Created June 21, 2023 15:23
dns wire format conversion
function dnsWireFormat(domain, ttl, type, cls, address) {
let labels = domain.split(".");
let output = "";
for (let label of labels) {
output += label.length.toString(16).padStart(2, '0');
for (let char of label) {
output += char.charCodeAt(0).toString(16);
}
}
import { ENS } from "@ensdomains/ensjs"; // 3.0.0-alpha.39
import { providers } from "ethers"; // 5.7.2
const client = new ENS();
const provider = new providers.Web3Provider(window.ethereum, "goerli");
async function setENSAvatar() {
await client.setProvider(provider);
@mdtanrikulu
mdtanrikulu / daemon.js
Created May 12, 2022 09:57 — forked from kumatch/daemon.js
Node.js daemon example
var fs = require('fs');
var INTERVAL = 1000;
var cycle_stop = false;
var daemon = false;
var timer;
process.argv.forEach(function (arg) {
if (arg === '-d') daemon = true;
@mdtanrikulu
mdtanrikulu / config-overrides.js
Created May 5, 2022 14:39 — forked from skycloud112/config-overrides.js
react-app-rewired config-overrides.js for referencing folders in adjacent folder https://github.com/facebook/create-react-app/issues/9127
const { override, addWebpackAlias } = require('customize-cra');
const path = require('path');
const overridePath = (webpackConfig) => {
const oneOfRule = webpackConfig.module.rules.find((rule) => rule.oneOf);
if (oneOfRule) {
const tsxRule = oneOfRule.oneOf.find(
(rule) => rule.test && rule.test.toString().includes('tsx')
);
import urllib.request
import re
EMOJI_TEST_FILENAME = "emoji-test.txt"
EMOJI_DATA_URL = "https://unicode.org/Public/emoji/14.0/emoji-test.txt"
def download_latest_emoji_test_data() :
response = urllib.request.urlopen(EMOJI_DATA_URL)
emoji_test_file = response.read()
with open(EMOJI_TEST_FILENAME, "wb") as tmp_file: