Searching yarn

Twts matching #1
Sort by: Newest, Oldest, Most Relevant
In-reply-to » @prologic Error handling especially in Go is very tricky I think. Even though the idea is simple, it's fairly hard to actually implement and use in a meaningful way in my opinion. All this error wrapping or the lack of it and checking whether some specific error occurred is a mess. errors.As(…) just doesn't feel natural. errors.Is(…) only just. I mainly avoided it. Yesterday evening I actually researched a bit about that and found this article on errors with Go 1.13. It shed a little bit of light, but I still have a long way to go, I reckon.

+1

⤋ Read More
In-reply-to » I did a take home software engineering test for a company recently, unfortunately I was really sick (have finally recovered) at the time 😢 I was also at the same time interviewing for an SRE position (as well as Software Engineering).

@prologic@twtxt.net Error handling especially in Go is very tricky I think. Even though the idea is simple, it’s fairly hard to actually implement and use in a meaningful way in my opinion. All this error wrapping or the lack of it and checking whether some specific error occurred is a mess. errors.As(…) just doesn’t feel natural. errors.Is(…) only just. I mainly avoided it. Yesterday evening I actually researched a bit about that and found this article on errors with Go 1.13. It shed a little bit of light, but I still have a long way to go, I reckon.

We tried several things but haven’t found the holy grail. Currently, we have a mix of different styles, but nothing feels really right. And having plenty of different approaches also doesn’t help, that’s right. I agree, error messages often end up getting wrapped way too much with useless information. We haven’t found a solution yet. We just noticed that it kind of depends on the exact circumstances, sometimes the caller should add more information, sometimes it’s better if the callee already includes what it was supposed to do.

To experiment and get a feel for yesterday’s research results I tried myself on the combined log parser and how to signal three different errors. I’m not happy with it. Any feedback is highly appreciated. The idea is to let the caller check (not implemented yet) whether a specific error occurred. That means I have to define some dedicated errors upfront (ErrInvalidFormat, ErrInvalidStatusCode, ErrInvalidSentBytes) that can be used in the err == ErrInvalidFormat or probably more correct errors.Is(err, ErrInvalidFormat) check at the caller.

All three errors define separate error categories and are created using errors.New(…). But for the invalid status code and invalid sent bytes cases I want to include more detail, the actual invalid number that is. Since these errors are already predefined, I cannot add this dynamic information to them. So I would need to wrap them à la fmt.Errorf("invalid sent bytes '%s': %w", sentBytes, ErrInvalidSentBytes"). Yet, the ErrInvalidSentBytes is wrapped and can be asserted later on using errors.Is(err, ErrInvalidSentBytes), but the big problem is that the message is repeated. I don’t want that!

Having a Python and Java background, exception hierarchies are a well understood concept I’m trying to use here. While typing this long message it occurs to me that this is probably the issue here. Anyways, I thought, I just create a ParseError type, that can hold a custom message and some causing error (one of the three ErrInvalid* above). The custom message is then returned at Error() and the wrapped cause will be matched in Is(…). I then just return a ParseError{fmt.Sprintf("invalid sent bytes '%s'", sentBytes), ErrInvalidSentBytes}, but that looks super weird.

I probably need to scrap the “parent error” ParseError and make all three “suberrors” three dedicated error types implementing Error() string methods where I create a useful error messages. Then the caller probably could just errors.Is(err, InvalidSentBytesError{}). But creating an instance of the InvalidSentBytesError type only to check for such an error category just does feel wrong to me. However, it might be the way to do this. I don’t know. To be tried. Opinions, anyone? Implementing a whole new type is some effort, that I want to avoid.

Alternatively just one ParseError containing an error kind enumeration for InvalidFormat and friends could be used. Also seen that pattern before. But that would then require the much more verbose var parseError ParseError; if errors.As(err, &parseError) && parseError.Kind == InvalidSentBytes { … } or something like that. Far from elegant in my eyes.

⤋ Read More

I’m trying to switch from Konversation to irssi. Let’s see how that goes. Any irssiers out there who can recommend specific settings or scripts? I already got myself trackbar.pl and nickcolor.pl as super-essentials. Also trying window_switcher.pl. Somehow my custom binds for Ctrl+1/2/3/etc. to switch to window 1/2/3/etc. doesn’t do anything: { key = "^1"; id = "change_window"; data = "1"; } (I cannot use the default with Alt as this is handled by my window manager). Currently, I’m just cycling with Ctrl+N/P. Other things to solve in the near future:

  • better, more colorful and compact theme (just removed clock from statusbar so far)
  • getting bell/urgency hints working on arriving messages
  • nicer tabs in status bar, maybe even just channel names and no indexes
  • decluster status bar with user and channel modes (I never cared about those in the last decade)

⤋ Read More
In-reply-to » A read-only, finger(1)-based social network, maybe? http://txtpunk.com/fingers/

It’ll track a bunch of finger(1) endpoints and let you see what’s new. Very early draft. Not actually a social network, more an anti-social network for ‘80s CompSci transplants. :-)

