gpl's recent activity

  1. Comment on Programming Challenge: Text compression in ~comp

    gpl Link Parent
    Good catch here, I wrote up the bonuses a little quickly so that I could post before the work day started. I'll fix this now. And nice solution btw :)

    The encoded bytes are not guaranteed to be valid ASCII… E.g., in your example, there are only 3 bytes of 8 that are in the ordinal range [0..128):

    Good catch here, I wrote up the bonuses a little quickly so that I could post before the work day started. I'll fix this now. And nice solution btw :)

    1 vote
  2. In an effort to make these weekly, I present a new programming challenge. The challenge this week is to compress some text using a prefix code. Prefix codes associate each letter with a given bit...

    In an effort to make these weekly, I present a new programming challenge.

    The challenge this week is to compress some text using a prefix code. Prefix codes associate each letter with a given bit string, such that no encoded bitstring is the prefix of any other. These bit strings are then concatenated into one long integer which is separated into bytes for ease of reading. These bytes can be represented as hex values as well. The provided prefix encoding is as follows:

    char value char value
    ' ' 11 'e' 101
    't' 1001 'o' 10001
    'n' 10000 'a' 011
    's' 0101 'i' 01001
    'r' 01000 'h' 0011
    'd' 00101 'l' 001001
    '~' 001000 'u' 00011
    'c' 000101 'f' 000100
    'm' 000011 'p' 0000101
    'g' 0000100 'w' 0000011
    'b' 0000010 'y' 0000001
    'v' 00000001 'j' 000000001
    'k' 0000000001 'x' 00000000001
    'q' 000000000001 'z' 000000000000

    Challenge

    Your program should accept a lowercase string (including the ~ character), and should output the formatted compressed bit string in binary and hex. Your final byte should be 0 padded so that it has 8 bits as required. For your convenience, here is the above table in a text file for easy read-in.

    Example

    Here is an example:

    $> tildes ~comp
    10010100 10010010 01011010 10111001 00000010 11000100 00110000 10100000
    94 92 5A B9 02 C4 30 A0
    

    Bonuses

    1. Print the data compression ratio for a given compression, assuming the original input was encoded in 8 bit ASCII (one byte per character).
      2. Output the ASCII string corresponding to the encoded byte string in addition to the above outputs.
    2. @onyxleopard points out that many bytes won't actually be valid ASCII. Instead, do as they suggested and treat each byte as an ordinal value and print it as if encoded as UTF-8.
    3. An input prefixed by 'D' should be interpreted as an already compressed string using this encoding, and should be decompressed (by inverting the above procedure).

    Previous Challenges (I am aware of prior existing ones, but it is hard to collect them as they were irregular. Thus I list last week's challenge as 'Week 1')
    Week 1

    11 votes
  3. Comment on Tildistas, what is your favorite poem? in ~books

    gpl Link Parent
    If you have not, check out the short story by the same name and similar in theme, written by Ray Bradbury.

    There Will Come Soft Rains

    If you have not, check out the short story by the same name and similar in theme, written by Ray Bradbury.

    4 votes
  4. Comment on Programming Challenge: Dice Roller in ~comp

    gpl Link
    I am a little late to this since I was travelling, but I wanted to share something a little different. I present the Quantum Dice Roller. This was written in Python 3.7 using IBM's qiskit...

    I am a little late to this since I was travelling, but I wanted to share something a little different. I present the Quantum Dice Roller. This was written in Python 3.7 using IBM's qiskit platform. In order to generate randomness, this program places a single quantum bit (qubit) into a superposition of 0 and 1 with equal probability, and then measures this state in order to return 0 or 1 with perfectly equal probability. It uses these random 0s and 1s to build a random string of 0s and 1s which is interpreted as a binary number in order to get the desired random result. So, for example, if you are rolling a d4 it will find the number of bits needed to represent "4" and create a string of that length. The only catch here is that sometimes the result will be greater than the number of sides. For example, for a d4 the program will create a bit string of length 3, which in principle could be "111" which is greater than 4. Thus, it checks the final result and tries again until a valid result is obtained.

    In principle, this program could be run on one of IBM's actual quantum computers. As it is written, it uses a simulated quantum processor (and thus probably some standard PRNG). However all it would take is changing the specified backend and making an IBM account to change this. I might do so later just for the novelty of it. I'm happy to answer questions if anyone has them

    import math
    from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister, execute, Aer
    
    def parse(string):
        params = [] #will hold relevant data
        if "+" in string:
            dice_info, modifier = string.split("+")
            dice_info = dice_info.strip()
            modifier = int(modifier.strip())
            nrolls = int(dice_info.split("d")[0])
            nsides = int(dice_info.split("d")[1])
            params=[nrolls, nsides, "+", modifier]
        elif "-" in string:
            dice_info, modifier = string.split("-")
            dice_info = dice_info.strip()
            modifier = int(modifier.strip())
            nrolls = int(dice_info.split("d")[0])
            nsides = int(dice_info.split("d")[1])
            params=[nrolls, nsides, "-", modifier]
        else:
            nrolls = int(string.split("d")[0])
            nsides = int(string.split("d")[1])
            params=[nrolls, nsides]
    
        return params
    
    def quantum_roll(nbits, nsides):
    
        max_flag = True
        
        while(max_flag):
            my_backend = Aer.get_backend("qasm_simulator")
            bit_string = ''
            for i in range(nbits):
                q = QuantumRegister(1)
                c = ClassicalRegister(1)
                qc = QuantumCircuit(q, c)
                qc.h(q[0])
                qc.measure(q, c)
    
                job_sim = execute(qc, my_backend, shots=1)
                sim_result = job_sim.result()
                counts = sim_result.get_counts(qc)
                bit = list(counts.keys())[0]
    
                bit_string += bit
            
            result = int(bit_string, 2) + 1
            if (result<=nsides):
                max_flag=False
    
        return result 
    
    
    def main():
        user_in = input("Enter a dice roll in the form _d__ + _ (e.g. 3d4+2): ")
    
        roll_params = parse(user_in)
        nrolls=roll_params[0]
        nsides=roll_params[1]
        
        #[0] is nrolls, [1] is nsides [2] is modifier if any
    
        nbits = nsides.bit_length()
    
        rolls = [] 
        for roll in range(nrolls):
            rolls.append(quantum_roll(nbits, nsides))
            
        total = sum(rolls)
    
        if len(roll_params) > 2:
            if roll_params[2] == "+":
                total += roll_params[3]
            elif roll_params[2] == "-":
                total -= roll_params[3]
            else:
                print("Invalid modifier, ignoring")
    
        roll_str = ",".join([str(x) for x in rolls])
        out = "You rolled the quantum dice {0} times, with results of {1}. This gave a total of {2}".format(nrolls, roll_str, total)
    
        if len(roll_params) > 2:
            out = out+", after a modifier of {} was applied.".format(roll_params[2]+str(roll_params[3]))
        else:
            out = out+"."
    
        print(out)
    
    if __name__=="__main__":
        main()
    
    2 votes
  5. Comment on What are you reading these days? #20 in ~books

    gpl Link Parent
    I agree regarding Don Quixote. What made you decide to go with the Lathrop translation? I read the Grossman translation and I have nothing but praise for it. It manages to salvage as much of the...

    I agree regarding Don Quixote. What made you decide to go with the Lathrop translation? I read the Grossman translation and I have nothing but praise for it. It manages to salvage as much of the wordplay as possible, and, where it cannot, it has helpful footnotes.

    1 vote
  6. Comment on alyaza is unbanned in ~tildes.official

    gpl Link Parent
    Please see my reply to @emdash further up. I understand the moderation process and the fact that it is inherently subjective. That being said, we already agree that some public code of conduct is...

    Please see my reply to @emdash further up. I understand the moderation process and the fact that it is inherently subjective. That being said, we already agree that some public code of conduct is warranted, as Tildes already has one. I am simply suggesting that, at the least, we make that code of conduct a bit more explicit (note that this does not mean it has to totally explicit, in that enumerates every possible violation, just more explicit than "Don't be an asshole", which is currently the only guideline directed towards actual user attitude and tone).

    I question the value of making bans public and open to commentary. There is no benefit in having the general public second-guessing every single ban. That is just distracting noise. Too often, it just turns into a slanging match between users and moderators. And the range of opinions about whether someone should have been banned is as wide and numerous as the number of people on the forum.

    This might be the case - at the least, it is a useful discussion to have. Tildes is still at the stage where it is able to experiment with different solutions. Perhaps there can be a separate "mod queue" that is different than the normal ~ feed, that all users can see but only those with a certain level of trust can comment on. Maybe this isn't necessary at all.

    Aren't you contradicting yourself here somewhat?

    I don't think the initial ban should have been publicized because this is not a policy and was enacted arbitrarily, and in this case ended up containing things that were not true. I do think that if this was standard and widely understood, it might help making the moderation process transparent, promote compliance with codes of conduct, and in general increase satisfaction with moderation.

    3 votes
  7. Comment on alyaza is unbanned in ~tildes.official

    gpl (edited ) Link Parent
    I largely agree with what you're saying, also based on some years of moderating medium sized subreddits. I completely understand that there's no mythical objective standard of moderation and that...

    I largely agree with what you're saying, also based on some years of moderating medium sized subreddits. I completely understand that there's no mythical objective standard of moderation and that ultimately subjectivity enters in - and that's not even a bad thing. That being said, I don't think it's unreasonable to suggest that things can be too arbitrary, and that this is a case that highlights that. Tildes code of conduct currently reads:

    Don't act like an asshole and routinely make other people's experiences—or lives—worse.
    Do not maliciously impersonate someone else's identity (real world or online)
    Do not maliciously attempt to counteract other users' attempts to delete or edit their content, such as by deliberately re-posting content they want to be deleted.
    Do not incite or encourage harm against people, including by posting hate speech or threats.
    Do not post anyone's sensitive personal information (related to either their real world or online identity) with malicious intent.

    As far as I am aware, the only rule that the user in question came close to violating is the first one, which in my opinion is sufficiently broad as to allow banning a user for relatively minor things. I don't think it's unreasonable to suggest that "Don't be an asshole" is insufficient as a policy when moderating 10,000+ (and growing!) people, for precisely the reason you mention: One person's hostility is another's "beautifully worded forceful argument". For example, while alyaza's comments often took a tone that I myself would not take, I was pretty surprised to find that she had been warned about them as they were often not directed at the users but at their arguments (at least from what I saw, which again is limited). I personally don't think 'good faith' discussion inherently precludes calling someones point 'dumb' if you genuinely believe it to be so. Furthermore, there have certainly been users here that have negatively impacted my usage of the site through a perceived overly-contrarian attitude. It's not immediately clear to me what distinguishes the two, and based on the discussions that followed this banning I don't think I'm alone, although perhaps in a minority.

    Anyway, I'm under no impression that there is some objective standard of moderation out there. That being said, I don't believe that "Don't be an asshole" on its own is sufficient when moderating a group of this size. At the very least, having some universally agreed upon standards makes it easier for people to comply to those standards and to understand when there have been violations.

    I hope this doesn't come across as just complaining about moderation, since all things considered I think @Deimos did an okay job here. I do think that this can be an illustrative episode, especially when considering how to implement moderation in the future. I personally am a big fan of the stack exchange approach to moderation as it is relatively democratic, and distributes power across a good range of the user base. In any case, my main point is that the inherent subjectivity of the moderation process doesn't mean that some standards shouldn't be written down.

    EDIT: As pointed out by @Whom, the actual reasons for the ban were an apparent attempt to use an alt account. I initially thought alyaza was banned for hostility, and then apparently used an alt to circumvent this. This was my misunderstanding. That being said, I still stand by the above points regarding arbitrariness so I leave this comment up. I also want to stress that I am not advocating for explicitly enumerating every possible infraction. I just think that this is a good time to consider whether Tildes is at the size where it might benefit from reexamining moderation guidelines, and in doing so considering how those guidelines might be improved.

    8 votes
  8. Comment on alyaza is unbanned in ~tildes.official

    gpl Link
    First of all, I applaud you for owning up to the mistake and taking some steps to fix it. However, I do want to ask: Are there any ideas in the works to prevent this type of thing from happening...

    First of all, I applaud you for owning up to the mistake and taking some steps to fix it.

    However, I do want to ask: Are there any ideas in the works to prevent this type of thing from happening in the future? I mean things like a public set of guidelines for what will constitute a ban, and guidelines for how those bans will be carried out and how they can be appealed? I agree that the initial ban shouldn't have been publicized, and your justification in that post for publicizing it was that "users would have questions". Having a common set of guidelines for bans like this might help in such situations, so users know exactly what to expect from bans.

    Overall, it doesn't sit very well with me. The entire process seemed somewhat arbitrary, from the original ban to now. What counts as 'too hostile', how many infractions are allowed before a ban, some type of systematized way of determining duration of bans, a public way to see why someone was banned (and I would argue comment on it), and an appeals system are all things that might be considered and formalized.

    Ultimately a mistake is a mistake and there's no sense beating that dead horse when it has already been acknowledged. The only thing that makes sense to do is see what flaws in the system this whole episode has highlighted, and how they might be fixed.

    10 votes
  9. Comment on What cultural misunderstandings have you experienced? in ~talk

    gpl Link Parent
    This actually makes much more sense than I would have expected. I wonder if business deals made with this thought process are longer lasting than purely mechanical counterparts.

    My takeaway from a Japanese business class is that the Japanese don't make "deals" like American's do: For them it's not about a single transaction but about a larger relationship.

    This actually makes much more sense than I would have expected. I wonder if business deals made with this thought process are longer lasting than purely mechanical counterparts.

    6 votes
  10. Comment on What cultural misunderstandings have you experienced? in ~talk

    gpl Link Parent
    What's the thought process here from the Japanese side? Evidently they would want the deal to go through too and wouldn't let it get jeopardized by a rude contractor. Do you think there was a...

    What's the thought process here from the Japanese side? Evidently they would want the deal to go through too and wouldn't let it get jeopardized by a rude contractor. Do you think there was a serious chance of it falling though because of that?

    Funny story regardless. Reminds me of the episode in Seinfeld where Lippman won't shake the Japanese CEO's hand because he sneezed and the merger falls through.

    5 votes
  11. Comment on Judge rejects Musk’s arguments to dismiss “pedo guy” defamation suit in ~news

    gpl Link Parent
    I would tend to err on the side of "Social media is a publishing platform to the extent that it is used to make public posts". That is, my private communications with friends using Messenger for...

    I would tend to err on the side of "Social media is a publishing platform to the extent that it is used to make public posts". That is, my private communications with friends using Messenger for example should be treated as private communications. But public posts, regardless of follower counts or level of notoriety, should be treated as a published statement. That only my friends might read my published posts doesn't really change their nature, only their possible effects.

  12. Comment on What are some quality mobile games? in ~games

    gpl Link
    I really like "What?" No clue where the name comes from but it is a simple puzzle game that is relaxing to play.

    I really like "What?"

    No clue where the name comes from but it is a simple puzzle game that is relaxing to play.

  13. Comment on What are your favorite games on the Switch? in ~games

    gpl Link
    I bought a switch a few months ago, and with it I bought Breath of the Wild. I’ve been busier than I would like so I haven’t actually advanced much further than Death Mountain, so I have a lot of...

    I bought a switch a few months ago, and with it I bought Breath of the Wild. I’ve been busier than I would like so I haven’t actually advanced much further than Death Mountain, so I have a lot of play left and probably won’t be getting another game for the foreseeable future. There are worse problems to have I suppose.

    7 votes
  14. Comment on What are you reading these days? #19 in ~books

    gpl Link Parent
    One Hundred Years of Solitude is one of my favorite books of all time, I'm planning on re-reading it sometime soon. Chronicle of a Death Foretold is actually one of the first books I read in...

    One Hundred Years of Solitude is one of my favorite books of all time, I'm planning on re-reading it sometime soon. Chronicle of a Death Foretold is actually one of the first books I read in Spanish, and while I enjoyed it slightly less than One Hundred Years of Solitude, I still loved it.

    3 votes
  15. Comment on Recreating the Oldest Fried Fish Recipe (10th century) in ~food

    gpl Link
    Super cool video, the chefs had a really fun dynamic. Plus, the fish looked really tasty.

    Super cool video, the chefs had a really fun dynamic. Plus, the fish looked really tasty.

    2 votes
  16. Comment on Recommend me a game that _________. in ~games

    gpl Link Parent
    I'll look into these, thanks so much. I was thinking about installing Dwarf Fortress and taking the plunge, but I'm kind of busy irl and don't want to get derailed lol. 0 AD looks really fun,...

    I'll look into these, thanks so much. I was thinking about installing Dwarf Fortress and taking the plunge, but I'm kind of busy irl and don't want to get derailed lol. 0 AD looks really fun, somehow I had never heard of this before. Some of my favorite games are the Total War games and not much other strategy has really managed to scratch that itch.

    2 votes
  17. Comment on Facing criticism, CMPD defends release of shorter video from police shooting in ~news

    gpl Link Parent
    I agree that he should have dropped it quicker, but he was complying with their orders, and I don't think hesitation (if he even is hesitating rather than moving slowing and deliberately, the...

    I agree that he should have dropped it quicker, but he was complying with their orders, and I don't think hesitation (if he even is hesitating rather than moving slowing and deliberately, the video is unclear) warrants execution. What's the point of issuing orders if you're going to shoot them when they are complying? What's the point of even complying in the first place?

    I understand this is a stressful situation for the cops, but its a stressful situation for the suspect-turned-victim too. Ultimately this is the cops fault - they gave him an order that, through his compliance, made them think they were in danger. If he hadn't dropped the gun, would they have been justified in shooting him for not obeying? Was there any way out of this were the man did not get shot?

    5 votes
  18. Comment on Recommend me a game that _________. in ~games

    gpl Link
    Recommend me a good strategy/base building game, but that would run well on Arch Linux.

    Recommend me a good strategy/base building game, but that would run well on Arch Linux.

    2 votes
  19. Comment on What OS do you use and what are your favourite programs? in ~comp

    gpl Link
    I run Arch Linux, although I do have a Windows 10 install in another partition that I hardly use. I don't have much specialty software installed, however. I use i3-gaps as a WM, polybar for my...

    I run Arch Linux, although I do have a Windows 10 install in another partition that I hardly use. I don't have much specialty software installed, however. I use i3-gaps as a WM, polybar for my status bar, xorg for displaying things. I'm a vim user but still trying to optimize my usage. Other than this I use Chromium because its what I'm used to, but I am certainly open to switching.

    I have irssi for IRC but I don't use it much these days (is there a tildes channel?), spotify for music, vimiv for images. That's about it, I don't really need much else for day to day usage. I have an iPad that I watch netflix and hulu on. The big open question for me right now is how to best take notes on my latop. I want some type of personal wiki I think, since I am used to that format and it's ultra flexible. I used to have vimwiki installed but I found it quite counter intuitive, but maybe I will give that another go. The thread on here from a few days ago was particularly useful, I have to go read through that again.

    1 vote
  20. Comment on It: Chapter Two - Official Teaser Trailer in ~movies

    gpl Link
    Wow, what a great trailer. I enjoyed the first one but now I’m excited for this one.

    Wow, what a great trailer. I enjoyed the first one but now I’m excited for this one.

    2 votes