Code Explainers
Code explainers tagged #resource-cleanup
python
from contextlib import contextmanager from typing import Iterator import psycopg2
Streaming Postgres rows with a server-side cursor
generators
context-managers
database-streaming
Intermediate
7 steps
ruby
class Admin::OrdersExportController < Admin::BaseController include ActionController::Live def show
Streaming a CSV export in Rails
streaming
csv-export
batching
Advanced
8 steps
typescript
import { Injectable, Logger, OnApplicationShutdown } from '@nestjs/common'; import { InjectRedis } from '@nestjs-modules/ioredis'; import Redis from 'ioredis'; import { DataSource } from 'typeorm';
Graceful shutdown hooks in NestJS
graceful-shutdown
lifecycle-hooks
dependency-injection
Intermediate
7 steps
java
@RestController @RequestMapping("/api/notifications") public class NotificationStreamController {
Server-Sent Events per user in Spring
server-sent-events
concurrency
event-driven
Advanced
8 steps
python
import time from contextlib import contextmanager
A reusable timing context manager in Python
context-manager
timing
generators
Intermediate
5 steps
php
<?php declare(strict_types=1);
Streaming file lines with a PHP generator
generators
lazy-evaluation
file-io
Intermediate
7 steps
go
package main import ( "bufio"
Counting matching lines in Go with bufio
file-io
buffered-scanning
error-handling
Intermediate
4 steps