aral, to web
@aral@mastodon.ar.al avatar

Here’s a niche gotcha with the clipboard API’s navigator.clipboard.writeText() method that’s unique to Safari:

If you access a function from a module within your gesture handler (e.g., click handler), you will get a permission error.

The (sadly hacky and not as robust) workaround is to set a global variable from your module instead.

Full gist:

https://codeberg.org/aral/gists/src/branch/main/clipboard-writetext-permission-error-when-using-modules-in-safari.md

juandesant, to github
@juandesant@astrodon.social avatar

I just created a new Gist to remind myself on how to create index entries that refer to glossary definitions.

https://gist.github.com/juandesant/0101a49fae94069e970484aa8609c0e3

ErHaWeb, to php German
@ErHaWeb@phpc.social avatar

Set up a new #TYPO3 #v13 test #environment in just a few seconds: I have now included the #autoinstallation of version 13.0.0 in my #bash #script collection on #Gist. Feel free to customize and use it for your purposes 🚀
https://gist.github.com/ErHaWeb/961dc1029ce05cee49825f4600219573#file-install-13-sh

geographile, to Happy
@geographile@sfba.social avatar

The origins of the and other things.
https://youtu.be/pdOgsGBw1t8?si=xjpvSET9ZhFl1QMI

I suck this stuff down like squishy-ripe hachiya persimmons. So yummy. I certainly don't understand all the details clearly, but I get the general , and knowing the people sit around thinking about this makes me incredibly . I'm not sure why. Maybe I'm just thrilled by this kind of .

Stark9837, (edited ) to RegEx
@Stark9837@techhub.social avatar

I sometimes just love !

I am busy with testing for my next implementation, for a remindMe bot idea.

The main idea is to allow users to mention it and say @remindMe 2 weeks 3 days 2 hours 5 minutes, which would then in turn message them, reminding them of the post which they replied to with this comment.

Such functionality can sometimes be difficult, and regex gets its hate for speed, complexity, and readibility. But this just works great in for a problem like this.

Here is the of an early prototype and example for those interested!

The bot is also at @remindMe, but it isn't operational yet. You can follow it for updates.

https://gist.github.com/e-dreyer/ce0f5e8c51d6454f91901f78f9e04b77

@Python

Stark9837, to random
@Stark9837@techhub.social avatar

@nicdex The logo is really horrible and the original Mastodon logo was so much better. Can we please have an option to turn it off?

Stark9837,
@Stark9837@techhub.social avatar

@vintprox @nicdex

Here is the for anyone wanting to remove the logo. Use this script in

https://gist.github.com/e-dreyer/8ae81aca2426d3f00cb20f770eff5f46

Stark9837, to python
@Stark9837@techhub.social avatar

@folkerschamel recently introduced me to product in . At first, it was odd and weird, but it really makes nested loops more elegant.

Original post: https://mastodon.social/@folkerschamel/110820141813190538

Here is the of a great example: https://gist.github.com/e-dreyer/81b5bc96c90926939ba8057109dfb202

@Python

Stark9837, to python
@Stark9837@techhub.social avatar

How would you feel about a to introduce Paths to ?

When using a dictionary:

MyDict = { "key1": "value1", "key2": { "key3": "value3" } }
Normally, to access "value3," you would need:

MyDict["key2"]["key3"] or MyDict.get("key2").get("key3")

And that is if you are 100%, the key does exists, otherwise you need to have a default value in order to have the second get not to fail:

MyDict.get("key2", {}).get("key3")

If we could use Json paths, we could simply use:

MyDict["$.key2.key3"]

Example of a library:

Glom

@Python

Stark9837,
@Stark9837@techhub.social avatar

@baderdean

The best solution is to proably make an ABC class of dict and then parse the JSON and throw your own exceptions.

I recently did something similar with the config files for my bots. I have a ConfigAccessor class, which reads a YAML file to a dict. What I found was, that if a user miss-configured their file, everything crashed due to missing keys etc.

So I made this class which handled it for me, and I just treat it like a normal dictionary. Here is the

https://gist.github.com/e-dreyer/878d2e8de3686495cbd1fc001f2231f7

