Skip to content

Instantly share code, notes, and snippets.

View ayharano's full-sized avatar

Alexandre Yukio Harano ayharano

View GitHub Profile
@ayharano
ayharano / deny_snippet.json
Created March 7, 2024 14:10 — forked from astuyve/deny_snippet.json
Deny cloudwatch permissions from Lambda to save money
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
@ayharano
ayharano / repl_example.py
Created September 15, 2023 13:30
List methods and attributes for a Python object instance
>>> class X:
... def __init__(self):
... self._a = None
... @property
... def a(self):
... return self._a
... @a.setter
... def a(self, val):
... self._a = val
...
@ayharano
ayharano / pyenv_only_latest.sh
Created June 13, 2023 13:28
pyenv versions
# install latest
for i in {7..11}; do V=$(pyenv install --list | grep "^[[:space:]]*3\.${i}\.[0-9]*" | tail -n 1 | sed 's,[[:space:]]*,,g'); echo "${V}"; yes n | pyenv install ${V}; echo; echo; done
# forced uninstall everything but latest
for i in {7..11}; do for V in $(pyenv versions | grep "^[[:space:]]*3\.${i}\.[0-9]*" | ghead -n -1 | sed 's,[[:space:]]*,,g'); do echo "${V}"; yes n | pyenv uninstall --force ${V}; done; echo; echo; done
@ayharano
ayharano / rj_campos_dos_goytacazes.py
Created December 31, 2022 16:57
rj_campos_dos_goytacazes.py with tentative end_date search
import calendar
import re
from datetime import date, timedelta
from string import punctuation
import dateparser
from scrapy import Request
from gazette.items import Gazette
from gazette.spiders.base import BaseGazetteSpider
@ayharano
ayharano / Changes are coming to pip-B4GQCBBsuNU.pt-BR.vtt
Last active October 1, 2020 19:51
A Portuguese translation to "Changes are coming to pip" video: https://www.youtube.com/watch?v=B4GQCBBsuNU
WEBVTT
Kind: captions
Language: pt-BR
00:00:00.000 --> 00:00:02.838
Uma grande mudança chega
a pip em outubro.
00:00:02.938 --> 00:00:07.362
Será um grande alicerce para tornar mais fácil
#!/usr/bin/env bash
INPUT_FILE="${1}"
TIME_START="${2}" # expected format HH:MM:SS
TIME_DURATION="${3}" # expected format HH:MM:SS
OUTPUT_FILE="${4}"
BASE="$(basename "${INPUT_FILE}")"
SHM_AUDIO_FILE="/dev/shm/audio_${BASE}"
SHM_VIDEO_FILE="/dev/shm/video_${BASE}"
@ayharano
ayharano / README.md
Created June 20, 2019 23:36 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@ayharano
ayharano / global_gitignore.bash
Last active December 18, 2018 16:28
Global gitignore populate from github
#!/usr/bin/env bash
URL_PREFIX='https://raw.githubusercontent.com/github/gitignore/master/'
URL_SUFFIX='.gitignore'
GLOBAL_IGNORE=~/.config/git/ignore
mkdir -p "${GLOBAL_IGNORE}" && rmdir "${GLOBAL_IGNORE}"
echo -n > "${GLOBAL_IGNORE}"
pushd /tmp
for IGNORE in {Linux,Windows,macOS,Vim,Emacs,JetBrains,SublimeText,VisualStudioCode,Ansible,VirtualEnv}; do
@ayharano
ayharano / grep.py
Created January 3, 2018 12:16
A grep-like copycat to match before and after matched lines, if requested.
#!/usr/bin/env python3
"""A `grep`-like copycat to match before and after matched lines.
"""
import re
def grep(pattern, string, before=0, after=0):
"""A grep-like copycat to match before and after matched lines,
if requested.
@ayharano
ayharano / gen-pass.py
Created November 16, 2017 01:08
Based on XKCD-style passphrase recipe from https://docs.python.org/3/library/secrets.html#recipes-and-best-practices. Python 3.6+
#!/usr/bin/python3
"""
Based on XKCD-style passphrase recipe from
https://docs.python.org/3/library/secrets.html#recipes-and-best-practices.
"""
import secrets
TRUNCATE = 64