Skip to content

Instantly share code, notes, and snippets.

Avatar

Noam Tamim noamtamim

View GitHub Profile
@noamtamim
noamtamim / get-aws-region.py
Created Apr 21, 2021
Get AWS Region (with cache)
View get-aws-region.py
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 Apr 18, 2021
Kinesis Stream Reader
View kinesis_reader.py
#!/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 Apr 12, 2021
macOS Terminal Tricks
View README.md

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!
View bitrates.csv
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 Feb 25, 2020
AWS: IP ranges of API Gateway in us-east-1
View aws-ip-range.sh
#!/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:
3.216.135.0/24
3.216.136.0/21
3.216.144.0/23
@noamtamim
noamtamim / docker-compose.yml
Created Nov 29, 2019
Simple Prometheus Docker Compose setup
View docker-compose.yml
version: '3.7'
volumes:
prometheus_data: {}
# Setup:
# The app root directory contains an "etc" subdir with the config files required by all containers.
# Docker Compose creates an internal network for all containers so they can call each other by name.
services:
@noamtamim
noamtamim / README.md
Last active Mar 21, 2021
Markdown with PlantUML
View README.md

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.

@noamtamim
noamtamim / mp4-to-mp3.md
Created May 15, 2019
Convert mp4 files to mp3 (extract audio from mp4)
View mp4-to-mp3.md

Convert mp4 files to mp3 (extract audio from mp4)

Assuming a simple mp4 with one video stream and one audio stream.

for f in *.mp4
do 
  ffmpeg -i "$f" "${f%mp4}mp3"
done
View android-sdk-license.sh
#!/bin/bash
<< ////
The script creates 'licenses' under '$ANDROID_HOME' and creates a file which proves
that the SDK license was accepted by the user.
Please copy this to your own account/gist/server. Every time there's an updated license, update the file with the new
license hash.
Legally if you run this script (or your own version of it), it means YOU accepted the license - don't trust someone else.
The hashes below are supposed to be taken from $ANDROID_HOME/licenses/android-sdk-license on YOUR machine, after you