Skip to content

Instantly share code, notes, and snippets.

@JBlond
JBlond / bash-colors.md
Last active May 10, 2025 22:40 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@Integralist
Integralist / Check TLS version using by Python.py
Created September 4, 2017 15:13
[Check TLS version using by Python] #python #tls #ssl
# Python 3.5.2-slim
import json
from tornado.httpclient import HTTPClient
response = HTTPClient().fetch("https://www.howsmyssl.com/a/check").body.decode()
data = json.loads(response)
tls_version = data["tls_version"]
print(tls_version)" # TLS 1.2
@maple3142
maple3142 / aria2.conf
Last active May 6, 2024 16:44
aria2 on Windows configuration
rpc-secret=maple3142
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
max-concurrent-downloads=5
continue=true
max-connection-per-server=16
min-split-size=10M
split=10
max-overall-download-limit=0
@buxx
buxx / aiopoc.py
Created July 24, 2018 12:44
aiohttp stream response example
from aiohttp import web
async def handle(request):
response = web.StreamResponse(
status=200,
reason='OK',
headers={'Content-Type': 'text/plain'},
)
await response.prepare(request)
@ww9
ww9 / gist_blog.md
Last active April 23, 2025 12:56
Using Gist as a blog #blog

Blogging with Gist

Gist simplicity can turn blogging into a liberating experience.

Pros Cons
✅ Free, simple, fast, hassle-free ❌ Image upload in comments only
✅ Tagging ❌ No post pinning
✅ Search ❌ Doesn't look like a blog
✅ Revisions ❌ Unfriendly URLs
@andystanton
andystanton / Tiny Python 3 HTTP 1.1 Server.md
Last active November 19, 2024 13:24
Tiny Python 3 HTTP/1.1 Server

What?

This is a Python 3 HTTP/1.1 server bound to 127.0.0.1 on port 8000 using only the standard library.

Why?

I wanted a simple Python 3 web server using HTTP 1.1 that can perform simple HTTP operations and depends only on Python and standard library modules. I couldn't find an example so I made one.

The example demonstrates how to accept different methods, parse the url and query strings, read data sent to the server, parse and return json, return responses with different status codes and headers, handle graceful termination, and override the default error logging.

@robin-a-meade
robin-a-meade / unofficial-bash-strict-mode.md
Last active April 1, 2025 10:29
Unofficial bash strict mode

Unofficial Bash Strict Mode

Sometimes a programming language has a "strict mode" to restrict unsafe constructs. E.g., Perl has use strict, Javascript has "use strict", and Visual Basic has Option Strict. But what about bash? Well, bash doesn't have a strict mode as such, but it does have an unofficial strict mode:

set -euo pipefail

set -e

@cb109
cb109 / vscode_python_sort_imports_isort_on_save.md
Last active April 29, 2025 08:19
VSCode: Python Sort Imports on File Save (isort)

VSCode: Python Sort Imports on File Save (isort)

  • Make sure the isort extension is installed in VSCode

Update April 2025

The latest VSCode update brought the requirement to use a python environment 3.8+ for isort:

2025-04-24 13:28:29.888 [info] No interpreter found from setting isort.interpreter
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@Paikan
Paikan / reproduction.py
Created November 7, 2019 14:05
Bug in wikitextparser with tables
import json
import wikitextparser
with open("table1.json") as f: # or table2.json
data = json.load(f)
source = data["source_text"]
parsed = wikitextparser.parse(source)
print("Processing tables")
# This one will hang