⤋ Read More

Elon Musk Offers To Buy Twitter For $41 Billion
Billionaire Elon Musk has offered to buy Twitter for about $41 billion, just days after rejecting a seat on the social media company’s board. From a report: Musk’s offer price of $54.20 per share, which was disclosedin a regulatory filing on Thursday, represents a 38% premium to Twitter’s April 1 close, the last trading day before the Tesla CEO’s more than 9% stake in the company … ⌘ Read more

⤋ Read More

@prologic@twtxt.net

#!/bin/sh

# Validate environment
if ! command -v msgbus > /dev/null; then
    printf "missing msgbus command. Use:  go install git.mills.io/prologic/msgbus/cmd/msgbus@latest"
    exit 1
fi

if ! command -v salty > /dev/null; then
    printf "missing salty command. Use:  go install go.mills.io/salty/cmd/salty@latest"
    exit 1
fi

if ! command -v salty-keygen > /dev/null; then
    printf "missing salty-keygen command. Use:  go install go.mills.io/salty/cmd/salty-keygen@latest"
    exit 1
fi

if [ -z "$SALTY_IDENTITY" ]; then
    export SALTY_IDENTITY="$HOME/.config/salty/$USER.key"
fi

get_user () {
    user=$(grep user: "$SALTY_IDENTITY" | awk '{print $3}')
    if [ -z "$user" ]; then
        user="$USER"
    fi
    echo "$user"
}

stream () {
    if [ -z "$SALTY_IDENTITY" ]; then
        echo "SALTY_IDENTITY not set"
        exit 2
    fi

    jq -r '.payload' | base64 -d | salty -i "$SALTY_IDENTITY" -d
}

