• 2 Posts
  • 2.45K Comments
Joined 3 years ago
cake
Cake day: June 18th, 2023

help-circle





  • NaibofTabr@infosec.pubto196@lemmy.blahaj.zonerule
    link
    fedilink
    English
    arrow-up
    13
    ·
    1 day ago

    Right, but this expression has an explicit ^ and $, so if there’s anything else in the input line besides a single instance of the pattern, it won’t match. This makes the g kind of pointless, there can’t possibly be multiple instances of the pattern in the same line and still return a valid match.



  • Meat/eggs/dairy, definitely.

    Vegetables, maybe, depending on what else they’ve touched.

    Dry/canned goods, probably not unless they’re wet (e.g if it’s in a cardboard box or paper package and it’s damp, it’s not worth the risk - if we’re talking about grocery store waste then for all you know that was water used to wash the butcher’s work station or mop the floor).

    Bacterial contamination is your primary concern, and after that mold. Salmonella could just end your life.


  • So, here’s a problem: food logistics is a massive, complicated morass of infrastructure. Getting food from the area where it’s produced to the area where there are people who want to eat it is difficult. A lot of individual steps have to go right for a bell pepper grown in Coahuila to show up in a grocery store in Tokyo, unspoilt and ready to eat.

    The timing of when the pepper is picked, how fast it will ripen and how long until it spoils is built into the steps of the supply chain. The cost of the logistics system for distributing food, and the overhead for managing and containing the chaos, is probably substantially higher than the cost of actually producing the food.

    The point being, when the bell pepper is at the store it is now ready for consumption. It will be there 2, maybe 3 days, and then if it is unsold it is at least halfway to rotten. Now at this point you want to try to redistribute it, which will require another supply chain, but there isn’t time to figure out where to send an overripe bell pepper or who would want to eat it, or to pack it and ship it and then unpack it and hopefully use it before it’s completely rotten.

    Refrigeration is a wonderful technology that has brought massive reduction of food waste, but it has limits. You can’t un-ripen a fruit. Trying to re-ship food at this point would not be worth the cost, and ultimately would create environmental harms that would outweigh any benefit.


    Always buy local, as much as you can!





  • NaibofTabr@infosec.pubto196@lemmy.blahaj.zonerule
    link
    fedilink
    English
    arrow-up
    93
    ·
    edit-2
    1 day ago

    Basic concept: the purpose of regex is to search input text for matching patterns of characters.

    Assuming this is correct (including the spaces):

    / ^(\d{3}) - (\d{2}) - (\d{5}) \2 \1$ / g

    Then:

    / The first forward slash is the delimiter which tells the code that this is the start of the regex (start interpreting the expression after this).

    ^ The caret marks the beginning of the text string being searched for a match or the beginning of a line of text, meaning that any matches found by the following regex must begin at the beginning of the input text, or at the beginning of a new line of text, not somewhere in the middle of it.

    (\d{3}) This is the first group for matching actual text characters. The \d matches any single digit (0-9). The {3} attached to it means that there must be exactly 3 digits adjacent to each other, no more, no less.

    _-_ (underscore indicating that there is a space in the original expression) This must match a [space][dash][space] as literal characters.

    (\d{2}) As before, this matches two adjacent digits. This is the second matching group.

    _-_ Same as above, [space][dash][space].

    (\d{5}) Same as the two patterns before, this matches five adjacent digits. This is the third group.

    _\2 The [space] here matters, indicating that there must be a space character between the previously matched group of five digits and the following match group \2, which says to match the same text as the most recently matched 2nd group. In this case the second group would be (\d{2}), so this must match the same two digits as were matched by (\d{2}) in the same order.

    _\1 Similar to the above, this must match a [space] and then the same text as the first most recently matched group. In this case that would be the (\d{3}).

    $ This is the same as the ^, only it matches the end of the input text or the end of a line of text. This means that there cannot be any more characters in the input text after the last characters that match the specified pattern.

    / g The / is again a delimiter, indicating the end of the regex. The g means “global”, which instructs the code to search the entire input text for all possible matches and return all of them at the end of the search (default regex behavior is to search until the first match, then stop and return that result).

    So example matches would look like this:
    111 - 22 - 33333 22 111
    012 - 01 - 01234 01 012
    987 - 98 - 98765 98 987

    But this would not match:
    11 - 222 - 33333 222 11 (incorrect numbers of digits in the first and second groups)
    012 - 01 - 01234 10 012 (the second group of 2 digits does not match the first group of 2 digits)
    987-98-9876598987 (spaces are missing)
    111 22 33333 22 111 (dashes are missing)


    Speculation:
    The matched string looks like a serial number or part number or something like that, so probably the use case for this regex is to search through a file containing a long list of such numbers all separated on new lines of text, to find specific ones (for some reason). Maybe numbers that match this pattern are invalid, or maybe only numbers that match this pattern are valid and everything else that might be in the file needs to be removed.

    Based on this I think the end is actually wrong and should be / gm (m for multi-line) to allow for searching (and returning) multiple lines of input text. Otherwise, this should be part of code which splits the lines of the input text file into individual strings and then feeds them through the regex one at a time - but if that’s the case then using the g (global) flag doesn’t really make sense.


    With thanks to https://regex101.com/









  • Rosen misses what he considers to be a bygone era of elite dominance. Lamenting the current state of democratized influence, Rosen says “the old gatekeepers were political professionals who could count cards; small dollar donors today are amateurs yanking the handles of ActBlue slot machines.”

    Abundance adherents often bristle at the suggestion that the project is orchestrated by Silicon Valley elites. But as the leaked documents demonstrate, Rosen and his colleagues clearly view it as such, and even frequently use the word “elite” by choice.

    ROSEN OPERATES AT THE NEXUS of tech titans’ “hostile takeover” of San Francisco politics through a “grey money” network, documented in reporting from The Guardian and Mission Local. The Phoenix Project has dubbed this overlapping set of organizations and campaigns the “Astroturf Network” and detailed its operations in a set of reports and a pair of influence maps.

    These people are villains.