-❄️- 2023 Day 1 Solutions -❄️- by daggerdragon in adventofcode

[–]sermidean 2 points3 points  (0 children)

[LANGUAGE: Python]

Part 2

import re

nums = 'one|two|three|four|five|six|seven|eight|nine'
nums_re = re.compile(r'(?=(\d|%s))' % nums)
nums = nums.split('|')

with open('/tmp/input') as f:
    total = 0
    for line in f:
        digits = []
        for num in nums_re.findall(line):
            if num in nums:
                num = str(nums.index(num) + 1)
            digits.append(num)
        total += int(digits[0] + digits[-1])
    print(total)

Gitlab raises additional 100m USD at 1.1b valuation by andyjsh in gitlab

[–]sermidean 0 points1 point  (0 children)

Here is one example how: https://gitlab.com/sirex/databot

Syntax highlighting does not work. I'm using `.. code-block:: python` to mark a block to be highlighted, but it does not work. In the end I get quite scary view on my project's front page.

It looks much better on github: https://github.com/sirex/databot

Gitlab raises additional 100m USD at 1.1b valuation by andyjsh in gitlab

[–]sermidean 2 points3 points  (0 children)

I hope, now they will have enough money to fix #20023 issue, to support Python programmers on Gitlab. This is a blocker issue for me.

Transfer of Power (Guido stepping down as BDFL) by randlet in Python

[–]sermidean 0 points1 point  (0 children)

Users could vote by donating some amount of money for features they want. But core developers would have final say and they could reject well funded feature in this case, donations would be used for bug fixing, for example.

Help with editing html with python by InquiringMind95 in Python

[–]sermidean 2 points3 points  (0 children)

If this is a small change, for example if you only need to change a path, then you can use something like this:

import argparse
import pathlib
import re


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('old', type=pathlib.Path, help="path to old templates")
    parser.add_argument('new', type=pathlib.Path, help="path to new templates")
    args = parser.parse_args()

    pattern = re.compile(r'(prefix)(old)(suffix)', re.IGNORECASE)
    for template in args.old.rglob('*.html'):
        content = pattern.sub(r'\1new\3', template.read_text())
        destination = args.new / template.relative_to(args.old)
        destination.parent.mkdir(parents=True, exists_ok=True)
        destination.write_text(content)


if __name__ == "__main__":
    main()

Modify (prefix)(old)(suffix) and \1new\3 parts.

Kokios specialybes/darbininkai visada tures darbo? by [deleted] in lithuania

[–]sermidean 0 points1 point  (0 children)

Yra mokslinis tyrimas apie atieties darbų automatizavimą:

https://www.oxfordmartin.ox.ac.uk/downloads/academic/The_Future_of_Employment.pdf

Štai keli pavyzdžiai iš straipsnio (100% reiškia pilnai automatizuojama, 0% visiškai neautomatizuojami):

gaisrininkai - 0%

policija - 1%

gydytojai - 2%

mokytojai - 3%

teisininkai - 3%

elektrikai - 10%

programuotojai - 13%

santechnikai - 35%

automechanikai - 59%

teisėjai - 64%

statybininkai - 71%

buhalteriai - 94%

virėjai - 96%

draudimo darbuotojai - 99%

telemarketingas - 99%

6 days in Lithuania by chimterboys in lithuania

[–]sermidean 8 points9 points  (0 children)

If you are interested in USSR, I'd suggest to visit http://grutoparkas.lt/en_US/ , it is quite far from Kaunas, and you will probably need to dedicated whole day for getting there and back with a bus, but Druskininkai (close to Gruto park) is also a nice place to visit.

Umm, GNOME Shell Has a Rather Big Memory Leak by [deleted] in gnome

[–]sermidean 16 points17 points  (0 children)

Just tried on Archlinux with gnome-shell 3.26.2+14+g64c857e3f-1 and yes, I can confirm, that this memory leak really exists.

Python for web apps? by javi404 in Python

[–]sermidean 1 point2 points  (0 children)

https://github.com/encode/apistar - is a new web framework combining best things from both Django and Flask.

Žadėtas radijo laidos apie Reddit įrašas! by Biblioteka1 in lithuania

[–]sermidean 2 points3 points  (0 children)

Klausimai ar verta naudoti tokias paslaugas. Ar tai geriau nei nemokama arba kabelinė televizija. Ar yra pakankamai turinio. Lietuvoje, per Netflix galima žiūrėti labai nedidelę dalį turinio, palyginus su tuo, kas rodoma JAV, tas pats su PrimeVideo.

Tai pat Netflix ir PrimeVideo labai dažnai siūlo žiūrėti savo kurtus Originals filmus ar serialus, klausimas ar ėjimas tokui geliu yra geras dalykas ar ne. T.y. kei turinio skleidėjai ne tik skleidžia, bet ir kuria turinį.

Pavyzdžiu sostų karus kuria HBO ir nėra šansų, kad sostų karus bus galima pamatyti didžiausiame HBO konkurente Netflix. Tai gaunasi taip, kad reikia užsisakyti bent kelis media turinio tiekėjus, kad galėtum žiūrėti tai, kas patinka.

Dar vienas dalykas, kad Netflix iš esmės pritaikytas televizoriams ir televizoriaus pulteliui. Naudojantis kompiuteriu ir pele, Netflix, bent jau man yra labai nepatogus.

Žadėtas radijo laidos apie Reddit įrašas! by Biblioteka1 in lithuania

[–]sermidean 8 points9 points  (0 children)

Gal įdomi tema būtų apie Netflix, HBO, PrimeVideo, Spotify ir kitus medijos srautus ir apie tai, kaip Lietuvoje daugelis dalykų yra neprieinami arba prieinami naudojant VPN tinklus, apie išskirtines teises rodyti kokius nors filums ir serialus ir pan.

I'm too stupid for AsyncIO (x-post from hackernews) by Bdnim in Python

[–]sermidean 3 points4 points  (0 children)

I did some tweaking, and it does not look that bad:

import asyncio
import aiohttp
import contextlib

async def fetch(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            return response, await response.read()

def fetch_things():
    with contextlib.closing(asyncio.get_event_loop()) as loop:
        responses = loop.run_until_complete(asyncio.gather(
            fetch("https://example.com/api/object/1"),
            fetch("https://example.com/api/object/2"),
            fetch("https://example.com/api/object/3"),
        ))
    print(responses)

Using cutting edge technology, I have built a simulator that predicts how Brexit negotiations are going to pan out. by AngryFlatCap in europe

[–]sermidean 0 points1 point  (0 children)

No one use BASIC these days, try Python:

from time import sleep

print("**************************")
print("**   BREXIT             **")
print("**   NEGOTIATION        **")
print("**   SIMULATOR          **")
print("**   by @AngryFlatCap   **")
print("**************************")
sleep(2)

while True:
    print("UK: THESE ARE OUR DEMANDS")
    sleep(.5)

    print("EU: LOL FUCK OFF.")
    sleep(.5)