Skip to content

Instantly share code, notes, and snippets.

@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

@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.

@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
@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)
@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
@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
@JBlond
JBlond / bash-colors.md
Last active May 7, 2025 03:36 — 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
@mdonkers
mdonkers / server.py
Last active April 4, 2025 13:11
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename trie.py
#created: 2010-08-01 20:24
#source uri: http://iregex.org/blog/trie-in-python.html
# escape bug fix by fcicq @ 2012.8.19
@nicktimko
nicktimko / override_guard.ipynb
Last active November 25, 2016 19:43
Override Checking
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.