SaveSnippets
Community
Pricing
Sign In
Get Started
Community
Public Snippets
7
Code shared by the SaveSnippets community — browse, copy, and get inspired.
All Languages
Bash
Go
HTML
Java
JavaScript
Kotlin
PHP
Python
Rust
SQL
TypeScript
#network
Clear
Tags
#php
#kotlin
#bash
#go
#sql
#rust
#typescript
#html
#java
#python
#files
#utils
#strings
#http
#concurrency
#async
#json
#arrays
#security
#types
#crypto
#database
#dates
#format
Bash
Check If Port Is Open
Several ways to probe a remote port: nc (most portable), bash's /dev/tcp pseudo-device (zero deps), or curl. Pick by what's available.
#bash
#network
#port
#tcp
#health-check
Bash
Wait For Service With Timeout
Block until a TCP port accepts connections, with a deadline. Used everywhere in docker-compose entrypoints — wait for the DB to be ready before running the app.
#bash
#network
#wait
#docker
#health-check
Bash
SSH to Multiple Hosts in Parallel
Run the same command on a fleet of hosts. Three patterns: serial loop (simplest), GNU parallel (fastest), pssh (purpose-built).
#bash
#network
#ssh
#parallel
Bash
Get Public IP Address
Several free services return your public IP as plain text. Useful when scripts running behind NAT need to know what address the outside world sees.
#bash
#network
#ip
#curl
Bash
DNS Lookup (dig / host / getent)
Three options depending on what's installed: dig is most flexible, host is concise, getent uses the system's resolver and respects /etc/hosts.
#bash
#network
#dns
#dig
#host
PHP
Find Open TCP Port
Probe whether a remote host:port accepts connections, with a configurable timeout. Useful for quick health checks in deploy scripts.
#php
#network
#tcp
#health-check
Bash
List Listening Ports
`ss` is the modern netstat — faster, more readable, ships everywhere. Show only listening TCP ports with their owning process.
#bash
#network
#ss
#netstat
#ports