Skip to content

Instantly share code, notes, and snippets.

View mjhea0's full-sized avatar

Michael Herman mjhea0

View GitHub Profile
@mjhea0
mjhea0 / admin.py
Created March 7, 2024 16:18 — forked from noviluni/admin.py
Large Table Paginator for Django: Scale Django admin pages and avoid timeouts.
from django.contrib.admin import ModelAdmin
from .paginator import LargeTablePaginator
class MyTableAdmin(ModelAdmin):
...
paginator = LargeTablePaginator
show_full_result_count = False # Recommended to avoid another count()
...
@mjhea0
mjhea0 / python_decorator_guide.md
Created September 5, 2020 13:45 — 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].

An engineering manager that I have the privilege of working with just asked me for three expectations of a principal engineer for a project that he is working on to mentor senior engineers at Twilio. Here is the list that I came up with.

  • Skate to where the puck is going: Are you waiting to be told what to do or are you getting a sense for our product vision and making concrete suggestions for what technical work needs to be done to get us in a good place when it becomes time to execute?
  • Act like an owner: Are you complaining about what's broken or offering solutions and/or alternative ways of thinking that makes it clear to engineers close to the problem that they can play an important role in solving those problems? Do you accept the world as it is or are you willing to provide a compelling vision for how it could be?
  • Teach and lead: You're not getting more hours in the day. Taking on all of the hard work not only makes you a single point of failure, it robs your colleagues of the ability

Install KiND

Instructions for installing KinD (Kubernetes in Docker) on Mac OS

Go

Start by installing Go, if you don't already have it.

If you’re on a Mac, the quickest way to install Go is with Homebrew:

@mjhea0
mjhea0 / 1_kubernetes_on_macOS.md
Created September 16, 2018 23:02 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@mjhea0
mjhea0 / dask_example.py
Created August 28, 2018 13:35
dask example
import time
import pandas as pd
import dask.dataframe as ddf
def benchmark(function, repetitions, name):
start = time.time()
function(repetitions)
end = time.time()

Install a 3-Node Kubernetes Cluster on Centos 7

This setup uses 3 machines:

  1. Centos7
  2. 100GB HDD
  3. 32 GB RAM
  4. 8 CPU

All Machines

const fs = require('fs');
const path = require('path');
const AWS = require('aws-sdk');
const { BUCKET_NAME, AWS_ACCESS_ID, AWS_SECRET_KEY } = process.env;
// helpers
function uploadToS3(file, name, type) {

Workaround for angular/angular-cli#9036.

In getErrorSpanForNode() in node_modules/typescript/lib/typescript.js...

Add-

if (!sourceFile) {
  return ts.createTextSpan(0, 0);
}

Hello!

I just finished planning the next edition of the Microservices with Docker, Flask, and React course and am looking for some feedback.

Major changes and updates:

Part Change
1 Replace Flask-Script with Flask-CLI/Click and add both Flask-RESTful and Flask-DebugToolbar
2 Add multistage Docker build for the React app and replace the pushstate server with nginx for the production React Dockerfile