context

go
package main

import (
	"context"
	"log"
	"net/http"

Graceful HTTP Server Shutdown in Go with SIGINT and Context Cancellation

go http graceful-shutdown
by codesnips 2 tabs
typescript
import { useEffect, useState } from 'react';

export function useLocalStorage<T>(
  key: string,
  initialValue: T
): [T, (value: T) => void] {

Persisting a Dark-Mode Theme Toggle with a React ThemeProvider and localStorage

react context hooks
by codesnips 4 tabs
javascript
import { useState, useEffect, useCallback } from 'react';

export function useLocalStorage(key, initialValue) {
  const readValue = useCallback(() => {
    if (typeof window === 'undefined') return initialValue;
    try {

Persist a React Shopping Cart to localStorage with a Context Provider

javascript react context
by codesnips 3 tabs
python
from django.conf import settings
from datetime import datetime


def site_settings(request):
    """Add site-wide settings to template context."""

Django context processors for global template variables

django python templates
by Priya Sharma 2 tabs
go
package health

import (
	"context"
	"sync"
	"time"

Concurrent Readiness Health Check Endpoint in Go with Timeouts

go health-check readiness
by codesnips 3 tabs
go
package logctx

import (
	"context"
	"log/slog"
)

Request-Scoped Structured Logging with slog and Context in Go

go logging slog
by codesnips 3 tabs
go
package limit

import (
  "context"

  "golang.org/x/sync/semaphore"

Concurrency limiting with a context-aware semaphore

go concurrency context
by Leah Thompson 1 tab
go
package fetch

import (
	"context"
	"net/http"

Bounded Fan-Out With Worker Pool, errgroup, and Result Collection in Go

go concurrency goroutines
by codesnips 3 tabs