• Activity
  • Votes
  • Comments
  • New
  • All activity
    1. What are you reading these days? #22

      What are you reading currently? Fiction or non-fiction, any genre, any language! Tell us what you're reading, and talk a bit about it. Notes: I am aiming to make a list of all the books mentioned...

      What are you reading currently? Fiction or non-fiction, any genre, any language! Tell us what you're reading, and talk a bit about it.

      Notes: I am aiming to make a list of all the books mentioned in toplevel comments in these threads, see this wiki page. If you want to help with that, that'd really be appreciated, PM me please.

      Past weeks: Week #1 · Week #2 · Week #3 · Week #4 · Week #5 · Week #6 · Week #7 · Week #8 · Week #9 · Week #10 · Week #11 · Week #12 · Week #13 · Week #14 · Week #15 · Week #16 · Week #17 · Week #18 · Week #19 · Week #20 · Week #21

      15 votes
    2. Tildes User Script: Youtube Thumbnails Below Topic Title

      A screenshot. Following is a user script that embeds a thumbnail into the topic header. Was supposed to be trivial, but walking around the CSRP was not that easy. Luckily, someone had written a...

      A screenshot.

      Following is a user script that embeds a thumbnail into the topic header. Was supposed to be trivial, but walking around the CSRP was not that easy. Luckily, someone had written a nice useful custom Base64 encoder, because I spent more than an hour trying to get btoa to do the thing.

      // ==UserScript==
      // @name     tildesYoutubeThumbs
      // @version  1
      // @grant    GM.xmlHttpRequest
      // @namespace   tildes.net
      // @include     https://tildes.net/~*/*
      // ==/UserScript==
      
      let youtubeIcon = document.querySelector('div.topic-icon-youtube_com')
      
      if(youtubeIcon !== null) {
        let youtubeLink = youtubeIcon.nextSibling.nextSibling.href;
        let youtubeID = new URL(youtubeLink).searchParams.get('v');
        let thumbnailUrl = "https://img.youtube.com/vi/" + youtubeID + "/0.jpg";
      
        GM.xmlHttpRequest({
          method: "GET",
          url: thumbnailUrl,
          overrideMimeType: 'text/plain; charset=x-user-defined',
          onload: function(response) {
            if(response.status === 200) {
              let thumbElement = document.createElement('img');
              let thumbParentDiv = document.createElement('div');
              let header = document.querySelector('article.topic-full > header');
              let data = "data:image/jpeg;base64," + customBase64Encode(response.responseText);
              thumbElement.src = data;
              thumbElement.style = 'width: 60%; margin: auto';
              thumbElement.id = 'gk-youtube-thumbnail';
              thumbParentDiv.style = 'width: 100%; text-align:center;';
              header.appendChild(thumbParentDiv);
              thumbParentDiv.appendChild(thumbElement);
            }
          }
        });
      }
      
      // https://stackoverflow.com/questions/8778863/downloading-an-image-using-xmlhttprequest-in-a-userscript/8781262#8781262
      function customBase64Encode (inputStr) {
          var
              bbLen               = 3,
              enCharLen           = 4,
              inpLen              = inputStr.length,
              inx                 = 0,
              jnx,
              keyStr              = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
                                  + "0123456789+/=",
              output              = "",
              paddingBytes        = 0;
          var
              bytebuffer          = new Array (bbLen),
              encodedCharIndexes  = new Array (enCharLen);
      
          while (inx < inpLen) {
              for (jnx = 0;  jnx < bbLen;  ++jnx) {
                  /*--- Throw away high-order byte, as documented at:
                    https://developer.mozilla.org/En/Using_XMLHttpRequest#Handling_binary_data
                  */
                  if (inx < inpLen)
                      bytebuffer[jnx] = inputStr.charCodeAt (inx++) & 0xff;
                  else
                      bytebuffer[jnx] = 0;
              }
      
              /*--- Get each encoded character, 6 bits at a time.
                  index 0: first  6 bits
                  index 1: second 6 bits
                              (2 least significant bits from inputStr byte 1
                               + 4 most significant bits from byte 2)
                  index 2: third  6 bits
                              (4 least significant bits from inputStr byte 2
                               + 2 most significant bits from byte 3)
                  index 3: forth  6 bits (6 least significant bits from inputStr byte 3)
              */
              encodedCharIndexes[0] = bytebuffer[0] >> 2;
              encodedCharIndexes[1] = ( (bytebuffer[0] & 0x3) << 4)   |  (bytebuffer[1] >> 4);
              encodedCharIndexes[2] = ( (bytebuffer[1] & 0x0f) << 2)  |  (bytebuffer[2] >> 6);
              encodedCharIndexes[3] = bytebuffer[2] & 0x3f;
      
              //--- Determine whether padding happened, and adjust accordingly.
              paddingBytes          = inx - (inpLen - 1);
              switch (paddingBytes) {
                  case 1:
                      // Set last character to padding char
                      encodedCharIndexes[3] = 64;
                      break;
                  case 2:
                      // Set last 2 characters to padding char
                      encodedCharIndexes[3] = 64;
                      encodedCharIndexes[2] = 64;
                      break;
                  default:
                      break; // No padding - proceed
              }
      
              /*--- Now grab each appropriate character out of our keystring,
                  based on our index array and append it to the output string.
              */
              for (jnx = 0;  jnx < enCharLen;  ++jnx)
                  output += keyStr.charAt ( encodedCharIndexes[jnx] );
          }
          return output;
      }
      
      15 votes
    3. What have you done lately that you're proud of?

      Anything you've been working at lately and finally got it done? Anything you finally got around to finishing/starting? Anything big happening? Feel free to gush about anything you've done but want...

      Anything you've been working at lately and finally got it done? Anything you finally got around to finishing/starting? Anything big happening? Feel free to gush about anything you've done but want to talk about!

      Yesterday I decided to pick my acoustic guitar back up and learn Blackbird by The Beatles (Only mildly inspired by Kmac). Today I got it all down! Feeling super proud that I nailed a song like that so quickly after having played bass almost primarily for a while now.

      23 votes
    4. Has Wine begun to remove the need for linux software?

      I started using wine in about 2013 and I remember back then it was quite patchy and only worked on some programs/games. I used to have a rule that I stuck hard to that I would not buy any games...

      I started using wine in about 2013 and I remember back then it was quite patchy and only worked on some programs/games. I used to have a rule that I stuck hard to that I would not buy any games that did not have a linux version. But now in 2019 I have found that everything I have tried to run in wine has been so seamless and close to flawless that I hardly know its running in wine. I semi regularly buy games that only have windows version because I am mostly sure it will work and can get a refund if it doesn't.

      What does everyone else think about this?

      8 votes
    5. A system for "starred" posts on sensitive/advice topics

      This was inspired by this post. I was thinking, as a platform gets bigger we're going to end up with more situations where people are asking for advice about fairly serious stuff. In some cases,...

      This was inspired by this post.

      I was thinking, as a platform gets bigger we're going to end up with more situations where people are asking for advice about fairly serious stuff. In some cases, that advice needs to come from experts and taking guidance from any random Joe on the street can be risky/dangerous. (For the record, I don't think the post I'm referencing is an example of this, it just got me thinking about it).

      In cases like this, I think it's important that the actual good advice get some kind of clear designation that THIS is the guidance you need to take first. I notice this in communities like /r/Fitness a lot where people will post about what sound like pretty serious health concerns and you get a fair number of posts that suggest toughing it out or whatever and the more critical "You need to see a doctor" posts can kind of disappear amid the discussion. Similar things in /r/relationships where you can't always count on "This is abuse. Make arrangements to get your kids and yourself somewhere safe. . ." to be the top post.

      Even in cases where the poster themselves is smart enough to take "YOU NEED TO SEE A DOCTOR" type advice to heart, not every schmuck searching the topic on Google will. To that end, it might be good to give certain posts with good, holistic advice or by a known expert some kind of visual indicator that it deserves to be taken more seriously than other posts in the thread. It wouldn't be censoring anything really, just providing a little nudge about what ought to be consulted first or taken to heart.

      Now obviously it gets hard to decide how to give a post this attribute. It could possibly be awarded by the OP, though that has some obvious issues where the OP themselves might not be in a position to credibly vet the advice they're getting. We could also just do it through ranking by vote, which is the default paradigm. But like I said, it doesn't always work so well on Reddit. And the Exemplary tag is invisible to others, so that doesn't work either (and the post itself might not be worth giving up your "Exemplary" for the day besides). Moderators could do it, but there may not be enough and the skillset to be a Mod might not overlap with the skillset to know what advice a person needs in a particular situation.

      I don't actually have the answers. Maybe it just comes down to creating an attribute for some users to be "wisened elders" or something and empower them to star certain posts to separate good advice from bad. It would basically be a trusted user system. It's got it's own problems, but I guess we can open the floor for other ideas. Maybe it's not a real concern. Maybe it's better addressed by tinkering with the sorting of posts.

      11 votes