lookup () {
    if [ $# -lt 1 ]; then
    printf "Usage: %s nick@domain\n" "$(basename "$0")"
    exit 1
    fi

    user="$1"
    nick="$(echo "$user" | awk -F@ '{ print $1 }')"
    domain="$(echo "$user" | awk -F@ '{ print $2 }')"

    curl -qsSL "https://$domain/.well-known/salty/${nick}.json"
}

readmsgs () {
    topic="$1"

    if [ -z "$topic" ]; then
        topic=$(get_user)
    fi

    export SALTY_IDENTITY="$HOME/.config/salty/$topic.key"
    if [ ! -f "$SALTY_IDENTITY" ]; then
        echo "identity file missing for user $topic" >&2
        exit 1
    fi

    msgbus sub "$topic" "$0"
}

sendmsg () {
    if [ $# -lt 2 ]; then
        printf "Usage: %s nick@domain.tld <message>\n" "$(basename "$0")"
        exit 0
    fi

    if [ -z "$SALTY_IDENTITY" ]; then
        echo "SALTY_IDENTITY not set"
        exit 2
    fi

    user="$1"
    message="$2"

    salty_json="$(mktemp /tmp/salty.XXXXXX)"

    lookup "$user" > "$salty_json"

    endpoint="$(jq -r '.endpoint' < "$salty_json")"
    topic="$(jq -r '.topic' < "$salty_json")"
    key="$(jq -r '.key' < "$salty_json")"

    rm "$salty_json"

    message="[$(date +%FT%TZ)] <$(get_user)> $message"

    echo "$message" \
        | salty -i "$SALTY_IDENTITY" -r "$key" \
        | msgbus -u "$endpoint" pub "$topic"
}

make_user () {
    mkdir -p "$HOME/.config/salty"

    if [ $# -lt 1 ]; then
        user=$USER
    else
        user=$1
    fi

    identity_file="$HOME/.config/salty/$user.key"

    if [ -f "$identity_file" ]; then
        printf "user key exists!"
        exit 1
    fi

    # Check for msgbus env.. probably can make it fallback to looking for a config file?
    if [ -z "$MSGBUS_URI" ]; then
        printf "missing MSGBUS_URI in environment"
        exit 1
    fi


    salty-keygen -o "$identity_file"
    echo "# user: $user" >> "$identity_file"

    pubkey=$(grep key: "$identity_file" | awk '{print $4}')

    cat <<- EOF
Create this file in your webserver well-known folder. https://hostname.tld/.well-known/salty/$user.json

{
  "endpoint": "$MSGBUS_URI",
  "topic": "$user",
  "key": "$pubkey"
}

EOF
}

# check if streaming
if [ ! -t 1 ]; then
    stream
    exit 0
fi

# Show Help
if [ $# -lt 1 ]; then
    printf "Commands: send read lookup"
    exit 0
fi


CMD=$1
shift

case $CMD in
    send)
        sendmsg "$@"
    ;;
    read)
        readmsgs "$@"
    ;;
    lookup)
        lookup "$@"
    ;;
    make-user)
        make_user "$@"
    ;;
esac

⤋ Read More
In-reply-to » Another day, another 5m outage 🤬

Wow. I’m paying about 100 USD for my cable internet. Hard to estimate since its part of a tvd bundle. But it is 1.2Gbit down and 40Mbit up. And speed tests at that on the regular. The new house will have FTTH gigabit for 80ish.

Do they have Starlink beta down there yet?

⤋ Read More

Netflix Raises Monthly Subscription Prices in US, Canada
Netflix has raised its monthly subscription price by $1 to $2 per month in the United States depending on the plan, the company said on Friday, to help pay for new programming to compete in the crowded streaming TV market. From a report: The standard plan, which allows for two simultaneous streams, now costs $15.49 per month, up from $13.99, in the Unite … ⌘ Read more

⤋ Read More

Btw… You guys have gotta start posting more pictures/videos a bit more regularly 😂 Every time I show Yarn.social off to a friend to “sell” them the platform and get them off their privacy eroding garbage Facebook/Twitter/etc) The no. #1 question I get asked is:

Oh is this only comments/text

🤣 Let’s show off the platform as a whole a bit eh? 😅

⤋ Read More
In-reply-to » New theme for yarn is up now at: https://git.mills.io/sorenpeter/darchTheme Still needs some work, but please have a go with it and hack away Media Media

@darch@twtxt.net
Getting this when trying to use it:

error executing template timeline: template: timeline:131:43: executing "twt" at <formatForDateTime>: wrong number of args for formatForDateTime: want 2 got 1

⤋ Read More

My nutritional supplements aim should be:

  • 1 or 1.5 cups of lentils (or any beans you might like better).
  • 2 or 2.5 cups of bitter greens.
  • 1 cup of your favourite protein (or an egg), grilled, or fried with a little of olive oil.
  • 1 or 2 tomatoes, or a handful if of the cherry type.
  • No added sugars. If it is sweet, make it have fibre.
  • No added salt (or very little and ionised), as salt is everywhere.

Related, I tried wild rice for the first time yesterday. It was different, in a good way.

⤋ Read More

Standby BIG-IP F5s upgraded to TMOS 16.1 (LTS). All their pairs (now on standby) will be upgraded on Wednesday. Just giving the TMOS some time to settle down, and feel at home. Hahahaha!

⤋ Read More
In-reply-to » Apple Event for 18 October 2021, 10:00 PDT, 13:00 EDT begins. Commentary will stream as replies to this twt. I might miss things here and there, as I will also be on a work meeting from 13:00 to 14:00 EDT.

