context

typescript
import React, { createContext, useContext, useState, ReactNode } from 'react'

type ToastType = 'success' | 'error' | 'info' | 'warning'

interface Toast {
  id: string

Toast notifications system

react notifications context
by Maya Patel 1 tab
typescript
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react'
import { User } from '@/types'
import api from '@/services/api'

interface AuthContextType {
  user: User | null

Context API for global UI state

react context hooks
by Maya Patel 1 tab
go
        package api

        import (
          "context"
          "crypto/rand"
          "encoding/hex"

HTTP handler with timeouts, request IDs, and context cancellation

go http context
by Leah Thompson 2 tabs
go
package workpool

import (
	"context"
	"sync"
)

Bounded Worker Pool Processing Jobs from a Buffered Channel in Go

go concurrency worker-pool
by codesnips 3 tabs
go
package service

import (
  "context"

  "golang.org/x/sync/errgroup"

Fan-out with errgroup and shared cancellation

go concurrency context
by Leah Thompson 1 tab
go
package pipeline

import "context"

func generate(ctx context.Context, nums ...int) <-chan int {
	out := make(chan int)

Fan-Out/Fan-In Pipeline With Channels and Context Cancellation in Go

go concurrency channels
by codesnips 3 tabs
go
package feed

import "time"

type Event struct {
	ID        string    `json:"id"`

Stream and Decode Newline-Delimited JSON (NDJSON) from an HTTP Response Body in Go

go ndjson streaming
by codesnips 3 tabs
typescript
export const FLAG_REGISTRY = {
  newDashboard: {
    default: false as boolean,
    description: 'Renders the redesigned dashboard shell',
  },
  maxUploadMb: {

Feature flags with a typed registry

typescript feature-flags react
by codesnips 3 tabs
go
package export

import (
	"encoding/csv"
	"log"
	"net/http"

Streaming Large CSV Exports in Go Without Buffering the Whole File

go http csv
by codesnips 3 tabs
go
package scheduler

import (
	"context"
	"log"
	"sync"

Graceful Cron-Style Scheduler in Go With Ticker and Context Cancellation

scheduler ticker context
by codesnips 3 tabs
typescript
import { createContext } from "react";

export type ToastVariant = "info" | "success" | "error";

export interface Toast {
  id: string;

Toast Notification Queue with a useToast Hook and Context Provider in React

react hooks context
by codesnips 4 tabs
go
package httpretry

import (
	"math/rand"
	"time"
)

Exponential Backoff With Full Jitter for Flaky HTTP Calls in Go

go http retry
by codesnips 3 tabs