Skip to content

Instantly share code, notes, and snippets.

View manju4ever's full-sized avatar
🙏
Namaste !

Manjunath D manju4ever

🙏
Namaste !
View GitHub Profile
@manju4ever
manju4ever / vault_client.go
Created July 13, 2023 18:27
Vault Client with Auto Login and Renewal
package vault_client
import (
"context"
"log"
"time"
"github.com/hashicorp/vault/api"
)
@manju4ever
manju4ever / batch_processor.go
Created December 8, 2022 19:05
Batch Processor in Go
// BatchProcessor processes a collection of items in batches using goroutines.
func BatchProcessor(items []int, processFunc func([]int) int, batchSize int) <-chan int {
var wg sync.WaitGroup
// Create a channel with a buffer size of the batch size.
ch := make(chan []int, batchSize)
// Create a channel to receive the results returned by the Process function.
results := make(chan int)
@manju4ever
manju4ever / ctx_timeout.go
Created November 19, 2022 20:31
Context Timeout Example
package main
import (
"context"
"fmt"
"time"
)
func WorkHardOne(ctx context.Context, name string, res *chan string) {
for sec := 0; sec < 3; sec++ {
@manju4ever
manju4ever / noti_data_model.sql
Last active November 13, 2022 14:13
Simple Notifications Data Model
-- DDL Statement --
create table users(
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
full_name varchar(100)
);
insert into users(full_name)
VALUES
('Manju Desappa'),
@manju4ever
manju4ever / wellford.go
Last active July 10, 2022 11:35
Wellford 1 pass method of calculating variance in Go
package main
import (
"fmt"
"math"
)
func main() {
// Find the definition after main
tracker := WellfordVariance{}
@manju4ever
manju4ever / ldap_with_docker.sh
Created September 9, 2020 20:55
Create LDAP Server with phpLDAPAdmin with docker
#!/bin/bash -e
docker run --name ldap-service --hostname ldap-service -p 389:389 -p 636:636 --detach osixia/openldap:1.1.8
docker run --name phpldapadmin-service --hostname phpldapadmin-service -p 6443:443 --link ldap-service:ldap-host --env PHPLDAPADMIN_LDAP_HOSTS=ldap-host --detach osixia/phpldapadmin:0.9.0
PHPLDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" phpldapadmin-service)
echo "Go to: https://$PHPLDAP_IP"
echo "Login DN: cn=admin,dc=example,dc=org"
echo "Password: admin"
@manju4ever
manju4ever / reposy.py
Last active September 1, 2020 16:28
Find authors in commit(s) in the time range (GitHub)
#!/usr/bin/python
import requests
import sys
import json
GITHUB_ENDPOINT = "https://api.github.com"
GIHUB_API_KEY = "84b84ed3699ff6d54c11171edc2f57fd25a9a71f"
# Print helper for the script
print("\n||| Some Github Shit |||\n")
@manju4ever
manju4ever / read_csv.go
Last active October 26, 2021 12:37
Read CSV From Go
package main
import (
"fmt"
"os"
"github.com/gocarina/gocsv"
)
/* users.csv
@manju4ever
manju4ever / bst.go
Last active August 12, 2020 20:39
Binary Search Tree in GO
package main
import "fmt"
const DEBUG bool = true
type Leaf struct {
value int
left *Leaf
right *Leaf
@manju4ever
manju4ever / dining.go
Created August 6, 2020 23:49
coursera - dining philosophers problem
package main
import (
"fmt"
"sync"
)
type Fork struct{ id int }
type Philo struct {