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.

barubary, to random

calendar
cylinder
colander

barubary, to random

who turgled

isotopp, to random German
@isotopp@chaos.social avatar

https://www.heise.de/news/Unternehmen-suchen-haenderingend-Zu-wenig-Fachkraefte-zu-viel-Regulierung-9573743.html

Tldr: Unternehmen können viele Stellen nicht besetzen, will sie nicht genügend bezahlen wollen, überkommene Arbeitsmodelle haben, die remote nicht integrieren, und weil in Betrieben unzureichend Englisch gesprochen wird.

In Summe schließen sich Unternehmen so vom weltweiten Fachkräftemarkt aus und haben Probleme mit jungen Arbeitnehmern erfolgreich zusammen zu arbeiten.

Die deutsche Arbeitgeber-Unflexibilität bricht der deutschen IT das Genick.

barubary,

@isotopp

Details zu diesen Ergebnissen und mehr Zahlen <a href="file:///Users/fo/Downloads/231213bitkom-chartsit-fachkraeftefinal.pdf" rel="external noopener" target="_blank">finden sich in der Umfrage</a>.

Wie geht dieses Internet nochmal?

ovid, to webdev
@ovid@fosstodon.org avatar

Just spotted this in some for some relatively new code: <p class="color-red font-small">

At that rate, why even bother? HTML 3.2 all the way, baby! Bring back the <style> tags! Or HTML 4 <font> tags. Who needs ?

barubary,

@ovid Oh, is that the Tailwind stuff?

da_667, to random

"There's nothing wrong with storing your shit in the cloud, DA, you're just paranoid."

https://www.cnbc.com/2023/12/13/how-to-stop-dropbox-from-sharing-your-personal-files-with-openai.html

barubary,

@da_667 """temporarily shared"""

feorag, to random
@feorag@wandering.shop avatar

After a brief stop in Koblenz for manti, and a power walk back to the station, I am on a train to Trier.

barubary,

@bellinghman @feorag Oh, right! Hadn't thought about it in a while but I remember the signs by his house, in German and Chinese. :-)

rrwo, to random
@rrwo@floss.social avatar

I have a question.

Given a list of regular expressions, how can I efficiently test them all against a string, and return the first one that matches?

I need to know which regex matches, because I will need to run different different methods depending on the regex.

Is there something more efficient than simply iterating over the list and trying each regex?

Should I use a pipe separator and backtracking control verbs to mark patterns? https://perldoc.perl.org/perlre#Special-Backtracking-Control-Verbs

barubary,

@rrwo Apart from performance, combining the regexes doesn't work in general because of backreferences. Matching (.)1 in isolation means something different than (hello)|(.)1.

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".

barubary,

@user8e8f87c 's rules for variable interpolation in double-quoted strings are arcane and only partially documented, so some of this is an educated guess.

  • The middle one, ${lol[010] }, is the only one that works as expected: The constant 010 is parsed as octal because it starts with a zero, so this accesses $lol[8]. (The other brace notation, "{$lol[010]}", gives the same result.)
  • Without curly braces, a different syntax rule is in effect: The part in [ ] must be a sequence of digits or an identifier; in either case it is used literally as a string key: "$x[123]" accesses $x['123'], "$x[hello42]" accesses $x['hello42'], and "$x[000]" accesses $x['000']. And in this program, "$lol[010]" accesses $lol['010'] without any octal interpretation.
  • The last one, ${ lol[010]}, somehow causes the parser to forget that it is supposed to look for a variable name. Instead it treats lol[010] as a general expression: lol is resolved as a constant, then "greetings"[010] (equivalent to "greetings"[8]) is just "s". Finally ${ "s" } is used to look up the value of $s at runtime.
SteveBologna, to random
@SteveBologna@mstdn.social avatar

This is a comic I’d buy

barubary,

@SteveBologna To the image description I'd like to add it's a parody of the famous Iron Man "Demon in a Bottle" cover by Bob Layton.

barubary, to random German

O-Ton Adonin

sluttymayo, to random
@sluttymayo@jorts.horse avatar

thank goodness the word "jinx" derives from an ancient greek name for a bird (hera turned somebody into one for some zeus-related romance shenanigans, usual stuff). it looks so much like it could be one of those words that everybody has been saying since the 1910s that's actually an awful slur or something.

barubary,

@sluttymayo Also, don't look up Jynx.

fedithom, to IT
@fedithom@social.saarland avatar

Ich mal wieder, und
Ich will per RegEx einen String in einem Dokument finden, der immer mit ABC anfängt. Danach folgt einen unterschiedliche Menge an (unterschiedlichsten) Zeichen, und zum Schluss immer 2 Zahlen.
Ersetzen will ich danach die beiden Zahlen, ohne dass ABC oder der wilde Kram zwischen den beiden angefasst wird.

Geht sowas? Und wenn ja, wie?
(Und: Hab ich das ausreichend gut erklärt?)

(Update: Mittelteil hat unterschiedliche Zahl an Zeichen)

barubary,

@fedithom Welches Tool bzw. welche Programmiersprache? Beispielhaft Lösungen in Perl:

  • s/(ABC.{42})d{2}/${1}Ersatz/a
  • s/ABC.{42}Kd{2}/Ersatz/a
  • s/(?<=ABC.{42})d{2}/Ersatz/a

(Bitte jeweils 42 und Ersatz durch die korrekte Zeichenzahl bzw. Ersatz-Zeichenfolge ersetzen.)

Und vim:

  • :%s/(ABC.{42})dd/1Ersatz/
  • :%s/ABC.{42}zsdd/Ersatz/
  • :%s/%(ABC.{42})@<=dd/Ersatz/
barubary,

@fedithom Hmm, Atom kenne ich nicht. Ich bin mir nicht sicher, ob ich die Problemstellung korrekt verstanden habe, aber hier ist eine Lösung in vim für folgendes Problem: "Finde eine Gruppe von drei Zeilen, von denen die erste mit "INT" anfängt, die zweite mit "|:", und die dritte mit "|" und einer Ziffer. Wenn das Ende der dritten Zeile aus "|" gefolgt von einer Zahl besteht, ersetze diese letzte Zahl durch 14."

:%s/^INT.*n|:.*n|d.*|zsd+$/14/

barubary, to DuckDuckGo

This is why sucks: Only one (irrelevant) search result for "this bridge was written".

barubary,

@jaror

main = do putStrLn (cycle "buffalo " ++ !getLine)<br></br>
hennell, to RegEx
@hennell@phpc.social avatar

This is pretty neat. A better way to in ? 🤔

https://github.com/gherkins/regexpbuilderphp

barubary,

@hennell Can't wait to replace $i++; by

$statement = $builder<br></br>    ->expression()<br></br>    ->fetch(variable('i'))<br></br>    ->add(number(1))<br></br>    ->store('i');<br></br><br></br>$statement->execute();<br></br>
barubary, to random

Man, I love getting blocked by https://www.bahn.de

Access Denied

You don't have permission to access "http://www.bahn.de/" on this server.

Reference .1f771302.1701619128.cf4cee6d

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
Oops, feel free to ignore this. It's answering the wrong question.

Are you familiar with the concept of vtables from C++ and friends? In Haskell they're called "method dictionaries" and they travel separately from values.
A typeclass constraint like Monad m => ... compiles to an extra parameter Monad_dict m -> .... A class declaration like

class Monad m where {<br></br>  return :: a -> m a;<br></br>  (>>=) :: m a -> (a -> m b) -> m b;<br></br>}<br></br>

secretly turns into a type declaration

data Monad_dict m = Monad_dict {<br></br>  return :: a -> m a;<br></br>  (>>=) :: m a -> (a -> m b) -> m b;<br></br>}<br></br>

An instance declaration is simply a value of this type:

monad_instance_List :: Monad_dict []<br></br>monad_instance_List = Monad_dict {<br></br>  return = x -> [x],<br></br>  (>>=) = x f -> concatMap f x<br></br>}<br></br>

Any use of a method like return x becomes return dict x (where dict is the compiler-generated parameter corresponding to the class constraint).

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.

barubary, to random

Pon-farrted so hard my Spock flew off and terraformed a planet

Tipa, to haskell
@Tipa@gamepad.club avatar

I just completed "Toboggan Trajectory" - Day 3 - Advent of Code 2020 https://adventofcode.com/2020/day/3 Okay taking a break. This is my second program. It is taking me a long time to write them.

barubary,

@Tipa foldr (*) 1? That looks a lot like product.

barubary, to random Latin

Mortuus est. Bene.

SwiftOnSecurity, to random

Sunshine (2007) is IMO one of the best space-travel movies ever. The aesthetics, the vibes, the design, the tone, it’s a must-watch. The ending may not stick but oh my god the journey. The fucking JOURNEY.

video/mp4

barubary,

@asharas How did you "misread" a movie?

barubary,

@asharas If you misread what Tay wrote, a natural response would've been "Sunshine isn't a time-travel movie" or "What time travel?" You, on the other hand, specifically criticized the movie for its depiction of time travel: "[...] nothing makes sense, the time travel is pure speculation [...] Looper and Predestination were much better time travel movies on all accounts."
And when someone pointed out that Sunshine doesn't have time travel, you didn't correct yourself or acknowledge the issue; instead you got pissy that they didn't specifically list the parts you got right, for some reason. (And when they did list the correct parts of your critique, you tried to argue the same points they already agreed with!)
How does any of this make sense?

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