Skip Navigation

Search

Programming @programming.dev
Corsair @programming.dev

Cannot post image anymore ?

Hi,

Is it just me, or posting image is not working anymore on programming.dev ?

Thanks.

Programming @programming.dev
MonkderVierte @lemmy.ml

Any Android Qr app (preferably Open Source) that allows decoding via "open with" or share?

cross-posted from: https://lemmy.ml/post/26048405

Because, we have here something called "Swiss Qr Bill" (standardized e-bill with Qr code) and some shops send you the bill via email. Would be nice, if i could just tap the qr-image and open with app.

Programming @programming.dev
thingsiplay @beehaw.org

Subclassing pathlib.PosixPath broken since Python 3.12 (actually its fixed, but workaround broken)

Solution was quite easy. Thanks to the user reply here: beehaw.org/comment/3535588 or programming.dev/comment/10034690 (Not sure if the links actually work as expected...)


Hi all. I have a little problem and don't know how to solve. A CLI program in Python is broken since Python 3.12. It was working in Python 3.11. The reason is, that Python 3.12 changed how subclassing of a pathlib.Path works (basically fixed an issue), which now breaks a workaround.

The class in question is:

 python
    
class File(PosixPath):
    def __new__(cls, *args: Any, **kwargs: Any) -> Any:
        return cls._from_parts(args).expanduser().resolve()  # type: ignore

    def __init__(self, source: str | Path, *args: Any) -> None:
        super().__init__()
        self.__source = Path(source)

    @property
    def source(self) -> Path:
        return self.__source

    @property
    def modified(self) -> Time:
       
  
Programming @programming.dev
promitheas @iusearchlinux.fyi

Blackjack game - array has 0s in first 24 elements immediately after initialising with values from 1 to 13

EDIT: Literally 1 second after I pressed the post button I got an idea and thats what it was. Why does that always happen? xD

The solution was that my player_hand[] and dealer_hand[] arrays had a size of DECK_SIZE / 2, but I was initialising them to 0 from within the for loop where I was initialising the deck[] array (which has a size of DECK_SIZE), so the last 24 0s of one of those where overflowing into deck[]...

Hello everyone!

I am trying to make a simple blackjack (21) game in C, to practice some pointer stuff, and I am running into an issue with the function that initialises all my arrays. The way I am going about setting everything up, I have an integer array for a standard deck of 52 cards (values from 1 to 13, each 4 times), an integer array for the shuffled deck, and 2 more arrays for the player and dealer hands (irrelevant at this point as they are not used yet).

My issue is that after successfully initialising the deck array (the non-shuffled one) and outputting the va

Programming @programming.dev
spez @sh.itjust.works

why local user.mail overrides global user.mail in git?

So, I have a GPG key with two noreply email addresses. One for codeberg.org and one email address for github.com. When using the [email protected] of codeberg as user.mail globally, I can make commits which show up as verified on codeberg.org. But if use the same mail as my git user.mail the commit on github will show up as unverified. Even though the particular repo's mail is set to the noreply email address of github which can be verified with git config user.mail but for some reason the global ~/.gitconfig mail is used to perform committs. Am I doing GPG management wrong or anything else wrong?

Programming @programming.dev
pe1uca @lemmy.pe1uca.dev

Can't access squid proxy via nodejs with axios

I'm not sure in which community to ask this, if you know of a better one let me know.

I already have squid proxy working, if I set up my browser or curl to use the proxy all sites work properly.
But when I try to make a request with axios it doesn't work.

Here are the logs of squid
The first two lines are successful google connections are from a browser.
The 3rd line is a successful to google using curl.
The 4th line is a successful to ipify using curl.
The last two ones are the ones from node using axios

 undefined
    
squid_proxy  | 1693406310.165  12043 127.0.0.1 TCP_TUNNEL/200 56694 CONNECT www.google.com:443 - HIER_DIRECT/142.250.217.132 -
squid_proxy  | 1693406310.166  10681 127.0.0.1 TCP_TUNNEL/200 47267 CONNECT apis.google.com:443 - HIER_DIRECT/142.250.176.14 -
squid_proxy  | 1693406325.551    497 127.0.0.1 TCP_TUNNEL/200 24778 CONNECT www.google.com:443 - HIER_DIRECT/142.250.217.132 -
squid_proxy  | 1693406336.829    403 127.0.0.1 TCP_TUNNEL/200 7082 CONNECT api.ipify.org
  
Programming @programming.dev
bloopernova @programming.dev

How to decide what to do with command line parameters?

This is solved, I was being dumb. Please see second EDIT below

This isn't really language specific, but if it helps I'm using Python. I can get the parameters just fine with the Traitlets module, but I'm still a novice really and figuring out which patterns to use is challenging.

Say you have a bunch of command line parameters. Some are booleans, where their presence means True, absence means False. Other parameters must accept one text string, and others can be used multiple times to build a list of strings.

It feels inefficient/wrong to use a bunch of IF/THEN/ELSE statements to decide what to do with the parameters, and prone to edge case errors. Is there a pattern that would invoke the correct method based on the combination of input parameters?

Examples:

 undefined
    
app thing --dry-run --create --name=newname01 --name=newname02 --verbose

app thing --create --name=newname01 --name=newname02 --name=newname03

app job --cancel -i 01 -i 02 -i 03

  

EDIT: Via the Traitlets module,