Skip to content

Instantly share code, notes, and snippets.

@pcolazurdo
pcolazurdo / command.sh
Last active January 25, 2021 09:14
Deep Tracing - what happens in a container when you run ping 8.8.8.8
# Docker Analysis
docker run -it -d --rm python top
sudo nsenter -n -t $(pgrep top) perf trace --no-syscalls --event 'net:*' ping 8.8.8.8 -c2 >/tmp/output.txt
grep -oP "net:.+:dev=.+? " /tmp/output.txt
# Instance Analysis
sudo perf trace --no-syscalls --event 'net:*' ping 8.8.8.8 -c2 2>/tmp/output.txt
grep -oP "net:.+:dev=.+? " /tmp/output.txt
@pcolazurdo
pcolazurdo / .multirc
Last active January 15, 2021 12:51
Shell Utils
# Set default blocksize for ls, df, du
# from this: http://hints.macworld.com/comment.php?mode=view&cid=24491
# ------------------------------------------------------------
export BLOCKSIZE=1k
# some utils
trash () { command mv "$@" ~/.Trash ; }
alias lr='ls -R 2>/dev/null| grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
zipf () { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder
qfind () { command find . -name "$@" 2>/dev/null ; }
@pcolazurdo
pcolazurdo / bug_report.py
Created December 27, 2020 22:26
Bug Report Pandas #38736
#as Reported in: https://github.com/pandas-dev/pandas/issues/38736
import pandas as pd
from pandas import Timestamp
import matplotlib.pyplot as plt
a= {'Argentina': {Timestamp('2020-11-17 00:00:00'): 56.0},
'Brazil': {Timestamp('2020-11-17 00:00:00'): 103.0},
'Guatemala': {Timestamp('2020-11-17 00:00:00'): 99.0},
'Ireland': {Timestamp('2020-11-17 00:00:00'): 53.0},
@pcolazurdo
pcolazurdo / README.md
Last active December 4, 2020 10:30
Pygmentize your presentations

Pygments allows you to beautify pieces of code to show in outside your Editor. This gist compiles some best practices.

pygmentize is best installed in a virtualenv so you need to activate before using it.

pigsplit splits the file every 45 lines (general good size for PPT) and reate multiple PNGs - it doesn't respect langage-based line breaks so be careful

pigrtf will format in RTF format and copy to the clipboard (on MAC) to paste directly into PowerPoint or Word

pig will create a png with some safe defauls

pygmentize -N file will try to guess the language formatter supported for this file

@pcolazurdo
pcolazurdo / find_names.sh
Created November 21, 2020 23:19
Use AWS Comprehend to find Names references in a Bible book
i=0 cat Revelation.json.txt| while read a
do
aws comprehend detect-entities --language-code "en" --text $a >/tmp/rev${i}.json
((i=i+1))
done
cat /tmp/*.json | jq '.Entities[].Text' | sort -u | cut -d\" -f2 | grep -e '^[A-Z].*'
@pcolazurdo
pcolazurdo / remove blank lines regex.md
Created October 26, 2020 17:28 — forked from fomightez/remove blank lines regex.md
remove all blank lines using regular expressions
@pcolazurdo
pcolazurdo / eks_cli_update.sh
Last active August 28, 2020 14:14
Install and/or update EKS commands automatically
# This script will update the key CLI tools for managing EKS
eksctl version
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
kubectl version -o json | jq -r '.clientVersion.major + "." + .clientVersion.minor'
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
@pcolazurdo
pcolazurdo / CleanJupiterNotebooksToGit.sh
Last active August 27, 2020 16:17
Snippet to add a filter action to git to upload a clean notebook (no outputs) to the repo
echo '[filter "strip-notebook-output"]' >>.git/config
echo ' clean = "jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to=notebook --stdin --stdout --log-level=ERROR"' >>.git/config
echo \*.ipynb filter=strip-notebook-output >.gitattributes
@pcolazurdo
pcolazurdo / readme.MD
Last active November 23, 2023 21:20
Home Raspberry PI setup
@pcolazurdo
pcolazurdo / needs_restart.sh
Created June 23, 2020 13:18
Check if restart is needed in Amazon Linux
needs-restarting -r ; echo $?
# Core libraries or services have been updated:
# openssl-libs -> 1:1.0.1e-60.el7_3.1
# systemd -> 219-30.el7_3.9
# Reboot is required to ensure that your system benefits from these updates.
# More information:
# https://access.redhat.com/solutions/27943
# 1