Skip to content

Instantly share code, notes, and snippets.

View eevmanu's full-sized avatar
🎯
focused

Manuel eevmanu

🎯
focused
View GitHub Profile
@eevmanu
eevmanu / main_v1.py
Last active February 9, 2023 04:08
default way to start python module as script
#!/usr/bin/env python
# MIT License
# Copyright (c) 2022-present, Manuel Solorzano
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@eevmanu
eevmanu / custom_prompt.sh
Created February 27, 2022 22:14
custom prompt I don't use anymore because I prefer [startship](https://github.com/starship/starship)
function custom_prompt {
# https://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html
# \e == \033
# Select Graphic Rendition parameters
# 30–37 selected the foreground color
# 40–47 selected the background color
# prompt
FMT_RESET="\[\e[0m\]"
@eevmanu
eevmanu / setup.md
Last active May 14, 2022 06:48
virtualenv + virtualenvwrapper setup (from almost 8 years ago)

Virtualenv + Wirtualenvwrapper

Check python binary to use

$ export VIRTUALENVWRAPPER_PYTHON=/path/to/.../python
$ export VIRTUALENVWRAPPER_PYTHON=${HOME}/bin/python

Path where virtual environments will be created

@eevmanu
eevmanu / template.py
Created February 16, 2022 20:21
Template from Matt Harrison 🧵 talking about decorators in Python 🐍 👉 https://twitter.com/__mharrison__/status/1491080949647380481
import functools
def decorator(func_to_decorate):
@functools.wraps(func_to_decorate)
def wrapper(*args, **kwargs):
# 👉 BEFORE 👈 invocation
result = func_to_decorate(*args, **kwargs)
# 👉 AFTER 👈 invocation
return result
return wrapper
@eevmanu
eevmanu / age_counting.py
Last active February 1, 2023 16:37
age counting solution in python
# import requests
# r = requests.get("coderbyte.com/api/challenges/json/age-counting")
# d = r.json()
d = {
"data": "key=IAfpK, age=58, key=WNVdi, age=64, key=jp9zt, age=47, key=0Sr4C, age=68, key=CGEqo, age=76, ... key=cFCfU, age=5, key=J8an1, age=48, key=dkSlj, age=5"
}
l = d['data'].split(", ")
@eevmanu
eevmanu / script.py
Created November 2, 2021 23:42
understand algorithm which implement variant of levenshtein distance
# https://stackoverflow.com/q/41275345/
def dist(s1, s2):
cur = list(range(len(s2) + 1))
prev = [0] * (len(s2) + 1)
print(f"{cur=}")
print(f"{prev=}")
input()
for i in range(len(s1)):
cur, prev = prev, cur
cur[0] = i + 1
@eevmanu
eevmanu / ytvstats.py
Created October 25, 2021 23:27
Youtube video stats - get number of views, published date and duration of a video
#!/usr/bin/env python
import sys
import datetime
import argparse
import urllib.request
parser = argparse.ArgumentParser()
parser.add_argument('yt_video_url', type=str)
args = parser.parse_args()
@eevmanu
eevmanu / ytplstats.py
Created October 25, 2021 18:47
Youtube playlist stats scraper - get number of videos, total views and last time updated of a youtube playlist
#!/usr/bin/env python
import sys
import time
import json
import argparse
import locale
import datetime
import urllib.request
@eevmanu
eevmanu / commands.md
Created October 8, 2018 17:45
Instructions to write iso file in USB with only commands
  1. Insert USB

  2. Unmount it

# Check where is mounted
$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    1  15,7G  0 disk