Skip to content

Instantly share code, notes, and snippets.

View rednafi's full-sized avatar
🏠
Working from home

Redowan Delowar rednafi

🏠
Working from home
View GitHub Profile
@rednafi
rednafi / dysfunc.go
Last active March 6, 2024 18:20
Dysfunctional option pattern in Go
package src
import (
"testing"
)
// Apply functional options pattern
type config struct {
// Required
foo, bar string
@rednafi
rednafi / main.go
Last active February 23, 2024 11:58
Anemic stack traces in Go. Read the blog on https://rednafi.com/go/anemic_stack_traces/
package main
import (
"fmt"
"io"
"os"
"runtime"
"strings"
)
@rednafi
rednafi / main.go
Last active September 26, 2023 17:34
Dummy load balancer in a single Go script. Here's the full explanation: https://rednafi.com/go/dummy_load_balancer
/*
cc Redowan Delowar (rednafi.com)
+----------------------------------------+
| Load Balancer (8080) |
| +----------------------------------+ |
| | | |
| | Request from Client | |
| | | |
| +-----------------|----------------+ |
@rednafi
rednafi / getUrls.md
Last active May 20, 2023 07:10
Submit URLs for indexing via googleapis
@rednafi
rednafi / src.js
Last active December 22, 2022 20:25
Get provider attributes from GET orders/ endpoint
// Must update the USERNAME, PASSWORD, and ORDER_CODE variables.
const USERNAME = "<your-username>"; // Has to be an email.
const PASSWORD = "<your-password>";
const ORDER_CODE = "KI00000133"; // Collect this from zapier panel.
const ROOT_DOMAIN = "https://kiyatec.dendisoftware.com";
// Cache the token.
let config = { token: "" };
async function getToken() {
This file has been truncated, but you can view the full file.
@rednafi
rednafi / docker-compose.yml
Last active July 24, 2022 21:54
Single node kafka, zookeeper, and schema-registry with docker compose 3
---
version: '3.9'
services:
zoo1:
image: confluentinc/cp-zookeeper:7.2.0
container_name: zoo1
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
@rednafi
rednafi / flipFlop.ts
Last active June 7, 2022 22:24
A simple two bit flip flop adder in TypeScript
type Bit = 0 | 1;
type Zero = Extract<Bit, 0>;
type One = Exclude<Bit, Zero>;
type Flip<T extends Bit> = T extends Zero ? One : Zero;
type Add<T extends Bit, U extends Bit> = T extends Zero
? U extends Zero
? Zero
@rednafi
rednafi / mutator.py
Created March 18, 2022 20:32
Mutate the fields of a dataclass by applying ad-hoc mutation callables.
from __future__ import annotations
import json
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Callable
class Mutator:
def __init_subclass__(
"""
Django settings for main project.
Generated by 'django-admin startproject' using Django 4.0.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/