• 0 Posts
  • 12 Comments
Joined 2 years ago
cake
Cake day: July 14th, 2023

help-circle


  • kibiz0r@midwest.socialtoLinux@lemmy.mlShare a script/alias you use a lot
    link
    fedilink
    English
    arrow-up
    47
    arrow-down
    1
    ·
    edit-2
    2 months ago

    I often want to know the status code of a curl request, but I don’t want that extra information to mess with the response body that it prints to stdout.

    What to do?

    Render an image instead, of course!

    curlcat takes the same params as curl, but it uses iTerm2’s imgcat tool to draw an “HTTP Cat” of the status code.

    It even sends the image to stderr instead of stdout, so you can still pipe curlcat to jq or something.

    #!/usr/bin/env zsh
    
    stdoutfile=$( mktemp )
    curl -sw "\n%{http_code}" $@ > $stdoutfile
    exitcode=$?
    
    if [[ $exitcode == 0 ]]; then
      statuscode=$( cat $stdoutfile | tail -1 )
    
      if [[ ! -f $HOME/.httpcat$statuscode ]]; then
        curl -so $HOME/.httpcat$statuscode https://http.cat/$statuscode
      fi
    
      imgcat $HOME/.httpcat$statuscode 1>&2
    fi
    
    cat $stdoutfile | ghead -n -1
    
    exit $exitcode
    

    Note: This is macOS-specific, as written, but as long as your terminal supports images, you should be able to adapt it just fine.


  • It’s the #1 thing that drives me crazy about Linux.

    It seems obvious. You’ve got a Windows/Apple/Super key and a Control key. So you’d think Control would be for control characters and Windows/Apple/Super would be for application things.

    I can understand Windows fucking this up, cuz the terminal experience is such a low priority. But Linux?

    There’s some projects like Kinto and Toshy which try to fix it, but neither work on NixOS quite yet.









  • Yearly refreshes make a lot more sense for phones, where the OS defines a lot more of the app lifecycle and common features, consumers might be interested in non-performance hardware upgrades like cameras, and things tend to be less spec-sensitive in the first place.

    For a gaming device, giving devs an uneven foundation and users a confusing compatibility matrix would spell doom.

    Edit: I should probably clarify that I wasn’t saying a yearly refresh for phones is good. Just that the context of Android+iOS is very different from the Steam Deck, and that context makes more frequent refreshes more attractive to consumers and less damaging to developers than it would be if applied to the Steam Deck also.

    Edit 2: I also just realized this is not the same story as the one a day or two ago that drew a direct comparison to phones. So I guess I should’ve gone back and commented on that one instead. I just wanted to share cuz I’ve had a lot of meetings about device support and consumer upgrade habits, as a mobile dev and as a game dev, and I don’t think most people would guess quite how different those two worlds are.