Skip to content

Instantly share code, notes, and snippets.

@s3rgeym
Created March 9, 2026 11:51
Show Gist options
  • Select an option

  • Save s3rgeym/50010a562ce2fce2438b5d74fa06aa03 to your computer and use it in GitHub Desktop.

Select an option

Save s3rgeym/50010a562ce2fce2438b5d74fa06aa03 to your computer and use it in GitHub Desktop.
==> no candidate packages found for pruning
(3/3) Performing snapper post snapshots for the following configurations...
==> root: 3015
~/workspace/hh-applicant-tool -> main
(.venv) ❯ flatpak update -y
Looking for updates…
Info: runtime org.kde.Platform branch 6.8 is end-of-life, with reason:
We strongly recommend moving to the latest stable version of the Platform and SDK
Info: applications using this runtime:
com.obsproject.Studio
ID Branch Op Remote Download
1. [✓] io.github.kolunmi.Bazaar.Locale stable u flathub 5.5 kB / 1.4 MB
2. [✓] org.freedesktop.Platform.GL.default 25.08 u flathub 69.5 MB / 141.4 MB
3. [✓] org.freedesktop.Platform.GL.default 25.08-extra u flathub 5.3 MB / 141.4 MB
4. [✓] org.freedesktop.Platform.Locale 25.08 u flathub 18.5 kB / 378.7 MB
5. [✓] org.freedesktop.Platform.codecs-extra 25.08-extra u flathub 712.3 kB / 14.4 MB
6. [✓] org.freedesktop.Sdk.Locale 25.08 u flathub 18.5 kB / 394.4 MB
7. [✓] io.github.kolunmi.Bazaar stable u flathub 4.4 MB / 7.6 MB
8. [✓] io.dbeaver.DBeaverCommunity stable u flathub 7.6 kB / 161.7 MB
9. [✓] org.freedesktop.Sdk 25.08 u flathub 34.8 MB / 595.3 MB
10. [✓] org.freedesktop.Platform 25.08 u flathub 3.2 MB / 253.4 MB
Updates complete.
~/workspace/hh-applicant-tool -> main
(.venv) ❯ python
Python 3.14.3 (main, Feb 13 2026, 15:31:44) [GCC 15.2.1 20260209] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> data = """\
... 5.5 kB / 1.4 MB
... 69.5 MB / 141.4 MB
... 5.3 MB / 141.4 MB
... 18.5 kB / 378.7 MB
... 712.3 kB / 14.4 MB
... 18.5 kB / 394.4 MB
... 4.4 MB / 7.6 MB
... 7.6 kB / 161.7 MB
... 34.8 MB / 595.3 MB
... 3.2 MB / 253.4 MB\
... """
>>> def parse_size(s):
... units = ["B", "kB", "MB", "GB"]
... size, unit = s.split()
... exp = units.index(unit)
... return int(size) * 1024**exp
...
>>> parse_size("2 kB")
2048
>>> def human_size(n):
... for i in ["B", "kB", "MB", "GB"]:
... if n < 1024:
... return f"{n} {i}"
... n /= 1024
...
>>> human_size(1025)
'1.0009765625 kB'
>>> def human_size(n):
... for i in ["B", "kB", "MB", "GB"]:
... if n < 1024:
... return f"{n:.2f} {i}"
... n /= 1024
...
>>> human_size(1025)
'1.00 kB'
>>> data.split("\n")
[' 5.5\xa0kB / 1.4\xa0MB', ' 69.5\xa0MB / 141.4\xa0MB', ' 5.3\xa0MB / 141.4\xa0MB', ' 18.5\xa0kB / 378.7\x
>>> [list(map(str.strip, x.split(" / "))) for x in data.split("\n")]
[['5.5\xa0kB', '1.4\xa0MB'], ['69.5\xa0MB', '141.4\xa0MB'], ['5.3\xa0MB', '141.4\xa0MB'], ['18.5\xa0kB', '37
>>> data=[list(map(str.strip, x.split(" / "))) for x in data.split("\n")]
>>> sum(parse_size(x[0]) for x in data)
Traceback (most recent call last):
File "<python-input-10>", line 1, in <module>
sum(parse_size(x[0]) for x in data)
~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<python-input-10>", line 1, in <genexpr>
sum(parse_size(x[0]) for x in data)
~~~~~~~~~~^^^^^^
File "<python-input-1>", line 5, in parse_size
return int(size) * 1024**exp
~~~^^^^^^
ValueError: invalid literal for int() with base 10: '5.5'
>>> def parse_size(s):
... units = ["B", "kB", "MB", "GB"]
... size, unit = s.split()
... exp = units.index(unit)
... return float(size) * 1024**exp
...
>>> sum(parse_size(x[0]) for x in data)
123673804.8
>>> sum(parse_size(x[1]) for x in data)
2191209267.2
>>> human_size(sum(parse_size(x[0]) for x in data))
'117.94 MB'
>>> human_size(sum(parse_size(x[1]) for x in data))
'2.04 GB'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment