Skip Navigation
Oh boy what a beautiful regex. I'm sure it does something logical and easy to understand.
  • Regex is good for a few very specific things, and sysadmins used to use it for goddamn everything. If all your server logs are in lightly-structured text files on a small number of servers, being able to improvise regex is damn useful for tracking down server problems. Just write a shell loop that spawns an ssh logging into each server and running grep over the log files, to look for that weird error.

    These days, if you need to crunch production server logs you probably need to improvise in SQL and jq and protobufs or systemd assmonkery or something.

    But if you actually need a parser, for goodness sake use a parser combinator toolkit, don't roll your own, especially not with regex. Describing your input language in plain Haskell is much nicer than kludging it.

    (This is the "totally serious software engineering advice" forum, right?)

  • TIL that recipes are not protected by copyright law in the USA (and likely Canada)
  • Yep. This is why online recipe sites put a whole goddamn personal essay before the actual recipe: if someone scrapes the page and copies it, they'll scrape the (copyrightable) essay as well as the (non-copyrightable) recipe.

  • Oh boy what a beautiful regex. I'm sure it does something logical and easy to understand.
  • The answer given in the spoiler tag is not quite correct!

    Test case

    According to the spoiler, this shouldn't match "abab", but it does.

    Corrected regex

    This will match what the spoiler says: ^.?$|^((.)\2+?)\1+$

    Full workup

    Any Perl-compatible regex can be parsed into a syntax tree using the Common Lisp package CL-PPCRE. So if you already know Common Lisp, you don't need to learn regex syntax too!

    So let's put the original regex into CL-PPCRE's parser. (Note, we have to add a backslash to escape the backslash in the string.) The parser will turn the regex notation into a nice pretty S-expression.

    > (cl-ppcre:parse-string "^.?$|^(..+?)\\1+$")
    (:ALTERNATION
     (:SEQUENCE :START-ANCHOR (:GREEDY-REPETITION 0 1 :EVERYTHING) :END-ANCHOR)
     (:SEQUENCE :START-ANCHOR
      (:REGISTER
       (:SEQUENCE :EVERYTHING (:NON-GREEDY-REPETITION 1 NIL :EVERYTHING)))
      (:GREEDY-REPETITION 1 NIL (:BACK-REFERENCE 1)) :END-ANCHOR))
    

    At which point we can tell it's tricky because there's a capturing register using a non-greedy repetition. (That's the \1 and the +? in the original.)

    The top level is an alternation (the | in the original) and the first branch is pretty simple: it's just zero or one of any character.

    The second branch is the fun one. It's looking for two or more repetitions of the captured group, which is itself two or more characters. So, for instance, "aaaa", or "abcabc", or "abbaabba", but not "aaaaa" or "abba".

    So strings that this matches will be of non-prime length: zero, one, or a multiple of two numbers 2 or greater.

    But it is not true that it matches only "any character repeated a non-prime number of times" because it also matches composite-length sequences formed by repeating a string of different characters, like "abcabc".

    If we actually want what the spoiler says — only non-prime repetitions of a single character — then we need to use a second capturing register inside the first. This gives us:

    ^.?$|^((.)\2+?)\1+$.

    Specifically, this replaces (..+?) with ((.)\2+?). The \2 matches the character captured by (.), so the whole regex now needs to see the same character throughout.

  • have you ever been given a warning or suspension for using profane language at work?
  • If someone doesn’t understand the difference between swearing at and swearing around, that’s a shitty environment.

    In one of my better workplaces, the expression was "you can cuss the hardware, you can cuss the software, but don't cuss your teammate."

  • Google security group discovers North Korean campaign targeting security researchers
    blog.google Active North Korean campaign targeting security researchers

    Threat Analysis Group shares findings on a new campaign by North Korean actors targeting security researchers.

    Active North Korean campaign targeting security researchers

    > Similar to the previous campaign TAG reported on, North Korean threat actors used social media sites like X (formerly Twitter) to build rapport with their targets. In one case, they carried on a months-long conversation, attempting to collaborate with a security researcher on topics of mutual interest. After initial contact via X, they moved to an encrypted messaging app such as Signal, WhatsApp or Wire. Once a relationship was developed with a targeted researcher, the threat actors sent a malicious file that contained at least one 0-day in a popular software package.

    [...]

    > In addition to targeting researchers with 0-day exploits, the threat actors also developed a standalone Windows tool that has the stated goal of 'download debugging symbols from Microsoft, Google, Mozilla and Citrix symbol servers for reverse engineers.' The source code for this tool was first published on GitHub on September 30, 2022, with several updates being released since. On the surface, this tool appears to be a useful utility for quickly and easily downloading symbol information from a number of different sources. Symbols provide additional information about a binary that can be helpful when debugging software issues or while conducting vulnerability research. > > But the tool also has the ability to download and execute arbitrary code from an attacker-controlled domain. If you have downloaded or run this tool, TAG recommends taking precautions to ensure your system is in a known clean state, likely requiring a reinstall of the operating system.

    [...]

    > As part of our efforts to combat serious threat actors, TAG uses the results of our research to improve the safety and security of Google’s products. Upon discovery, all identified websites and domains are added to Safe Browsing to protect users from further exploitation. TAG also sends all targeted Gmail and Workspace users government-backed attacker alerts notifying them of the activity and encourages potential targets to enable Enhanced Safe Browsing for Chrome and ensure that all devices are updated.

    1
    Do you grow Brugmansia (Angel's Trumpet)? If so, why?

    Some folks in my area grow this plant. It seems really dangerous.

    Brugmansia produces anticholinergic toxins that can cause permanent neurological damage. It's closely related to the Datura genus, also known as jimsonweed, devil's snare, or loco weed.

    It's kinda pretty, but it baffles me that it's so popular as a front-yard ornamental plant. If your child or dog eats a flower from this plant, they will probably have a bad trip that they may never recover from.

    So why grow it? Are you sure nobody you care about will ever stick it in their mouth?

    No trolling. This actually baffles me.

    2
    Maro’s Teaser for Wilds of Eldraine
    markrosewater.tumblr.com Maro’s Teaser for Wilds of Eldraine

    Before previews for Wilds of Eldraine officially begin, I thought it would be fun to do another of my Duelist-style teasers where I give tiny hints of things to come. Note that I’m only giving you...

    First up, here are some things you can expect:

    • a new type of token (at least done as a cohesive theme)
    • a card that can activate to copy enchantments
    • Adventures on a new permanent type
    • an artifact that has two different artifact subtypes normally associated with artifact tokens
    • a creature type from Alpha gets a draft archetype
    • fairy tale Sagas
    • multiple legendary Foods
    • a new card with a lobotomy effect
    • a creature with two triggers, one for artifacts entering the battlefield and one for enchantments
    • a new mechanic that batches together three items that have been in the game since Alpha but never batched before

    Next, here are some rules text that will be showing up on cards:

    • “If a permanent entering the battlefield causes a triggered ability of a permanent you control to trigger, that ability triggers an additional time.”
    • “Look at the top twenty cards of your library.”
    • “it produces three times as much of that mana instead.”
    • “Sacrifice all Reflections you control.”
    • “Creatures you control with +1/+1 counters on them have all activated abilities of all creature cards exiled with CARDNAME.”
    • “have base power and toughness 4/4 and flying.”
    • “exile up to one other non-Fox creature”
    • “Land creatures you control”
    • “Whenever you tap an untapped creature an opponent controls,”
    • “X is 2 plus the number of cards in your graveyard that are instant cards, sorcery cards, and/or have an Adventure.”

    Here are some creature type lines from the set:

    • Creature – Mouse
    • Creature – Rabbit Unicorn
    • Creature – Faerie Shapeshifter
    • Creature – Elf Fox Knight
    • Creature – Giant Archer
    • Creature – Plant Wurm
    • Creature – Elemental Raccoon
    • Legendary Creature – Rat Noble
    • Legendary Creature – Vedalken Scout
    • Legendary Creature – Human Warlock Bard

    Finally, here are some names in the set:

    • Candy Grapple
    • Charming Scoundrel
    • Food Fight
    • Protective Parents
    • Scream Puff
    • Stroke of Midnight
    • A Tale for the Ages
    • Three Blind Mice
    • Three Bowls of Porridge
    • Up the Beanstalk
    15
    I just saw a flash of another user's main page that refreshed into mine.

    Just now, loading the page https://lemmy.world, I saw a different user's main page. The page loaded in light mode (I use dark) with the username of /u/froodloop in the top right. Then a moment later, it refreshed into my expected main page with my username in top right. This went past too quickly to get a screenshot, but it was reminiscent of some of the bugs that were happening in the old websocket code.

    10
    What's the oldest live Arena bug that actually breaks the rules?

    Here's one from almost a year ago that is still live today.

    If you have [[Muldrotha]] out, you should be able to cast a creature from your graveyard once per turn. But if you have a creature with Evoke in your graveyard — such as [[Mulldrifter]] — Arena allows you to repeatedly cast it for its Evoke cost. This shouldn't be allowed, since Evoke doesn't change the timing of when you're allowed to cast a spell.

    0
    Moderators & admins: What's the best way for users to report spam accounts? (Or not at all?)

    I'm starting to notice spam accounts here — accounts that do nothing but post and crosspost links to low-quality or promotional websites.

    My inclination is to simply downvote and report each spam post, but this maybe generates a lot of mod queue activity for community moderators. And when an account is used for nothing but spam, presumably that would be better handled by admins banning the account than by each community moderator needing to respond individually to each spam post.

    And maybe by the time mods or admins get around to looking at the reports, they've already noticed the spam and responded to it directly.

    So — if you're a community moderator or an instance admin, what are your preferences for receiving reports of spam accounts? Is it worth it to you to get reports of spam posts, or messages pointing out a spammer account, or would you prefer that we just downvote, block, and move on?

    12
    YSK: While you're on Lemmy/Kbin/Fediverse, you're not "the product" but you're also not "the customer".

    Why YSK: Getting along in a new social environment is easier if you understand the role you've been invited into.

    ----

    It has been said that "if you're not paying for the service, you're not the customer, you're the product."

    It has also been said that "the customer is always right".

    Right here and now, you're neither the customer nor the product.

    You're a person interacting with a website, alongside a lot of other people.

    You're using a service that you aren't being charged for; but that service isn't part of a scheme to profit off of your creativity or interests, either. Rather, you're participating in a social activity, hosted by a group of awesome people.

    You've probably interacted with other nonprofit Internet services in the past. Wikipedia is a standard example: it's one of the most popular websites in the world, but it's not operated for profit: the servers are paid-for by a US nonprofit corporation that takes donations, and almost all of the actual work is volunteer. You might have noticed that Wikipedia consistently puts out high-quality information about all sorts of things. It has community drama and disputes, but those problems don't imperil the service itself.

    The folks who run public Lemmy instances have invited us to use their stuff. They're not business people trying to make a profit off of your activity, but they're also not business people trying to sell you a thing. This is, so far, a volunteer effort: lots of people pulling together to make this thing happen.

    Treat them well. Treat the service well. Do awesome things.

    205
    What's your flavor win of the day? (Cute plays brag thread)

    Just now on Arena I was playing against a [[Sauron, the Dark Lord]] Historic Brawl deck. I realized that I had lethal, but played the last 1-mana creature in my hand before attacking.

    I then realized that I'd just played [[Delighted Halfling]].

    Before beating Sauron.

    0
    YSK: If you make popcorn in a pot on the stove, the oil to use is ghee.

    Why YSK: Popcorn fans often want a buttery flavor, but plain butter is a bad choice for popping popcorn in a pot, because the proteins and sugars smoke and burn around the same temperature where it's hot enough to pop the kernels.

    Ghee, or Indian-style clarified butter, is butter that's been simmered and the milk solids (proteins and sugars) skimmed off. This leaves a clear yellow oil that doesn't smoke when it's heated and doesn't go rancid quickly, but has a distinct toasty butter flavor.

    Vegetable oil is either flavorless or faintly bitter, and some high-temperature vegetable oils tend to start polymerizing (i.e. becoming plastic) when heated in small amounts. This is also not good for popcorn.

    Good-quality popcorn popped in ghee reliably produces lots of "butterfly" popcorn with few unpopped "duds" and no scorched kernels or batches ruined by smoke.

    Try it! I'm sure not going back to canola oil.

    30
    Suggestion: When posting news articles, first follow links to the original source.

    Many "news" sites on the Web are really just private link-aggregators with extra ads. They don't do original reporting; they just link to and summarize an article that someone else wrote, while surrounding it with extra ads.

    For example, most news articles that appear on Boing Boing and similar sites are really just links to an article published elsewhere, which was written by an actual reporter for an actual news service. The reporter's article may be one or two links away from the aggregator's page, as news services sometimes also link to other news services.

    What the link aggregator adds is ... ads. Lots of them, usually poor-quality ones. And nobody needs another dose of Outbrain or Taboola.

    Example: Boing Boing postOriginal article at the BBC.

    A reader who's interested in the subject of the article is going to want to get to the actual source, not just the link-aggregator page. So it's usually better for the poster here to post the original article, not the link-aggregator page.

    0
    Go visit the mtgzone.com communities!

    There's a more featureful Magic community (actually several) hosted on mtgzone.com. They have a card fetcher bot and everything. Go visit them!

    0
    Welcome, planeswalkers!

    I created this to see if folks are interested in migrating from Reddit's /r/MagicTCG. I'll gladly turn over moderation to people more organized than myself.

    0
    InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)FU
    fubo @lemmy.world

    No relation to the sports channel.

    Posts 20
    Comments 2.3K
    Moderates