This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# > python3.11 -m venv .venv | |
# > source .venv/bin/activate | |
# > pip install ytmusicapi | |
# Run the following command to generate the auth token file (oauth.json): | |
# > ytmusicapi oauth | |
import logging | |
import ytmusicapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function venvnow() { | |
GREEN="\033[0;32m" | |
NC='\033[0m' # No Color | |
venv_default_root=~/dev/venvs | |
function try_dotvenv { | |
if [ -d '.venv' ]; then | |
echo -e " - found ${GREEN}.venv${NC} directory" | |
if [ -f ".venv/bin/activate" ]; then | |
source .venv/bin/activate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# ------------------------------------------------------- | |
# Place this somewhere in your path, and make it executable. | |
# Inside any venv, run `outdated.py path/to/requirements.txt` | |
# By default it will attempt to read ~/requirements.txt | |
# | |
# $> cd project && source .venv/bin/activate | |
# $> outdated.py requirements/common.txt | |
# >> Reading requirements (/home/user/project/requirements/common.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from inspect import isfunction, isclass | |
from typing import Union, List, Callable | |
from django.urls import path as _django_path, include, register_converter | |
from rest_framework.routers import SimpleRouter | |
from rest_framework.views import APIView | |
from rest_framework.viewsets import ViewSetMixin | |
TYP = Union[SimpleRouter, List, Callable, APIView, ViewSetMixin, str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# DESCRIPTION: | |
# | |
# Set the bash prompt according to: | |
# * the active virtualenv | |
# * the branch/status of the current git repository | |
# * the return value of the previous command | |
# * the fact you just came from Windows and are used to having newlines in | |
# your prompts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -* | |
# | |
# URL_EX : url helper to make dealing with patterns in urls easier, and prevent common issues | |
# - calls .as_view() on DRF APIView instances automatically | |
# - appends a leading ^ | |
# - appends a trailing $ the the call isn't an include() | |
# - add more shortcuts and patterns as required | |
# | |
# Examples: | |
# urlpatterns = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -* | |
from __future__ import print_function, absolute_import, unicode_literals | |
import six | |
from PIL import Image | |
from django.core.files.uploadedfile import SimpleUploadedFile | |
Image.DEBUG = True | |
with open("/Users/andrew/Desktop/sample.tiff", 'rb') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_dict_for_formdata(input_dict, array_separator="[{i}]"): | |
""" | |
Recursively flattens nested dict()s into a single level suitable for passing to a library | |
that makes multipart/form-data posts. | |
- nested dicts, tuples (treated like arrays), lists, list of objects, etc | |
{ | |
"owner": { | |
"name": {"first": "andy"}, | |
"favorite_color": ("blue", "green") | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
venvnow () | |
{ | |
venv_default_root=~/dev/venvs; | |
cur_dir=`pwd`; | |
if [ -d venv ]; then | |
echo " - found local ./venv/, using that"; | |
source ./venv/bin/activate; | |
return 0; | |
fi; | |
if [ -f '.venv' ]; then |