Skip to content

Instantly share code, notes, and snippets.

View juparave's full-sized avatar

Juan Pablo Ramírez juparave

View GitHub Profile
@juparave
juparave / fake_names.py
Last active January 28, 2021 06:53
Replace user display_name from randomuser.me
#!/usr/bin/env python
# pip install randomuser
import random
from randomuser import RandomUser
domains = [ "hotmail.com", "gmail.com", "infinitum.com", "mail.com" , "yahoo.com"]
def get_random_domain(domains):
return random.choice(domains)
@juparave
juparave / installation_guide.md
Last active August 22, 2020 19:20
New MacOS Installation
@juparave
juparave / corona.sh
Created June 17, 2020 13:48
Covid-19 Command Line Stats
#!/usr/bin/env bash
[ "$(stat -f "%Sm" -t '%y%m%d%H' ~/.cache/corona)" != "$(date '+%y%m%d%H')" ] &&
curl -s https://corona-stats.online/mexico > ~/.cache/corona
grep "Mexico" ~/.cache/corona |
sed -e 's/ //g ; s/║//g ; s/│/;/g' |
#cut -d';' -f 2,4
awk -F';' '{print $2 " 😷 " $3 " (" $4 ") ☠️ " $5 " (" $6 ")"}'
@juparave
juparave / superclean.sh
Created March 25, 2020 23:04
Superclean iOS workspace for flutter projects
#!/usr/bin/env bash
echo -e "\033[0;32m ** Removing ios/Podfile.lock \033[0;0m"
rm -rf ios/Pods ios/Podfile.lock
echo -e "\033[0;32m ** Removing ~/.pub-cache/hosted/pub.dartlang.org/ \033[0;0m"
rm -rf ~/.pub-cache/hosted/pub.dartlang.org/
echo -e "\033[0;32m ** Running flutter clean... \033[0;0m"
flutter clean
echo -e "\033[0;32m ** Removing ios/Flutter/Flutter.framework \033[0;0m"
rm -rf ios/Flutter/Flutter.framework
@juparave
juparave / update_db_charset.sh
Created March 6, 2020 22:35
convert a utf8/latin1 mysql database charset to utf8mb4 with utf8mb4_general_ci collate
#!/usr/bin/env bash
usage() {
echo -e ""
echo -e "./update_db_charsetr.sh"
echo -e ""
echo -e "convert a utf8/latin1 mysql database charset to utf8mb4 with utf8mb4_general_ci collate"
echo -e "\t-h --help"
echo -e "\t-f=db_file.sql to convert (mysqldump --opt)"
echo -e ""
@juparave
juparave / numero_a_letra.py
Last active March 6, 2020 18:45
Convierte un número a su representación con palabras
# -*- coding: utf-8 -*-
UNIDADES = (
'',
'UN ',
'DOS ',
'TRES ',
'CUATRO ',
'CINCO ',
'SEIS ',
@juparave
juparave / setenv.sh
Created March 2, 2020 15:22
Look for python virtual environment from local folder
#!/usr/bin/env python
# setenv.sh
# Look for python virtual environment and print `activate` path
import os
ignore = ['.git', 'node-modules']
# get immediate child directories
subs = next(os.walk('.'))[1]
@juparave
juparave / httpd.conf_spiders
Last active August 5, 2019 01:24 — forked from gplv2/httpd.conf_spiders
Apache bot control system, filter out spiders good and bad crawlers/ webspiders when they hit your server hard, like googlebot , bingbot. Block all them for specific places marked in the robots.txt to not visit (yet they do sometimes).
# To relieve servers
##Imagine a robots.txt file like this (Google understands this format):
#User-agent: *
#Disallow: /detailed
#Disallow: /?action=detailed
#Disallow: /*/detailed
#Crawl-delay: 20
##
@juparave
juparave / short_uuid_gen.py
Last active February 24, 2022 04:19
A UUID generator ala youtube id
# -*- coding: utf-8 -*-
"""The application's uuid model
.. Usage:
# on declarative table definition
user_id = Column(CHAR(12), primary_key=True, nullable=False, default=short_uuid_gen)
# on sortable things
order_id = Column(CHAR(12), primary_key=True, nullable=False, default=ulid_gen)
"""
import os
@juparave
juparave / clean.sh
Last active January 2, 2019 03:18 — forked from Iman/clean.sh
Free up disk space on Ubuntu - clean log, cache, archive packages/apt archives, orphaned packages, old kernel and remove the trash
#!/bin/sh
#Check the Drive Space Used by Cached Files
du -sh /var/cache/apt/archives
#Clean all the log file
#for logs in `find /var/log -type f`; do > $logs; done
logs=`find /var/log -type f`
for i in $logs