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
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 |
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); |
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
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// 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
""" | |
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): |
" 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' |
import os | |
import time | |
import json | |
import socket | |
import logging | |
from slacker import Slacker, Error as SlackerError | |
class SlackChannelHandler(logging.Handler): |
This is a sample on how to stream the results of a large QuerySet into a CSV file using Django StreamingHttpResponse
class.
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. | |
""" | |
# --------------------------------------------------------------------------- |