barubary

@barubary@infosec.exchange

Indoor European. I know #regex. I write #code (in #C or #Haskell or #Perl or #JavaScript or #bash).

This profile is from a federated server and may be incomplete. Browse more on the original instance.

jan, to random
@jan@toot.io avatar

ActivityPub servers: 26k+

AT proto servers: 1

What is the current status of federation?

"We do not currently support PDS federation on the production network but it is now possible to federate in the developer sandbox."

https://github.com/bluesky-social/pds

barubary,

@jan "Mom, someone federated in the developer sandbox!"

nonfedimemes, to random
@nonfedimemes@wetdry.world avatar
barubary,

@nonfedimemes I'm pretty sure both are parody accounts.

benzucker, to RegEx German
@benzucker@maly.io avatar

Any #regex wizards here?
Is there a way to match multiple linebreaks regardless of the content but only if the number of linebreaks exceeds a value like 5?

barubary,

@benzucker Probably? I can't really tell what you're looking for.

barubary,

@benzucker n(.*n){3}

castarco, to til
@castarco@hachyderm.io avatar

#TIL Today I learnt that adding ? after * transforms a #regex expression from being "greedy" into "lazy" (important for performance, safe validators, and protection against DoS attacks).

I don't know how I missed this bit of knowledge for so long. :blobfoxbox:

barubary,

@castarco Oh, that doesn't count. The regex finds a match, so there is no catastrophic backtracking.

(As for semantic correctness, both regexes are wrong.)

barubary,

@castarco Can you show me an example of a regex where non-greedy matching reduces the number of alternatives tried?

barubary,

@castarco PS: You can easily get the opposite result by changing the test string: https://regex101.com/r/pRY7Gw/1

(3720 steps for <script>.*?</script>, 30 steps for <script>.*</script>)

barubary,

@castarco I don't see how it protects against DoS attacks. The DoS problem is caused by badly written regexes that take "forever" to fail, so the regex engine is busy trying all possible variations to make the regex match a given string (assuming a standard backtracking implementation).

Making quantifiers non-greedy (by appending ?) does not change the number of ways a regex can match, nor does it shortcut the matching process. It simply changes the order in which alternatives are tried.

In the case of X*, the normal order is to try to match as many X's as possible and only "give back" matches if the rest of the regex fails to match. With X*?, the regex engine will try to match as few repetitions as possible (i.e. 0 at first) and only consume more if the rest of the regex fails to match. In either case all possibilities are tried before giving up.

timlegge, to Perl

@Perl, Published a timeline and write up of the recent module vulnerabilities in parsing spreadsheets.

https://blogs.perl.org/users/timothy_legge/2024/02/vulnerable-perl-spreadsheet-parsing-modules.html

barubary,

@timlegge Broken link/mangled formatting: "A detailed write up of the vulnerability and Proof of Concept (PoC) is available at https://github.com/haile01/perlspreadsheetexcelrcepoc"

barubary, to random

Lead is fine for adults; otherwise all those rock bands wouldn't use it in their guitars.

barubary, to random

Orphans can't become zombies.

barubary, to random

Microservices are great if you hate types and just want to pass strings around.

barubary, to random

@thunderbird Just updated Thunrderbird. Got a web page asking for donations. Page design is kinda sus (doesn't tell you who's behind it, there are no links with more info or "about us", etc., not sure this is even legal in Germany), but I decided to click the Donate button anyway. Got nothing; button doesn't work, just reloads the page. Might want to fix that.

barubary, to VintageOSes

Anyone have a copy of the fcntl man page?

barubary, to ChatGPT

Maybe don't blindly (or at all) trust with your code. Transcript:

You
What's the output?

<?php<br></br>define("lol", "greetings");<br></br>$s = "Everyone!";<br></br>$lol = array(<br></br>  "8" => "Christmas",<br></br>  "010" => "Merry",<br></br>);<br></br><br></br>echo "$lol[010] ${lol[010] } ${ lol[010]}";<br></br>

