Skip to content

Instantly share code, notes, and snippets.

  • each iteration of the loop creates new variables
  • Enhanced HTTP routing patterns (breaks backwards compatibility in small ways)
  • go/types - new Alias type - may break existing type switches that do not know to check for them
  • for i := range 10 //from 0 to 9, inclusive
  • New math/rand/v2 package
  • Commands in workspaces can now use a vendor directory containing the dependencies of the workspace
  • runtime/trace - trace viewer improved, execution tracer has been completely overhauled
  • runtime/pprof Mutex profiles improved
  • PGO improvement
@fillest
fillest / better-than-bash-scripts.py
Last active October 18, 2023 19:11
No more unmaintainable error-prone Bash scripts - use this instead
# Bash really should be avoided as much as possible (within reasonable limits, of course) even for one-liners which *seem* trivial.
# Bash is very error-prone by design. It's hard to comprehend all the pitfalls (e.g. https://mywiki.wooledge.org/BashFAQ/105)
# and it's a regrettable time-waste anyway.
#
# Modern Python is good for scripting the logic - keep Bash only for launching executables and most primitive
# pipes and redirections (avoid subshells, substitutions and so on). No need to install anything -
# just start your script with the following small self-contained helper function (check the examples for usage). Its features:
# * terminates on non-zero exit status by default
# * returns the output (combined - which usually should not be a problem - use e.g. '2>/dev/null' when it is)
# * prints commands and combined output

grouped by versions (3.0 to 3.10).
most important is marked with bold.


(https://docs.python.org/3/whatsnew/3.0.html)

  • binary data and Unicode
    Python 3.0 uses the concepts of text and (binary) data.
    All text is Unicode ("...")
    b"..." literals for binary data.
#!/usr/bin/env bash
set -e
#set -x
if [ ! -d somedir ]; then echo "..."; else true; fi
for fpath in some/path/*; do cat $fpath; echo; done > some/file
python3 -m venv venv
venv/bin/pip install -U pip
venv/bin/pip install -U setuptools wheel
venv/bin/pip freeze --all | grep -v pkg-resources
import argparse
cli_parser = argparse.ArgumentParser()
cli_parser.add_argument('--smth-str', default = 'val', help = "")
cli_parser.add_argument('-n', type = int, default = 2, choices = [1, 2, 3])
cli_parser.add_argument('-o', '--optional-smth', action = 'store_true')
func PanicOn(err error) {
if err != nil {
panic(err)
}
}
multilineStr := `line1
line2`
//tmp avoid "unused"
import subprocess
import time
import sys
interval = 2.0
while True:
t1 = time.time()
#http://manpages.ubuntu.com/manpages/trusty/en/man1/curl.1.html
@fillest
fillest / asd.py
Last active July 10, 2019 09:59
python_some_module_level_scope_hack
import some_module
some_module.surprise_global = ["sgushenka"]
some_module.test()
# $ python -c 'import asd'
# ['sgushenka']
import contextlib
import urllib2
try:
with contextlib.closing(urllib2.urlopen(url, timeout = 1)) as resp:
#resp.getcode()
except urllib2.URLError as e:
#
[loggers]
keys = root, ..., sqlalchemy, sqlalchemy_pool
[logger_sqlalchemy_pool]
level = DEBUG
handlers =
qualname = sqlalchemy.pool