Skip to content

Instantly share code, notes, and snippets.

@defianceblack
defianceblack / keybase.md
Last active May 24, 2019 15:34
This gist confirms my identity within Keybase.

Keybase Proof

I hereby claim:

  • I am defianceblack on github.
  • I am defiance (https://keybase.io/defiance) on keybase.
  • I have a public key ASDplCCHGhLVF75kFORG0Ye51TMU3rDc81uHoEhsbWn7lwo

To claim this, I am signing this object:

@defianceblack
defianceblack / admin.py
Created September 6, 2019 12:14 — forked from padurets/admin.py
django rest api framework session auth example
from django.contrib import admin
from .models import User
admin.site.register([User])
"""
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.
"""
# ---------------------------------------------------------------------------
@defianceblack
defianceblack / final_models.py
Created February 17, 2020 09:26 — forked from lb-/final_models.py
Django + Wagtail - custom taxonomy model
"""Node model and Node admin interaction."""
from django import forms
from django.conf.urls import url
from django.contrib.admin.utils import quote, unquote
from django.core.exceptions import PermissionDenied
from django.core.validators import MinLengthValidator, RegexValidator
from django.db import models
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
@defianceblack
defianceblack / python_decorator_guide.md
Created February 17, 2020 10:02 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@defianceblack
defianceblack / README.md
Created February 17, 2020 10:14 — forked from genomics-geek/README.md
Setting up a Dockerized web application with Django REST APIs, ReactJS with Redux pattern, and Webpack Hot Reloading! Mouthful.

Guide on how to create and set up a Dockerized web app using Django REST APIs and ReactJS

Hopefully this will answer "How do I setup or start a Django project using REST Framework and ReactJS?"

This is a guide to show you step by step how this can be setup. If you just want to get started, use the cookiecuter I set up cookiecutter-django-reactjs. It basically is a fork of pydanny's cookiecutter, just added the front-end stuff :).

I created this because it was SUCH a pain in the ass setting up a project using all the latest technologies. After some research, I figured it out and have it working. The repo that implements this is located here. Feel free to use it as a boilerplate ;)

Main features:

  • Django REST APIs

Connecting emacs and Protonmail Bridge

This guide will cover the basics on how to integrate emacs with the bridge using

  • mu4e
  • mbsync
  • smtpmail

I am going to assume that you already have installed the mentioned software, I am using Fedora 27 but it should work on any GNU/Linux distribution.

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@defianceblack
defianceblack / cl-tcpip.lisp
Created November 25, 2020 17:07 — forked from shortsightedsid/cl-tcpip.lisp
Short guide to TCP/IP Client/Server programming in Common Lisp using usockets
; Short guide to TCP/IP Client/Server programming in Common Lisp using usockets
;
; The main reason for this guide is because there are very few examples that
; explain how to get started with socket programming with Common Lisp that I
; could understand. After spending a day trying, I finally came up with a small
; bit of code that makes it easy to understand the basics. I've written this
; primarily for myself, but should help others get started as well.
; As usual, we will use quicklisp to load usocket.
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#