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 | |
set -o errexit | |
force=false | |
reg_name='test' | |
reg_port='5001' | |
pos_args=() | |
while [ $# -gt 0 ]; do | |
arg="$1" |
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
# Hello, and welcome to makefile basics. | |
# | |
# You will learn why `make` is so great, and why, despite its "weird" syntax, | |
# it is actually a highly expressive, efficient, and powerful way to build | |
# programs. | |
# | |
# Once you're done here, go to | |
# http://www.gnu.org/software/make/manual/make.html | |
# to learn SOOOO much more. |
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 | |
##################################################### | |
# Name: Bash CheatSheet for Mac OSX | |
# | |
# A little overlook of the Bash basics | |
# | |
# Usage: | |
# | |
# Author: J. Le Coupanec | |
# Date: 2014/11/04 |
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 dataclasses | |
import selectors | |
import sys | |
import click | |
from colorama import Fore | |
@dataclasses.dataclass | |
class Command: |
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
# spinner, progress bar | |
https://stackoverflow.com/questions/238073/how-to-add-a-progress-bar-to-a-shell-script/238094#238094 | |
# kubectl get all api resources separated by comma | |
kubectl api-resources -o name | paste -sd, - | |
# gpg print signing keys | |
gpg --list-keys --with-colons | awk -F: '/^pub:/ { print $5 }' | |
# gpg generate and export |
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
from .logging import GunicornLogger, gunicorn_logconfig_dict, gunicorn_access_log_format | |
wsgi_app = "conf.wsgi" | |
bind = "0.0.0.0:8000" | |
workers = 2 | |
proxy_protocol = True | |
proxy_allow_ips = "*" |
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
from django.core.exceptions import ValidationError | |
from django.db import models | |
class ViolationFieldNameMixin: | |
""" | |
Mixin for BaseConstraint subclasses that builds custom | |
ValidationError message for the `violation_field_name`. | |
By this way we can bind the error to the field that caused it. | |
This is useful in ModelForms where we can display the error |
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
class CascadeOnRelatedChangeForeignKey(models.ForeignKey): | |
""" | |
ForeignKey that deletes all instances of the "related_name" | |
whenever the related instance changes. | |
For example while using this field in a token model, if the user | |
changes, all the tokens will be deleted. | |
""" | |
def contribute_to_related_class(self, cls, related): |
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
from functools import wraps | |
import django.http | |
import django.views.static | |
def no_cache_static(f): | |
@wraps(f) | |
def static(*a, **kw): | |
response: django.http.response.HttpResponse = f(*a, **kw) # type: |
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
getnode: | |
mkdir venvnode || true && wget -c https://nodejs.org/dist/v18.13.0/node-v18.13.0-linux-x64.tar.xz -O - | tar --strip-components=1 -xJ -C venvnode | |