Skip to content

Instantly share code, notes, and snippets.

View aldookware's full-sized avatar
:octocat:
Focusing

Aldo Okware aldookware

:octocat:
Focusing
View GitHub Profile
@aldookware
aldookware / conda_cheat
Created March 17, 2019 09:24 — forked from qheuristics/conda_cheat
conda cheatsheet
to create a new environment
conda create -n mynewenviron package1 package2 etc
conda create -n newenv --clone ~anaconda
to remove an environment
conda remove -n myenvirontoremove --all
always start with
@aldookware
aldookware / config.sh
Last active May 21, 2019 20:26
My terminal setup
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
orange=$(tput setaf 166);
purple=$(tput setaf 125);
yello=$(tput setaf 228);
green=$(tput setaf 28);
white=$(tput setaf 15);
reset=$(tput sgr0);
bold=$(tput bold);
@aldookware
aldookware / git-handy-commands.md
Last active August 20, 2020 08:03
git commands I use often

To initialize a new local repo.

$ git init

To add newly created files to staging

$ git add <file-name> or . for all new files.

To clone a repo

@aldookware
aldookware / sampleREADME.md
Created July 3, 2020 20:05 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@aldookware
aldookware / docker-cleanup-resources.md
Created August 20, 2020 07:27 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@aldookware
aldookware / 1.srp.py
Created June 21, 2021 18:42 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@aldookware
aldookware / .vimrc
Created August 6, 2021 15:53 — forked from miguelgrinberg/.vimrc
My .vimrc configuration for working in Python with vim
" plugins
let need_to_install_plugins = 0
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
let need_to_install_plugins = 1
endif
call plug#begin()
Plug 'tpope/vim-sensible'
@aldookware
aldookware / slack_handler.py
Created July 14, 2022 10:55 — forked from blakev/slack_handler.py
Python logging handler for publishing to a slack channel.
import os
import time
import json
import socket
import logging
from slacker import Slacker, Error as SlackerError
class SlackChannelHandler(logging.Handler):
@aldookware
aldookware / django_stream_queryset_to_csv.md
Created August 1, 2022 21:56 — forked from niuware/django_stream_queryset_to_csv.md
How to stream a CSV file from a large QuerySet using Django's StreamingHttpResponse

Stream a CSV file from a QuerySet using StreamingHttpResponse

This is a sample on how to stream the results of a large QuerySet into a CSV file using Django StreamingHttpResponse class.

  1. Add the CSVStream class in your project, for example a writers.py file:
import csv
from django.http import StreamingHttpResponse
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------