Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Johnson escattone

View GitHub Profile
@escattone
escattone / send_welcome_emails_2020_05_21.py
Created May 22, 2020
Send welcome emails to the 11 users whose email failed to send on May 21, 2020
View send_welcome_emails_2020_05_21.py
from kuma.users.tasks import send_welcome_email
users = [
(723329, "en-US"),
(723330, "en-US"),
(723331, "fr"),
(723332, "es"),
(723336, "en-US"),
(723337, "es"),
(723338, "en-US"),
View delete_persona_users_without_contributions.py
def delete_user(user):
# Protected references to users need to be manually deleted first.
user.key_set.all().delete()
# Some records are worth keeping prior to deleting the user
# but "re-assign" to the anonymous user.
anon, _ = User.objects.get_or_create(username="Anonymous")
user.revisionakismetsubmission_set.update(sender=anon)
user.documentdeletionlog_set.update(user=anon)
user.documentspamattempt_set.update(user=anon)
user.documentspam_reviewed.update(reviewer=anon)
@escattone
escattone / hierarchy_check_failures.log
Created Feb 21, 2020
A log of the failures discovered when running hierarchy_check.py on all documents within all locales on MDN
View hierarchy_check_failures.log
-------------------------------------------------
locale = en-US, 4 failures within 18601 documents
-------------------------------------------------
doc.slug = SpiderMonkey/GCIntegration
doc.parent_topic.slug = Mozilla/Projects/SpiderMonkey
---
doc.slug = Gecko/FAQ
doc.parent_topic.slug = Mozilla/Gecko
---
doc.slug = NSS/PKCS_11_Netscape_Trust
@escattone
escattone / hierarchy_check.py
Created Feb 21, 2020
Python code for checking that a document's slug is a sub-path of its parent's slug -- for all documents in all locales on MDN
View hierarchy_check.py
from kuma.wiki.constants import EXPERIMENT_TITLE_PREFIX, LEGACY_MINDTOUCH_NAMESPACES, NOINDEX_SLUG_PREFIXES
def get_docs(locale):
qs = Document.objects.filter(locale=locale, is_redirect=False).exclude(html="")
qs = qs.only("id", "locale", "slug", "parent_topic")
qs = qs.select_related('parent_topic')
qs = qs.exclude(current_revision__isnull=True)
q = Q(slug__startswith=EXPERIMENT_TITLE_PREFIX)
for legacy_mindtouch_namespace in LEGACY_MINDTOUCH_NAMESPACES:
View re_render_docs.py
# From https://gist.github.com/jwhitlock/43e34e07bef8c3f1863e91f076778ca6
from time import sleep, time
import redis
from celery.states import READY_STATES
from django.conf import settings
from kuma.wiki.models import Document
from kuma.wiki.tasks import render_document
View spy.py
#!/usr/bin/env python
import base64
import click
import oyaml as yaml
@click.command()
@click.option('--decode/--encode', default=True,
help='base64 decode or encode')
View gist:63fec9ffba093b3ea38cbd5ab2818aad
#!/usr/bin/env bash
echo '--> Setting environment to PROD in PORTLAND'
export KUBECONFIG=~/.kube/portland.config
# Define defaults for environment variables that personalize the commands.
export TARGET_ENVIRONMENT=prod
export K8S_NAMESPACE=mdn-${TARGET_ENVIRONMENT}
export AWS_REGION=us-west-2
export K8S_CLUSTER_SHORT_NAME=portland
View .env
COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml
View keybase.md

Keybase proof

I hereby claim:

  • I am escattone on github.
  • I am escattone (https://keybase.io/escattone) on keybase.
  • I have a public key whose fingerprint is 4CE9 97DA AB88 9BB2 3ACD 10FA 68EA 41CB 713F 24D9

To claim this, I am signing this object: