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 cldr-44.1.0-json-modern | |
* | |
* - [Tags for Identifying Languages (BCP47)](https://www.ietf.org/rfc/bcp/bcp47.txt) | |
* - [List of ISO 639 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) (WikiPedia) | |
* - [Unicode CLDR Project](https://cldr.unicode.org/) | |
*/ | |
/** @typedef {string} LocaleCode */ |
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
#!/usr/bin/env python3 | |
import html | |
import json | |
import socketserver | |
import sys | |
from datetime import datetime | |
from http import HTTPStatus | |
from http.server import SimpleHTTPRequestHandler | |
from time import mktime |
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
MIT License | |
Copyright (c) 2021 Daniel Ethridge | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
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
module.exports = (ctx) => { | |
return { | |
parser: ctx.ext ==='.sml' ? 'posthtml-sugarss' : false, | |
from: ctx.from, | |
to: ctx.to, | |
path: ctx.cwd || './src', | |
plugins: ctx.plugins || {}, | |
} | |
} |
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
#!/usr/bin/env python3 | |
import contextlib | |
import gzip | |
import sys | |
from itertools import zip_longest | |
from urllib.parse import urlparse | |
import boto3 | |
from botocore.exceptions import NoCredentialsError |
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
def humanize_bytes(nbytes, output_format='%.2f %s%s', suffix=None): | |
if suffix is None: | |
suffix = 'iB' | |
basis = 1024.0 if suffix == 'iB' else 1000.0 | |
for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']: | |
if abs(nbytes) < basis: | |
return output_format % (nbytes, unit, suffix) | |
nbytes /= basis | |
return output_format % (nbytes, 'Y', suffix) |
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
""" | |
Django REST Framework router + ViewSet + parameters | |
- https://www.django-rest-framework.org/api-guide/routers/ | |
""" | |
class OriginViewSet(ModelViewSet): | |
... | |
@classmethod | |
def as_custom_viewset(cls, **kwargs): | |
class CustomViewSet(cls): |
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
document.querySelectorAll("td[colspan=full]").forEach(td => { | |
const table = td.closest("table"); | |
const columns = table.querySelector("tr").querySelectorAll("th, td"); | |
const column_count = Array.from(columns).reduce((acc, cell) => acc + (cell.getAttribute('colspan') || 1), 0); | |
td.setAttribute('colspan', column_count); | |
}); |
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
document.querySelector('input[type=email]').addEventListener('keyup', event => { | |
const element = event.target; | |
const valueParts = element.value.split('@'); | |
if (element.getAttribute('list') && document.getElementById(element.getAttribute('list'))) { | |
document.getElementById(element.getAttribute('list')).remove(); | |
} | |
if (valueParts.length > 1 && valueParts[0] && valueParts[1]) { | |
const suggestionsId = (element.id || element.name) + 'Suggestion'; | |
const suggestions = makeDatalist(suggestionsId, valueParts[0], valueParts[1]); |
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:3.7 | |
RUN apt-get -qq update && \ | |
apt-get -q -y upgrade && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y locales locales-all | |
RUN apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | |
#ENV PYTHONDONTWRITEBYTECODE 1 |
NewerOlder