@stigatle@twtxt.net
You can get an Air for $1,000 (or $1,200 with 16GB). I have used it (with 8GB), and that machine flies. I can’t imagine how fast one with an M1MAX will feel.

⤋ Read More

An estimated 6.8 million fewer female births will be recorded across India by 2030 because of the persistent use of selective abortions, researchers estimate. — The Guardian

And from the same article:

India’s skewed ratio of men to women – currently between 900-930 females per 1,000 males – reflects India’s ingrained attitude towards girls. Boys are seen as breadwinners while girls are seen as a burden across every social class. Boys are more likely to receive more nutritious food and better medical care than girls.

That is just beyond sad.

⤋ Read More
In-reply-to » Assuming the DNS is playing ball now, my little personal site https://www.andrewjvpowell.com/ is now self hosted and solar powered. As @mckinley can attest, running on the original nearlyfreespeech.net non-production plan could use as little as $0.01 per day so there's not really any advantage to this, its just... because I can 🙃

a simple Makefile for forwarding internet to your local machine:

SSH_HOST=https://xuu.me
PRIV_KEY=~/.ssh/id_ed25519
forward:
	LOCAL_PORT=$(HOST_PORT); sh -c "$(shell http --form POST $(SSH_HOST) pub=@$(PRIV_KEY).pub | grep ^ssh | head -1 | awk '{ print "ssh -T -p " $$4 " " $$5 " -R " $$7 " -i $(PRIV_KEY)"  }')"

⤋ Read More

@prologic@twtxt.net @jlj@twt.nfld.uk @movq@www.uninformativ.de

 /p/tmp > git clone https://www.uninformativ.de/git/lariza.git                                                                                                    Mon May 24 23:48:18 2021
Cloning into 'lariza'...
 /p/tmp > tree lariza/                                                                                                                                    12.5s  Mon May 24 23:48:32 2021
lariza/
├── BUGS
├── CHANGES
├── LICENSE
├── Makefile
├── PATCHES
├── README
├── browser.c
├── man1
│   ├── lariza.1
│   └── lariza.usage.1
├── user-scripts
│   └── hints.js
└── we_adblock.c

2 directories, 11 files

⤋ Read More
In-reply-to » @xuu Re CPU usage of the lextwt branch. There's a noticeable ~2x increase in CPU usage across the board since I deployed this at ~16.30pm (AEST).

@prologic@twtxt.net That is strange.. i wonder if there is another change that is causing it. Benchmarks are thinking the other way :|

BenchmarkAll/retwt-16                  1        4940172200 ns/op       587319376 B/op    2587159 allocs/op
BenchmarkAll/lextwt-16                 1         775764020 ns/op         9223088 B/op     197557 allocs/op
BenchmarkParse/retwt-16                1         591158277 ns/op        67539096 B/op     230841 allocs/op
BenchmarkParse/lextwt-16               1         716961837 ns/op         5450448 B/op     130290 allocs/op
BenchmarkOutput/retwt-html-16          1        8358103017 ns/op       918709168 B/op    4692292 allocs/op
BenchmarkOutput/lextwt-html-16         1         822033267 ns/op        14280112 B/op     261795 allocs/op
BenchmarkOutput/retwt-markdown-16      1        8114225415 ns/op       929928384 B/op    4693004 allocs/op
BenchmarkOutput/lextwt-markdown-16     1         806554306 ns/op        14332608 B/op     270905 allocs/op
BenchmarkOutput/retwt-text-16          1        8098215897 ns/op       923862192 B/op    4684739 allocs/op
BenchmarkOutput/lextwt-text-16         1         745064673 ns/op        12689784 B/op     252476 allocs/op
BenchmarkOutput/retwt-literal-16       1        4068799822 ns/op       409517880 B/op    2372471 allocs/op
BenchmarkOutput/lextwt-literal-16      1         754793627 ns/op         9834520 B/op     214931 allocs/op

⤋ Read More

Are you able to coax your webserver to add the charset to the content type header? Browsers are having a hard time thinking you are sending latin-1

content-type: text/plain; charset=utf-8

⤋ Read More