This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from typing import TextIO | |
@dataclass | |
class Solver: | |
center_letter: str | |
all_letters: set[str] | |
dictionary: TextIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://betterstack.com/community/guides/logging/zerolog/ | |
package logger | |
import ( | |
"io" | |
"os" | |
"runtime/debug" | |
"strconv" | |
"sync" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:alpine | |
RUN apk add --update \ | |
build-base \ | |
postgresql-dev | |
WORKDIR /source | |
ADD requirements.txt . | |
RUN pip install -r requirements.txt | |
ADD . /source | |
CMD python manage.py runserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"golang.org/x/tour/tree" | |
) | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. | |
func Walk(t *tree.Tree, ch chan int) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import distutils | |
import inspect | |
import os.path | |
import subprocess | |
import types | |
import unittest | |
class PyangBindTestCase(unittest.TestCase): | |
yang_files = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AUTH_LDAP_START_TLS = True | |
AUTH_LDAP_SERVER_URI = env('AUTH_LDAP_SERVER_URI', cast=str, default=None) | |
AUTH_LDAP_GLOBAL_OPTIONS = { | |
ldap.OPT_X_TLS_REQUIRE_CERT: ldap.OPT_X_TLS_NEVER | |
} | |
AUTH_LDAP_BIND_DN = env('AUTH_LDAP_BIND_DN', cast=str, default=None) | |
AUTH_LDAP_BIND_PASSWORD = env('AUTH_LDAP_BIND_PASSWORD', cast=str, default=None) | |
AUTH_LDAP_USER_SEARCH = LDAPSearchUnion( | |
LDAPSearch( | |
'OU=Company,DC=our,DC=domain,DC=com', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from django import template | |
from pygments import highlight | |
from pygments.formatters import HtmlFormatter | |
from pygments.lexers import get_lexer_by_name | |
register = template.Library() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if messages %} | |
{% for message in messages %} | |
<div class="alert{% if message.tags %}{% if message.tags == "error" %} alert-danger{% else %} alert-{{ message.tags }}{% endif %}{% endif %}" role="alert"> | |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
<span aria-hidden="true">×</span> | |
</button> | |
{{ message }} | |
</div> | |
{% endfor %} | |
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import time | |
from datetime import datetime, timedelta | |
import django_filters | |
from django.utils import timezone | |
from .lookups import Now | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is for a case where I was accessing the database connection/cursors directly, | |
and had need to mock up a result from a database call. The real trick here is | |
returning the cursor MagicMock object as a side effect of the initial patch. | |
""" | |
from unittest import mock | |
cursor = mock.MagicMock( |
NewerOlder