Useful helper commands, added to ~/.zshrc
# Open a bash shell in a named container
function ctr-bash() { docker exec -it $1 /bin/bash }
# Start streaming logs from the current time
alias ctr-logstream='docker logs -f --since $(date +%s)'
| # Install procpath tool (use "python3 -m site --user-base" to find installation directory if needed) | |
| > pip3 install --user procpath | |
| # Get the right version of sqlite | |
| > pip3 install --user apsw-wheels | |
| # Start recording metrics | |
| # i 5 - one datapoint every 5 seconds | |
| # r 120 - 120 datapoints (omit r for continuous capture, and use ctrl+c to stop) | |
| # d db.sqlite - a sqlite database |
| swagger: "2.0" | |
| info: | |
| version: '1' | |
| title: Test API | |
| description: Test Apiary | |
| host: api.test.com | |
| schemes: [https] | |
| consumes: | |
| - application/json | |
| produces: |
| # Search all files in current directory that were modified today for one of many strings (stored in /tmp/findStrings) | |
| find -daystart -mtime 0 -type f | xargs grep -lF -f /tmp/findStrings |
| tcpdump -i any -q -s 0 -W 5 -C 10 port <port> -w /tmp/tcp_capture | |
| # -i any (all interfaces) | |
| # -q (less protocol info) | |
| # -s 0 (capture the full packet) | |
| # -W 5 -C 10 (rotate between 5 10MB files) | |
| tcpdump -A -r /tmp/tcp_capture0 |
| cluster=mycluster | |
| service=myservice | |
| # Construct a copy of the current task definition, copying over the necessary attributes | |
| task_def_arn=$(aws ecs describe-services --cluster "$cluster" --service "$service" | jq -r '.services[0].deployments[0].taskDefinition') | |
| task_def=$(aws ecs describe-task-definition --task-definition "$task_def_arn" | jq '.taskDefinition | { family:.family, containerDefinitions:.containerDefinitions}') | |
| # Register as a new task and deploy it to the service. "wait" does not return until the service is stable (i.e. deployed). | |
| new_task_def_arn=$(aws ecs register-task-definition --cli-input-json "$task_def" | jq -r '.taskDefinition.taskDefinitionArn') | |
| aws ecs update-service --cluster "$cluster" --service "$service" --task-definition "$new_task_def_arn" |
| /** | |
| * Benchmark creation of a timestamp ([n] ms from now), and from it creating a unix timestamp and native Date object | |
| */ | |
| const Benchmark = require('benchmark'); | |
| const moment = require('moment'); | |
| const suite = new Benchmark.Suite; | |
| const msToAdd = 36000; | |
| const msInSec = 1000; |
Useful helper commands, added to ~/.zshrc
# Open a bash shell in a named container
function ctr-bash() { docker exec -it $1 /bin/bash }
# Start streaming logs from the current time
alias ctr-logstream='docker logs -f --since $(date +%s)'
| events {} | |
| http { | |
| include /etc/nginx/mime.types; | |
| gzip on; | |
| gzip_disable "msie6"; | |
| server { | |
| listen 8080; |