Skip to content

Instantly share code, notes, and snippets.

View afr-dt's full-sized avatar
:octocat:

Alejandro Flores afr-dt

:octocat:
View GitHub Profile
@afr-dt
afr-dt / init.vim
Last active November 1, 2019 03:22
My Neovim setup 👨🏽‍💻😃
call plug#begin()
" syntax check
Plug 'w0rp/ale'
" Autocomplete
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
" Formater
@afr-dt
afr-dt / iterm2-solarized.md
Created October 27, 2019 07:06 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@afr-dt
afr-dt / README-Template.md
Created March 30, 2020 20:33 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@afr-dt
afr-dt / pandas_dataframe_difference.py
Created June 8, 2020 15:57 — forked from toddbirchard/pandas_dataframe_difference.py
Helper function to compare two DataFrames and find rows which are unique or shared.
def dataframe_difference(df1, df2, which=None):
"""Find rows which are different."""
comparison_df = df1.merge(df2,
indicator=True,
how='outer')
if which is None:
diff_df = comparison_df[comparison_df['_merge'] != 'both']
else:
diff_df = comparison_df[comparison_df['_merge'] == which]
diff_df.to_csv('data/diff.csv')
@afr-dt
afr-dt / validate_phone.py
Created January 8, 2021 20:01
Validate phone with + symbol
import re
def validate_phone(phone):
if re.match(r'^\+1?\d{9,15}$', phone):
print(f'{phone} is valid number')
else:
print(f'{phone} is not valid')
@afr-dt
afr-dt / clean_empty_or_none.py
Created January 18, 2021 07:14
Clean empty or None values from dict
def clean_empty_or_none(d):
"""
Clean empty or None values from dict
"""
clean = {}
for k, v in d.items():
if isinstance(v, dict):
nested = clean_empty_or_none(v)
if len(nested.keys()) > 0:
clean[k] = nested
@afr-dt
afr-dt / requests_logging.py
Last active January 27, 2021 00:16
Python requests logging
import logging
from http.client import HTTPConnection
def httpclient_logging():
HTTPConnection.debuglevel = 1
requests_log = logging.getLogger("urllib3")
requests_log.setLevel(logging.WARNING)
@afr-dt
afr-dt / s3_presigned_image_url.py
Last active June 4, 2021 18:22
Generate a presigned URL from S3 image
import boto3
import logging
from botocore.exceptions import ClientError
class S3Imgs:
def __init__(self, aws_access_key_id, aws_secret_access_key, region_name):
"""S3 secrests config.
@afr-dt
afr-dt / accessing_dict_keys_like_an_attribute.py
Created November 25, 2021 21:47
accessing_dict_keys_like_an_attribute
class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self
config = AttrDict()
# Example
config['name']
@afr-dt
afr-dt / iterm2.md
Created November 26, 2021 16:59 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)