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
for {
// Build the paginated query
query := session.Query("SELECT id, name FROM users").PageSize(pageSize).PageState(pageState)
iter := query.Iter()
var id gocql.UUID
var name string
for iter.Scan(&id, &name) {
fmt.Printf("User: %s - %s\n", id, name)
@rednafi
rednafi / errs.go
Created February 23, 2025 23:31
Some go err handling
package errs
import (
"fmt"
"runtime"
)
// Error represents a custom error with function name, line number, and message.
type Error struct {
lineno int
@rednafi
rednafi / worklog.md
Last active August 20, 2024 07:14
Generate a simple worklog.

What

The following script will generate a simple markdown worklog in the format listed below. It correctly handles the partial weeks at the beginning and the end of the year.

# Worklog

## Week 1 [2025-01-01 - 2025-01-03]
@rednafi
rednafi / __init__.py
Last active February 8, 2025 03:39
Log context propagation in Python ASGI apps. Details here: https://rednafi.com/python/log_context_propagation/
from svc import log # noqa
@rednafi
rednafi / __init__.py
Created August 6, 2024 19:07
Log context propagation in Python ASGI apps.
from svc import log # noqa
@rednafi
rednafi / dysfunc.go
Last active October 30, 2024 07:31
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() {