Skip to content

Instantly share code, notes, and snippets.

View chinchalinchin's full-sized avatar

Grant Moore chinchalinchin

View GitHub Profile
@chinchalinchin
chinchalinchin / metric_code.py
Created April 12, 2025 03:38
The Invocation of Metric Code
"""
The Invocation of Metric Code
=============================
A Pythonic poem in (mostly) metric form.
Hacks until the devs publish a fix:
- "()", "[]", ".", ":", "_", "=" and "==" don't contribute!
- Comments are part of the poem! Except the first one!
@chinchalinchin
chinchalinchin / prime.py
Last active May 17, 2024 20:27
Sieve of Erastothenes Algorithm for Finding Prime Numbers
def _squares(n):
"""
Arguments:
n (int): arbitray integer
Returns:
a list of squares up to the value of ``n``.
"""
return [
@chinchalinchin
chinchalinchin / variance.py
Last active December 15, 2022 19:00
Young and Cramer's Recursive Variance Algorithm in Python
from typing import List, Union
import random
def recursive_sum_of_squares(
x: List[Union[float,int]],
checked: bool = False
) -> float:
n = len(x)
@amarao
amarao / blame-praise.py
Last active March 17, 2025 12:48
Example of argparse with subparsers for python
#!/usr/bin/env python
import argparse
def main(command_line=None):
parser = argparse.ArgumentParser('Blame Praise app')
parser.add_argument(
'--debug',
action='store_true',
help='Print debug info'