Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dima Tisnek dimaqq

🏠
Working from home
View GitHub Profile
View guardian_clueless_sudoku.py
from collections import Counter
from pprint import pprint
BOARD = """
a a a a b
c c c a b
d d c b b
d e c c c
d e e e c
""".strip().splitlines()
View hide-disabled.js
setInterval(() => [...document.getElementsByClassName("disabled")].map(e => e.remove()), 500)
View ana.py
from collections import Counter
from pathlib import Path
def ngrams(n, s):
# lazy, but trailing sub-n-grams are not statistically significant
for i in range(len(s)):
yield s[i:i+n]
View config-overrides⁄index.js
const path = require("path");
const immer = require("immer");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const stats = process.argv.includes("--stats");
module.exports = (config, env) => immer.produce(config, draft => {
// I just happen to know these indices:
// https://github.com/facebook/create-react-app/issues/7581#issuecomment-535305630
draft.module.rules[2].oneOf[0].test.push(/[.]svg$/);
// Ad-hoc UseBabelRc()
View Openssl Error Comparison.txt
=== ubuntu buster
# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 280
# define SSL_R_INVALID_COMMAND 280
# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281
# define SSL_R_INVALID_CONTEXT 282
# define SSL_R_INVALID_CONFIG 283
# define SSL_F_TLS1_PRF 284
# define SSL_R_NOT_SERVER 284
# define SSL_F_SSL3_FINAL_FINISH_MAC 285
View repro-bpo-39951.py
""" Reproducer for BPO-39951
We send some data over ssl and close the connection.
The server responds after our openssl considers the connection closed-ish and raises an error.
"""
import asyncio
import ssl
host = "nghttp2.org"
port = 443
View anti_dogpile.py
fut = None
async def antidogpile(coro, *args, **kwargs):
nonolocal fut
async def helper():
nonlocal fut
try:
return await coro(*args, **kwargs)
finally:
View session.txt
/app # wget https://raw.githubusercontent.com/python/cpython/master/Tools/gdb/libpython.py
...
/app # apk add gdb
...
/app # env PYTHONPATH=. gdb
GNU gdb (GDB) 8.2
...
View data.json
[
{
"refs": [
"tag: 0.1"
],
"hash": "6bf194888b1c0e40d68aae9424c69e798395b165",
"hashAbbrev": "6bf1948",
"tree": "37097d59d05d6216edb082f62ce15be4eb6b732d",
"treeAbbrev": "37097d5",
"parents": [],
View shiritori.py
def game():
"""Play a single game, interactively"""
last = None # last word entered by player
seen = set() # all the words player tried so far
while True:
guess = input("Please type a word: ")
if not guess: