Skip to content

Instantly share code, notes, and snippets.

View imsickofmaps's full-sized avatar

Mike Jones imsickofmaps

View GitHub Profile
@hakib
hakib / django_markdown.py
Created March 30, 2020 15:10
Using Markdown in Django
# Source code for article:
# https://hakibenita.com/django-markdown
from typing import Optional
import re
import markdown
from markdown.inlinepatterns import LinkInlineProcessor, LINK_RE
from urllib.parse import urlparse
from django.core.exceptions import ValidationError
from datetime import date
from google.oauth2 import service_account
from googleapiclient.discovery import build
import pandas as pd
import numpy as np
credentials = service_account.Credentials.from_service_account_file(
"./credentials.json"
)
@hakib
hakib / custom_django_checks.py
Last active July 1, 2024 09:20
Custom django checks using Django check framework, inspect and ast.
"""
Custom django checks.
H001: Field has no verbose name.
H002: Verbose name should use gettext.
H003: Words in verbose name must be all upper case or all lower case.
H004: Help text should use gettext.
H005: Model must define class Meta.
H006: Model has no verbose name.
H007: Model has no verbose name plural.
@simonw
simonw / how-to-upgrade-heroku-postgresql.md
Last active April 29, 2024 05:07
How to upgrade a Heroku PostgreSQL database to a new plan

How to upgrade a Heroku PostgreSQL database to a new plan

I started a project on a Hobby Dev plan (free, limit 10,000 rows), and then later needed to upgrade it to Hobby Basic ($9/month, limit 10,000,000 rows).

After assigning the new database, I had two databases attached to the application. They looked something like this:

  • HEROKU_POSTGRESQL_OLIVE (postgresql-dimensional-3321) Old, free-tier (Hobby Dev) database
@tricoder42
tricoder42 / 00_GraphQL_Subscriptions.md
Last active September 10, 2024 20:00
GraphQL Subscriptions with django-channels

GraphQL Subscription with django-channels

Django channels are official way for implementing async messaging in Django.

The primary caveat when working with GraphQL subscription is that we can't serialize message before broadcasting it to Group of subscribers. Each subscriber might use different GraphQL query so we don't know how to serialize instance in advance.

See related issue

We don't use that word here

There are some words which carry with them the baggage of sexism and ableism and so they're words we've chosen to avoid using within our community.

We realise that sometimes SlackBot might get a bit over-eager and correct you when you intentionally chose that word and it is appropriate. That's okay, but we find that in most cases, SlackBot's reminders help us choose our words with intention and promote a more inclusive and welcoming space.

There are plenty of other words that you can use which can still convey the meaning you're looking for. Sometimes it might require a bit of creativity, but trust us – it can be done.

We don't assume you were intentionally being sexist or ableist. Our language is littered with the legacy of unfortunate cultural baggage. You might not even believe that there's a problem with the word you used. That's cool, but we don't use that word here.

@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active November 16, 2024 22:55
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@tolsadus
tolsadus / networking.md
Last active July 8, 2016 09:24
Networking
  1. if you’re on (most modern distributions of) linux, forget that route(1) even exists (and throw ifconfig out in the same go) because it’s just absolutely frustrating. for probably 98% of what you need, ip(1) is the cool you care about

generally speaking, these will cover you: ip route, ip address, ip link

  1. when dealing with routing problems (​even if just two hosts next to each other​), mtr > traceroute > ping is an order that’s useful for a lot of what you need

mtr is nice because you can just let it keep running. press d in its display to get a running history breakdown of packets. fantastic for intermittent issues!

traceroute is generally known already, but depending on the complexity of your networks in question you may want traceroute-nanog or similar other ones. some of these are ASN-aware, which is useful.

"""
Logical deletion for Django models. Uses is_void flag
to hide discarded items from queries. Overrides delete
methods to set flag and soft-delete instead of removing
rows from the database.
"""
from django.apps import apps
from django.contrib.admin.utils import NestedObjects
from django.db import models
from django.db.models import signals
@criccomini
criccomini / run-tests.sh
Created June 22, 2016 15:16
run-tests.sh
#!/bin/bash
# Runs airflow-dags tests.
# Set Nose defaults if no arguments are passed from CLI.
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NOSE_ARGS=$@
if [ -z "$NOSE_ARGS" ]; then
NOSE_ARGS=" \
--with-coverage \