@Python

folkerschamel, to python
@folkerschamel@mastodon.social avatar

for fans:
where does this error come from?


In my opinion, one of the great things about is that it's simple and straightforward - you don't get unexpected surprises. But there are a few exceptions, as this example shows.😉

Stark9837,
@Stark9837@techhub.social avatar

@folkerschamel @djvdq

This is the first one off the top of my head. Sorry, I just got home from work.

https://gist.github.com/e-dreyer/19f0b5470b96d73a36180be4e24bb1d9

@Python

Stark9837,
@Stark9837@techhub.social avatar

@folkerschamel @djvdq

Lol, now I am on a roll! Here is another. For taking 3 dicts with the same structure and getting the separate values of matching keys

https://gist.github.com/e-dreyer/2e8a0c5d10522bd7860dff946f07ad0c

@Python

Stark9837,
@Stark9837@techhub.social avatar

@folkerschamel @djvdq

Last one😂 I promise!

Deep comparison of dicts using zip. This is possibly useless in higher level languages, but in something like C and C++, you would need this.

Well, also not. C++ allows for operator overloading, so you could overload == and in you could define eq, so it is one of those toy problems:

https://gist.github.com/e-dreyer/5cc62448cb58400399804d3b72756001

@Python

Stark9837,
@Stark9837@techhub.social avatar

@folkerschamel @djvdq

Final one, you just triggered my itch. Copying missing keys between dicts.

This one, for example, I used with an plugin:

https://gist.github.com/e-dreyer/eb421026e66ed4ad92140803df95dbfe

@Python

Stark9837, to python
@Stark9837@techhub.social avatar

threading, asyncio, and multi-processing

Recently, as I've worked on , I have enountered many situations where my code waits, takes a long time to execute, and my main loop is blocked.

With my @3dprinting bot, this only happens on the first run of a clean config, where all previous posts are fetched from the API and stored in a database The reason is irrelevant, but basically for metrics.

Thus, when the bot starts, it makes about 1.3k requests, one for every post by the bot. This can take about 10 minutes, with the API, paging, network speed, and rate limiting.

During this time, no mentions, new followers, or any other notifications are processed. Then BAM! Everything goes through, and WOW, we are back on track.

@Python

Stark9837,
@Stark9837@techhub.social avatar

@baderdean

I got it to work now. Seems because you need to use asyncio.run() you need to wrap al the functions with async, then have another function which you then call.

Will share the once I clean it up.

@Python

Stark9837,
@Stark9837@techhub.social avatar
Stark9837, to python
@Stark9837@techhub.social avatar

I am busy messing around with , for API consumption, but the API library isn't implemented with asyncio.

I can either fork the library and possibly switch its request object with an async version, but often we might not be able to do this and we need to work with blocking functions.

I struggled to get this working in my current code, so I tried it in another file and got it to work. There are still a few things I could change, allowing for more threads and using an executor, but here is the

https://gist.github.com/e-dreyer/82196b2781b3ebc9429c8bb6607651ff

bp, to random
aral, to programming
@aral@mastodon.ar.al avatar

The Stripe API doesn’t include a way to validate publishable and secret API keys.

Here’s a simple function you can use to do that:
https://codeberg.org/aral/gists/src/branch/main/validateStripeKey.md

aral, (edited ) to programming
@aral@mastodon.ar.al avatar

SystemError typedef for Node.js (gist)

https://codeberg.org/aral/gists/src/branch/main/SystemError.md

Node.js doesn’t expose the SystemError class in any way. This JSDoc type definition works around this limitation.

Update: Yeah, Node.js should really just expose the SystemError class because this is ridiculous.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • cisconetworking
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • InstantRegret
  • Durango
  • Youngstown
  • slotface
  • thenastyranch
  • love
  • kavyap
  • tacticalgear
  • tester
  • provamag3
  • khanakhh
  • ngwrru68w68
  • everett
  • osvaldo12
  • rosin
  • cubers
  • GTA5RPClips
  • normalnudes
  • modclub
  • ethstaker
  • Leos
  • anitta
  • JUstTest
  • All magazines