ChatGPT
In the provided PHP code, you are defining a constant named lol and creating an array $lol with two elements. Let's break down what the echo statement will output:

  1. "$lol[010]": This part will not output as expected. In PHP, variables inside double-quoted strings are parsed, but array indices are not parsed correctly if they are not enclosed in curly braces. Therefore, this part will not output the value of $lol['010'].
  2. "${lol[010]}": This is a correct way to access an array element within a double-quoted string. The curly braces allow PHP to correctly parse the array and its index. This will output "Merry".
  3. "${ lol[010]}": This is similar to the previous part, but with a space after the opening curly brace. PHP is generally tolerant of such spaces, so this should also output "Merry".

However, there's an important note about the array indices: "8" will be interpreted as an integer index (8), but "010" is a bit tricky. In PHP, a number starting with a 0 is considered octal (base 8). However, since 010 is an invalid octal number (octal digits are 0-7), PHP will interpret it as a string index instead. Thus, '010' remains as the string "010".

Putting it all together, the output of the echo statement will be something like:

Notice: Undefined variable: lol in your_script.php on line X<br></br>Merry Merry<br></br>

This notice is generated because $lol[010] is not recognized as a valid array element in the first part of the echo statement. The other two parts correctly output the string "Merry".

kephalos, to haskell German
@kephalos@social.tchncs.de avatar

a question. Is there an active community around here?

I can understand how typeclasses are implemented for typeclass functions that have the implementation type as first argument (such as (>>=) in the Monad typeclass).

But for signatures like return (a -> m a) is there some special magic happening?

I currently assume its compile time type inference from return being used in a context of (>>=), as >>= expects a function (a -> m b)

barubary,

@kephalos Due to the type signature of >>=, all the m type variables have to be the same in your example. The type checker then has to unify m a (from the argument of >>=) with Just 1 :: Maybe Integer and concludes m = Maybe.

darkade, to boardgames
@darkade@dice.camp avatar

deleted_by_author

  • Loading...
  • barubary,

    @efi I think it represents getting shafted.

    barubary,

    @hstde @Spore Even better, the alphabetical index of function names was generated in English first and then translated, meaning the documentation looks like a scrambled mess in any other language because it is alphabetized according to what the English equivalent would be.

    barubary, to random
    barubary, to haskell

    Today I spent a few hours trying to track down a problem deep in a helper module of a complex production application written in . Among other things, it involves threads, a monad transformer stack (3 or 4 levels deep, I think?), an SQL database, and HTTP calls to an external service.

    In the end, I managed to boil one issue in the code down to the following crucial lines:

    forever_mpl :: Monad m => m a -> m b<br></br>forever_mpl m = fix (m >>)<br></br><br></br>forever_mpf :: Monad m => m a -> m b<br></br>forever_mpf m = fix (self -> m >> self)<br></br>
    

    In theory, both of these should be equivalent to forever from the base library. However ...

    In one place in the code, using forever_mpl (the first definition) works correctly: It repeats an action forever. But switching to forever_mpf (the second definition) makes the code hang instead (at 0% CPU). Why?!

    I know the answer now, so here's a challenge: Can you think of a reason why these two definitions should behave differently? Can you implement a Monad instance with a >> that distinguishes between them somehow?

    barubary, to random

    The trick that mathematicians haven't quite figured out yet is that you can combine multiple letters into "words" and use those to name things. Then you don't need five scripts and three separate fonts just to give everything its own unique letter.

    foone, to random
    @foone@digipres.club avatar

    ahhhhhrhgghghr. I finally got around to digging into a Switch game for the first time, because someone wanted me to hack one, and the first thing I see is a filename:
    img/unity_logo.png

    barubary,

    @foone IF U NO, U NO

    barubary, to Cats
    barubary, to random

    "I asked one of those AI things to set up a REST API in Python. First instruction was to install Ruby"

    barubary, to random

    @foone I made something. It's inspired by something you mentioned once, I believe: https://gate.uber.space/dkq/cgi-bin/xencode?q=%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%E2%9A%A7%EF%B8%8F

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