Skip to content

Instantly share code, notes, and snippets.

View liiight's full-sized avatar

Or Carmi liiight

View GitHub Profile
@willmcgugan
willmcgugan / typed_property.py
Created October 18, 2021 10:12
A property decorator that permits a different type in the setter
from typing import Any, Callable, Generic, NamedTuple, Optional, Tuple, TypeVar
GetterT = TypeVar("GetterT")
SetterT = TypeVar("SetterT")
GetterCallable = Callable[[Any], GetterT]
SetterCallable = Callable[[Any, SetterT], SetterT]
def typed_property(getter: GetterCallable) -> "TypedPropertyGetter[GetterT]":
@jph00
jph00 / py.md
Last active May 31, 2022 06:16
Organized and hyperlinked index to every module, function, and class in the Python standard library

All of the python 3.9 standard library

For a version without the collapsible details sections (so you can search the whole thing in your browser), click here.

@Midnighter
Midnighter / README.md
Last active September 8, 2019 13:24
How to make autodoc recognize any Python module.

How to Auto Document Your Pytest Test Suite

Triggered by this recent tweet advertising a new pytest plugin that can document itself, I want to briefly describe how you can get sphinx-autodoc to recognize and document the tests.

It is slightly more work since you have to tell Sphinx to auto-document each individual module manually. At least, I haven't yet spent the time to os.walk the test directory and document each one. Assuming the following project

@oifland
oifland / Jenkinsfile
Last active March 23, 2024 17:59
Loops in Jenkinsfiles
// Related to https://issues.jenkins-ci.org/browse/JENKINS-26481
abcs = ['a', 'b', 'c']
node('master') {
stage('Test 1: loop of echo statements') {
echo_all(abcs)
}
stage('Test 2: loop of sh commands') {
@ril3y
ril3y / create_x.509_cert.py
Created August 23, 2011 12:58
Python script that will generate a x.509 certificate
#!/usr/bin/python
from OpenSSL import crypto, SSL
from socket import gethostname
from pprint import pprint
from time import gmtime, mktime
from os.path import exists, join
CERT_FILE = "myapp.crt"
KEY_FILE = "myapp.key"