Skip to content

Instantly share code, notes, and snippets.

View gigenthomas's full-sized avatar
🎯
Focusing

Gigen Thomas gigenthomas

🎯
Focusing
View GitHub Profile
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"syscall"
package main
import (
"fmt"
"time"
)
// Worker function that listens for a job on its own channel
func worker(id int, jobChannel chan int) {
for job := range jobChannel {
@gigenthomas
gigenthomas / go-constants.go
Last active March 23, 2025 06:12
go-constants.go
const (
Unknown nodeType = iota
Sync
Async
Fanout
)
func getNodeType(node Node) nodeType {
if _, isSync := node.(SyncNode); isSync {
return Sync
package main
import "fmt"
// Define a function type called 'mathOperation'
type mathOperation func(int, int) int
// Define some functions that match the 'mathOperation' type
func add(a, b int) int {
return a + b
Worker Pool : Distribute tasks efficiently among multiple goroutines
Fan-out, Fan-in Multiple workers process tasks; results are collected
Pipeline Process data through multiple stages
Pub-Sub One publisher sends messages to multiple subscribers
Rate Limiting Control request rate to prevent overload
Timeout Prevent indefinite blocking
package main
import (
"fmt"
"time"
)
// worker function that runs in a separate goroutine
func worker(id int, ch chan string) {
time.Sleep(time.Second) // Simulate some work
package main
import (
"fmt"
"sync"
)
// Define a struct for map operations
type MapOperation struct {
Key int
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"sync"
"syscall"
@gigenthomas
gigenthomas / react.md
Last active July 23, 2023 23:41
React

React Basics

The useEffect Hook is React’s main approach to handling Side Effects. Side Effects refer to anything that affects something outside the scope of the function being executed.

React Layout