• 1 Post
  • 32 Comments
Joined 1 year ago
cake
Cake day: July 9th, 2023

help-circle








  • That’s a big one, generating thumbnails client-side rather than running an imagemagick instance on the server to re-size pictures on upload

    I used it to generate hashes of the pictures as well, once.

    Adding watermarks too. There are virtuous watermarks as well, I remember having to code up a transparents watermark over people’s IDs to make sure that when they submitted their renters dossier (it was a real estate renting service), it couldn’t be used to commit identity theft by the homeowner later down the line or re-used for something else.


  • Ah nah Canvas is used for so much stuff and it’s sometimes way under your radar in stuff you wouldn’t at all expect

    For instance

    • one-loop.github.io, opensource reddit front-end that allows you to look at reddit, but it looks like you’re reading outlook from a distance
    • For people’s avatars, it sources images from thispersondoesnotexist.com
    • You can’t just “download” a picture from another website, because that violates “CORS”: If it were allowed, you could just download their face from facebook.com, scan if they have something hosted on localhost, …
    • You can use an <img> tag which fetches the image, but your javascript cannot access the image’s data. It doesn’t belong to your page

    I’ll let you look at the comments to see how they circumvented this

    async function generateFacePic(commentData: SnooComment, ppBuffer: HTMLImageElement[], displaySize: number = 50): Promise<HTMLCanvasElement> {
        const imageSeed = /* a random number */
        const imageElement: HTMLImageElement = /* someone's avatar */
    
        // Purpose of copying: A single <img> tag cannot be in multiple spots at the same time
        // I did not find a way to duplicate the reference to an img tag 
        // If you use Element.appendChild with the same reference multiple times, the method will move the element around
        // Creating a new <img> tag and copying the attributes would work, but it would fetch the src again
        // The image at thispersondoesnotexist changes every second so the src points to a new picture now
        // Since the URL has a parameter and hasn't changed, then most likely, querying the URL again would
        //     hit the browser's cache. but we can't know that.
        // Solution: make a canvas and give it the single <img> reference. It makes a new one every time. It doesn't query the src.
        const canv = copyImage2Canvas(imageElement, displaySize);
    
        canv.classList.add(`human-${imageSeed}`);
        return canv;
    }
    

    I’ve seen canvas being used for github-like random avatars, graphs, logos, to create dynamic previews of images on the page in online shops, …









  • Cars kill 43 000 people a year in the U.S.

    I’m talking about people’s reactions in this thread when they haven’t read the article. All of those people opposing a hypothetical “cop presses a button” remote kill switch are insane.

    Private citizens do not have a right to operating a motor vehicle any way they see fit. You license it, you license your skills, you get it looked at periodically and you use it on public roads with the state’s blessing only if you can manage to get along with other people using that same road. There is no sense opposing a kill switch for “freedom”.

    We can’t trust cops with their stupid car chases that result in crashes, and their maneuvers for flipping cars over on the freeway.

    You give them a killswitch


  • You can get rid of all those uncertainties by just rolling out a pilot and seeing how it goes. There’s no way cops being able to stop cars remotely causes any more trouble than them actually flipping cars over if they take .3 seconds too long to park for a traffic stop, like they did to that pregnant woman who died in 2022.

    The police has also demonstrated many, many times that they can’t be trusted to rationally judge whether to indulge in hugely dangerous car chases or not, and they routinely end up making perps crash into random people/objects for traffic stop evasions that turn out to just be a guy fleeing because they have felony quantity of coke or a revoked license. You give it a pilot and see how it goes, if it does more good than harm, then you keep it.

    For security, there are many remote-access-control security dances out there, and it’s a solved problem. Tons of them are just a certificate to authenticate, and do a little challenge to solve to be protected from repeat attacks. If one certificate gets leaked or abused you can revoke it and that’s that. If that somehow still has flaws - that’s why you’re doing a pilot.