Skip to content

Instantly share code, notes, and snippets.

@dlamblin
dlamblin / _ Sophie's Python practice _.md
Last active February 13, 2024 23:08
Sophie's Python practice games

Sophie's Python practice games

In order to practice Python, Sophie worked on some Python that implements a game.

Deck shuffle

The first practice was to figure out how to take an ordered list of cards and shuffle that list like a deck of cards. After quickly figuring out a way to shuffle cards and then display the mixed up deck, she worked on making a guessing game out of it.

@dlamblin
dlamblin / Results-2023-09-11.tsv
Created September 11, 2023 22:56
Tabs vs Spaces, Entab, Detab
refmt mentions EG
detab 468 Fixed crash when detabbing with zero spaces per tab.
entab 88 Add C functions to centralize entab processing
reindent 6311 lang_css: reindented parser_css.mly
@dlamblin
dlamblin / fmtyaml.py
Created March 24, 2023 02:05
Format YAML by key name order with fmtyaml.py
#!/usr/bin/env python3
# vim: et sw=4 ai
"""
This script takes in files named in presumed yaml format and OVERWRITES them
with all their keys sorted by the key name. It does not preserve comments. I've
not tested it with lists.
Using '-' as a filename opens and consumes stdin in addition to other files.
stdin is written to stdout with the same processing.
@dlamblin
dlamblin / mute.py
Created August 21, 2020 13:02
Python muting stdout or stderr
"""
This module contains four methods for muting file descriptors.
You can mute the standard file descriptors:
with mute_stdout():
...
with mute_stderr():
...
with mute_stdout_stderr():
...
Or mute a list of known file descriptors:
@dlamblin
dlamblin / openapi_1_10_0.yaml
Last active April 4, 2020 11:09
OpenAPI schemas for The Airflow API, which has been experimental and without a clear schema
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@dlamblin
dlamblin / openapi_1_10_0.yaml
Created April 4, 2020 11:04
OpenAPI schemas for The Airflow API, which has been experimental and without a clear schema
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@dlamblin
dlamblin / ngram.py
Last active May 14, 2024 15:12
Python N-Gram for characters in string
"""
n-gram of a string by characters (not by words)
takes all args as input unless the first two args are numbers which are in
order, then it assume these are min and max length. Default min max is 2 - 60
"""
def ngram(inp='', mn=2, mx=60):
"""
@dlamblin
dlamblin / powers_of_2_in_decimal.pl
Created December 12, 2018 13:40
Print Powers of 2 to 2^64
#!/usr/bin/env perl
use bignum;
$a=1;
for(0..64){
printf "%2s%21s\n", $_, $a;
$a<<=1;
}
# (perl)$ perl -Mbignum -E '$a=1;for(0..64){say" "x($_<10).$_." "x(21-length($a)).$a;$a<<=1}'
# (perl)$ perl -Mbignum -E '$a=1;for(0..64){printf"%2s%21s\n",$_,$a;$a<<=1}'
@dlamblin
dlamblin / copy_one_line_per_sec.bash
Last active April 24, 2024 14:19
Subscribing to an AWS region's status RSS feeds in slack
sleep 5; while read -r line; do clear; echo $line; echo "$line" | pbcopy; sleep 1; done < "feed_commands_for_seoul_ap-northeast-2.txt"
@dlamblin
dlamblin / swisscom_Internet-Box_os-licenses.html
Last active July 25, 2018 17:27
Open Source Licences page of Swisscom Internet Box 2
Open Source License List (not included at https://www.swisscom.ch/en/residential/help/device/open-source.html)
<div class="base-content">
<div class="text description"> <span class="translation-string">Swisscom adopts a careful approach to the open source software used in its products. Use the links below to access the websites of the open source software components used. For more information and open source contact details of the Internet-Box software suppliers go to <a href="http://www.swisscom.ch/opensource">here</a>.</span> </div>
<div class="license-container">
<div class="license-name"> <a href="/static/licenses/AP/stargatev2/avahi-LICENSE.txt" target="_blank">avahi</a> </div>
<div class="license-site"> <a href="https://github.com/lathiat/avahi/releases/tag/v0.6.32" target="_blank">https://github.com/lathiat/avahi/releases/tag/v0.6.32</a> </div>
</div>
<div class="license-container">
<div class="license-name"> <a href="/static/licenses/AP/stargatev2/dbus-COPYING.t