Skip to content

Instantly share code, notes, and snippets.

View abdivasiyev's full-sized avatar
🥷
golang ninja

Asliddinbek Azizovich abdivasiyev

🥷
golang ninja
View GitHub Profile
@abdivasiyev
abdivasiyev / subdomains.sh
Created November 6, 2024 05:00
Find subdomains using crt.sh
#!/bin/bash
# check curl exists
if ! command -v curl >/dev/null 2>&1
then
sudo apt install -y curl
fi
# check pup exists
if ! command -v pup >/dev/null 2>&1
@abdivasiyev
abdivasiyev / decoder.go
Created August 3, 2024 12:29
Decode everything using only one package
package decoder
import (
"encoding/json"
"io"
"net/http"
"github.com/gorilla/schema"
)
@abdivasiyev
abdivasiyev / workerpool.go
Last active May 22, 2024 21:16
Goroutine management by using workerpool pattern
package workerpool
type Work[T any] func(workerID int, result chan<- T) error
type Pool[T any] interface {
Add(w Work[T])
Shutdown()
Result() <-chan T
}
@abdivasiyev
abdivasiyev / generic_setter.go
Created May 1, 2024 18:32
Set value by calling functions in generics
package main
import "fmt"
type Setter[V any] interface {
Set(value V)
}
type Getter[V any] interface {
Get() V
@abdivasiyev
abdivasiyev / optional.go
Created May 1, 2024 17:39
Optional arguments implementation
// Usage:
//
// SomeFn(1, "test", WithArg1("optional 1"), WithArg2(true))
//
package some_pkg
type Option func(*option)
type option struct {
arg1 string
@abdivasiyev
abdivasiyev / repository.go
Last active April 21, 2024 16:15
Repository for dynamic insertion
package repository
import (
"fmt"
"strings"
)
type Row interface {
SetPos(pos int)
Values() []any
package http
import (
"context"
"encoding/json"
"mime/multipart"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/google/uuid"
@abdivasiyev
abdivasiyev / default.nix
Created February 3, 2024 18:37
default nix configuration
with import <nixpkgs> {}; rec {
helloNixEnv = stdenv.mkDerivation {
name = "hello-nix-env";
buildInputs = [ go ];
};
}
@abdivasiyev
abdivasiyev / ternary.go
Created June 28, 2023 14:40
Simple ternary operator implementation in Go with generics
package ternary
type operatorIf[T comparable] struct {
condition bool
value T
elseIf *operatorIf[T]
elseValue T
}
func If[T comparable](condition bool) *operatorIf[T] {
@abdivasiyev
abdivasiyev / nerd_fonts.sh
Created December 24, 2022 20:16 — forked from davidteren/nerd_fonts.md
Install Nerd Fonts via Homebrew [updated & fixed]
# Nerd Fonts for your IDE
# https://www.nerdfonts.com/font-downloads
brew tap homebrew/cask-fonts && brew install --cask font-3270-nerd-font
brew tap homebrew/cask-fonts && brew install --cask font-fira-mono-nerd-font
brew tap homebrew/cask-fonts && brew install --cask font-inconsolata-go-nerd-font
brew tap homebrew/cask-fonts && brew install --cask font-inconsolata-lgc-nerd-font
brew tap homebrew/cask-fonts && brew install --cask font-inconsolata-nerd-font
brew tap homebrew/cask-fonts && brew install --cask font-monofur-nerd-font
brew tap homebrew/cask-fonts && brew install --cask font-overpass-nerd-font