Skip to content

Instantly share code, notes, and snippets.

View noamtamim's full-sized avatar

Noam Tamim noamtamim

View GitHub Profile
@noamtamim
noamtamim / dockers.md
Last active February 26, 2024 12:58
Dockers

Dockers

Redis

# Run
docker run -d --name redis -p 6379:6379 redis

# Stop
docker stop redis
@noamtamim
noamtamim / httprint.mjs
Last active January 3, 2024 15:13
Simple NodeJS http server that prints requests to stdout
// Usage:
// node httprint.mjs [PORT]
//
// The default port is 3000.
// Prints to stdout the request method, url, headers and body.
// Always returns 200 with an empty JSON object as the body and application/json as the content type.
import { createServer } from "node:http";
const port = process.argv[2] || 3000;
@noamtamim
noamtamim / kube.sh
Last active January 18, 2023 14:33
kubectl shortcuts
# Source this file to use
_podget() {
kubectl --namespace $NS get pods
}
_podnames() {
_podget | tail -n +2 | cut -d " " -f1
}
@noamtamim
noamtamim / redoc.html
Created July 5, 2021 21:52
redoc openapi template
<!DOCTYPE html>
<html>
<head>
<title>FastAPI - ReDoc</title>
<!-- needed for adaptive design -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
@noamtamim
noamtamim / get-aws-region.py
Created April 21, 2021 16:11
Get AWS Region (with cache)
def get_region_name():
from urllib import request, error
me = get_region_name
if hasattr(me, 'cache'):
return me.cache
try:
with request.urlopen("http://169.254.169.254/latest/meta-data/placement/region", timeout=1) as res:
me.cache = res.read().decode().strip()
@noamtamim
noamtamim / kinesis_reader.py
Created April 18, 2021 13:46
Kinesis Stream Reader
#!/usr/bin/env python3
import boto3
import time
from pprint import pprint
import json
import sys
client = boto3.client('kinesis')
@noamtamim
noamtamim / README.md
Last active April 12, 2021 14:22
macOS Terminal Tricks

Clipboard

pbpaste

This command writes (pastes) the content of the clipboard to stdout.

To use - copy (cmd-c) some text; then in the terminal type pbpaste and enter:

$ pbpaste
Hello, World!
Country WIFI 2G 3G 4G
AD 3500 148 2200 5300
AE 3500 95 490 690
AF 470 95 810 1400
AG 1100 148 2200 3200
AI 3500 200 2200 1400
AL 3500 132 2200 3200
AM 2000 132 970 2000
AO 1100 95 970 5300
AR 2000 115 970 2000
@noamtamim
noamtamim / aws-ip-range.sh
Last active December 1, 2022 14:38
AWS: IP ranges of API Gateway in us-east-1
#!/bin/bash
# Assuming jq (https://stedolan.github.io/jq/) and curl are installed.
# Show only the entries for region = us-east-1 and service = API_GATEWAY.
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq --raw-output '.prefixes[] | select(.region=="us-east-1" and .service=="API_GATEWAY") | .ip_prefix'
<< ////
Output (2022/12/01):
3.216.135.0/24
3.216.136.0/21
3.216.144.0/23