Skip to content

Instantly share code, notes, and snippets.

View mjhea0's full-sized avatar

Michael Herman mjhea0

View GitHub Profile
@mjhea0
mjhea0 / audit_mixin.py
Created December 7, 2016 14:12 — forked from techniq/audit_mixin.py
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@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 / README.md
Created July 3, 2016 19:27 — forked from alextucker/README.md
Installing Dokku and Deploying a Django App
@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].

@mjhea0
mjhea0 / comprehensions.md
Created March 27, 2016 14:23 — forked from bearfrieze/comprehensions.md
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain

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
@mjhea0
mjhea0 / packt_scraper.py
Created February 4, 2016 01:00 — forked from TrishGillett/packt_scraper.py
Checking the Packt Publishing free ebook of the day with Selenium
# -*- coding: utf-8 -*-
"""
author: Trish Gillett (discardthree@gmail.com, @discardthree on github)
Basic scraper to check the Packt Publishing Free ebook of the day.
This version uses selenium because when I tried getting the source via the
requests package it sometimes seemed to return the source for a version of
the website that was different from the one that was live.
Adapted from this code which was used by Estela Alvarez (supita@gmail.com)
to demo webscraping at a Montreal Pyladies meeting:
@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 / promises-faq.md
Created August 21, 2016 14:38 — forked from joepie91/promises-faq.md
The Promises FAQ - addressing the most common questions and misconceptions about Promises.
@mjhea0
mjhea0 / search-bash-zsh-history.md
Created July 12, 2016 14:47 — forked from nepsilon/search-bash-zsh-history.md
Searching bash or zsh history — First published in fullweb.io issue #55

Searching bash or zsh history

More often than not, you already typed yesterday the commands you’re about to use today. Wouldn’t it be handy to be able to retrieve the long command instead of typing them yet another time?

Hit Ctrl+R, you’ll see:

(reverse-i-search)`':