analog circuit debugging is a transcendental experience. every.single.time. #electronics
Universe Price Tiers
⌘ Read more
(cont.)
Just to give some context on some of the components around the code structure.. I wrote this up around an earlier version of aggregate code. This generic bit simplifies things by removing the need of the Crud functions for each aggregate.
Domain ObjectsA domain object can be used as an aggregate by adding the event.AggregateRoot struct and finish implementing event.Aggregate. The AggregateRoot implements logic for adding events after they are either Raised by a command or Appended by the eventstore Load or service ApplyFn methods. It also tracks the uncommitted events that are saved using the eventstore Save method.
type User struct {
Identity string ```json:"identity"`
CreatedAt time.Time
event.AggregateRoot
}
// StreamID for the aggregate when stored or loaded from ES.
func (a *User) StreamID() string {
return "user-" + a.Identity
}
// ApplyEvent to the aggregate state.
func (a *User) ApplyEvent(lis ...event.Event) {
for _, e := range lis {
switch e := e.(type) {
case *UserCreated:
a.Identity = e.Identity
a.CreatedAt = e.EventMeta().CreatedDate
/* ... */
}
}
}
Events
Events are applied to the aggregate. They are defined by adding the event.Meta and implementing the getter/setters for event.Event
type UserCreated struct {
eventMeta event.Meta
Identity string
}
func (c *UserCreated) EventMeta() (m event.Meta) {
if c != nil {
m = c.eventMeta
}
return m
}
func (c *UserCreated) SetEventMeta(m event.Meta) {
if c != nil {
c.eventMeta = m
}
}
Reading Events from EventStore
With a domain object that implements the event.Aggregate the event store client can load events and apply them using the Load(ctx, agg) method.
// GetUser populates an user from event store.
func (rw *User) GetUser(ctx context.Context, userID string) (*domain.User, error) {
user := &domain.User{Identity: userID}
err := rw.es.Load(ctx, user)
if err != nil {
if err != nil {
if errors.Is(err, eventstore.ErrStreamNotFound) {
return user, ErrNotFound
}
return user, err
}
return nil, err
}
return user, err
}
OnX Commands
An OnX command will validate the state of the domain object can have the command performed on it. If it can be applied it raises the event using event.Raise() Otherwise it returns an error.
// OnCreate raises an UserCreated event to create the user.
// Note: The handler will check that the user does not already exsist.
func (a *User) OnCreate(identity string) error {
event.Raise(a, &UserCreated{Identity: identity})
return nil
}
// OnScored will attempt to score a task.
// If the task is not in a Created state it will fail.
func (a *Task) OnScored(taskID string, score int64, attributes Attributes) error {
if a.State != TaskStateCreated {
return fmt.Errorf("task expected created, got %s", a.State)
}
event.Raise(a, &TaskScored{TaskID: taskID, Attributes: attributes, Score: score})
return nil
}
Crud Operations for OnX Commands
The following functions in the aggregate service can be used to perform creation and updating of aggregates. The Update function will ensure the aggregate exists, where the Create is intended for non-existent aggregates. These can probably be combined into one function.
// Create is used when the stream does not yet exist.
func (rw *User) Create(
ctx context.Context,
identity string,
fn func(*domain.User) error,
) (*domain.User, error) {
session, err := rw.GetUser(ctx, identity)
if err != nil && !errors.Is(err, ErrNotFound) {
return nil, err
}
if err = fn(session); err != nil {
return nil, err
}
_, err = rw.es.Save(ctx, session)
return session, err
}
// Update is used when the stream already exists.
func (rw *User) Update(
ctx context.Context,
identity string,
fn func(*domain.User) error,
) (*domain.User, error) {
session, err := rw.GetUser(ctx, identity)
if err != nil {
return nil, err
}
if err = fn(session); err != nil {
return nil, err
}
_, err = rw.es.Save(ctx, session)
return session, err
}
@mckinley@twtxt.net Haha, while composing I was wondering two or three times whether I should throw my thoughts in an HTML page instead. But out of utter laziness I discarded that idea. ¯_(ツ)_/¯
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).
Got the results of my take-home today and whilst there was some good feedback, man the criticisms of my work were harsh. I’m strictly not allowed to share the work I did for this take-home test, and I really can only agree with the “no unit tests” piece of the feedback, I could have done better there, but I was time pressured, sick and ran out of steam. I was using a lot of libraires to do the work so in the end found it difficult to actually think about a proper set of “Unit Tests”. I did write one (in shell) but I guess it wasn’t seen?
The other points were on my report and future work. Not detailed enough I guess? Hmmm 🤔
Am I really this bad? Does my code suck? 🤔 Have I completely lost touch with software engineering? 🤦♂️
@movq@www.uninformativ.de I usually only use eggs for baking or fry them for potatoes and spinach. @prologic@twtxt.net Why don’t you have them anymore? Did the fox get them all when the door didn’t close in time? ]:->
Goofs
⌘ Read more
Spent the last few days debugging network issues at work.
Exhausting. You never get a full picture. You poke a little here, poke a little there, … Form a hypothesis and test it. Eventually, maybe, you can narrow it down a bit to some segment or even some component.
A very time consuming process. Even more so if you try not to cause downtimes for your users.
I want a magical device that allows me to look inside a cable/fibre.
But hey, at least we got rid of a bunch of Cisco switches in the process. So there’s that.
Mainly Known For
⌘ Read more
trying some day planning on paper, quantizing all tasks into pomodoros. feels good. my goal is to make software only if/when I’ll feel I’ll need it and have a pretty decent idea of WHAT I need #tracking #selfimprovement #time
Family Reunion
⌘ Read more
I would HIGHLY recommend reading up on the keybase architecture. They designed device key system for real time chat that is e2e secure. https://book.keybase.io/security
A property of ec keys is deriving new keys that can be determined to be “on curve.” bitcoin has some BIPs that derive single use keys for every transaction connected to a wallet. And be derived as either public or private chains. https://qvault.io/security/bip-32-watch-only-wallets/
Consensus Time
⌘ Read more
Took a flu medicine last night, and it knocked me down around 22:00. Woke up at 04:00, then slept till 06:30. All has been seemingly fine, not feeling sleepy, and mostly alert… until now. I am having a really hard time keeping my eyes open. 😬
Startup Aims To Help Software Companies Shift To Usage-Based Pricing Models
The startup Metronome “claims to have developed a billing and data infrastructure platform that is capable of ‘reliably’ processing data at scale so that usage-based companies can iterate on business models without code changes,” reports TechCrunch. “It does this by providing businesses with real-time APIs for their customer … ⌘ Read more
Time to get Gitea configured and running my website, I think 🤔
Alien Mission
⌘ Read more
@prologic@twtxt.net you be the man! I can’t remember the last time something gave as much troubles as this. The mention and the way to handle images are two things that have stuck in my head. Hopefully this is the last time there is an issue with this one! 🤞🏻
@movq@www.uninformativ.de was the request to remove the hash (subject) from showing on twts discarded? I don’t see it on the TODO, so I am curious. Was it something you decided was not worth investing time on?
@fastidious@arrakis.netbros.com 🕑 Hi, the current time is about a quarter past two in the afternoon 🌅.
The battery life in this i9 MacBook Pro from 2018 has diminished to being barely enough to serve as an UPS backup system with enough time to perform a safe shutdown
Haha that guy comes up every time BTC peaks a bit higher. He is never gonna find it.
Killing time in Goodwill, I picked up a desk calculator from a pile. Dude standing next to me goes “what’s that for?”. 😳💀
This pi will now boot directly to ed if the gpio pin is grounded at boot time. ed(1)term v1. :-) http://txtpunk.com/edterm/
@lyse This was basically a trial/proof-of-concept for the real goal: a switch which, if on at boot time, causes the pi to boot straight to ed.
@thecanine@twtxt.net been there a few times! Thank goodness for mosh for when trying to debug from spotty GSM connection and having ssh drop out every few minutes.
Edge Cake
⌘ Read more
Siren
⌘ Read more
@fastidious@arrakis.netbros.com Yes. there is a –flag for it. i have mine set for some crazy long time.
No on gitlab. If its self hosted gitea is best in class.
I can see hosting a mirror on github if only for the redundancy/visibility. Some projects will host but then direct contributions on their self host. Like Go does.
I would suggest using a vanity domain that can redirect tools like go get to hosting of choice. And not require rewriting all the packages any time it gets moved.
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? 😅
Hmmm so… We seem to have a few pods offline in the network 😂 Also 😢
- @jlj@twt.nfld.uk’s twt.nfld.uk => 504 Gateway Time-out
- @adi@f.adi.onl’s f.adi.onl => 200 OK but doens’t appear to be a pod anymore?! 🤔
- @eldersnake@yarn.andrewjvpowell.com’s personal pod => offline due to lack of Solar/Battery power? 😅
- @lohn@tw.lohn.in’s personal pod => 503 Service Unavailable
It’s a bad day for Yarn.social 🤣
Good thing it’s all decentralised 😉
👋 Q&A: Let’s discuss the removal of Editing and Deleting your last Twt. This is something @fastidious@twtxt.net has raised to me on IRC and something I find quite a valid approach to this. Over time I believe the utility and value of “Editing” and “Deleting” one’s last Twt isn’t as valuable as we’d like and increased complexity and introduces all kinds of side-effects that are hard to manage correctly. I vote for the removal of this feature from yarnd, the mobile app nor API support this anyway…
@eldersnake@yarn.andrewjvpowell.com Is there still an issue (sortt was out for most of the day) with the We 💚 Privacy Club pod? 🤔 I hope no weird bug has been introduced 😢 AFIK none of the auth/session handling code has been touched in quite some time.
My Friday has started. Now, what will I do with this much time?! LOL! Got to remember “dum loquimur, fugerit invida aetas”. ⏳
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.
Went to sleep at 01:00, woke up at 06:30, having a really hard time keeping my eyes open, and there is still one more hour till calling it quits. Does being this sleepy counts as being sick?
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!
Rule 299:
After you’ve exploited someone, it never hurts to thank them. That way, it’s easier to exploit them next time.
@prologic@twtxt.net
It is still too early, and too few of us. Give it some time, and your wife might revise her statement. 😂
@movq@www.uninformativ.de what is your cron job repeat time for jenny? Currently I have mine to every minute, and while it allows me to participate fairly quick on conversations it has some drawbacks: it captures every single edited twt, so I end up with seemingly the same twt, but not quite—as it has minor edits, etc. So, “repeats”. Perhaps setting cron to check every 5 minutes or so is best?
@stigatle@twtxt.net
It is a lovely view! That’s home office, or work office? I am hoping the second, though I do not know Norway’s days and nights well. I know that Sweden can get pretty dark, or pretty light, for long periods of time.
No new iMacs, or Mac minis. I really wanted a new iMac with the new SoC, and a bigger screen. Not this time. 😩
@laz@tt.vltra.plus
Are all minimum requirements met? All pre-install checks performed? Install steps carefully read, and checked, one more time?
@stigatle@twtxt.net
You are making me want to visit Norway! I would have gone long ago if it weren’t because of my partner, she can’t handle the cold. Maybe I just need to leave her behind! 🤣
What would the best time to visit be?
@jlj@twt.nfld.uk
Your avatar is healthy on your pod now. Still doesn’t show well on twtxt.net, but it is just a matter of time now (caching, etc.), it is all good. 🎉
@prologic@twtxt.net I am thinking on calling in sick to work. 😂 Every time I order an iPhone, I take the day off on delivery day. On Apple events I normally use my lunch and break times all combined, to watch them.
@prologic@twtxt.net I knew you were short sided from day one I saw Yarn. On desktop everything is huge, and I assumed it was to cater short-sightedness. Also, you have enabled underlines on buttons on iOS, bold and bigger fonts, etc., so that was also a give away. Sorry if I digress, but, glasses wouldn’t help? I have to wear mine all the time, otherwise I am also near blind myself!
@movq@www.uninformativ.de I remember that time. I built my own mess, then used someone else’s mess (WordPress). I then switched to Jekyll when Tom released it, then to Hugo, which I use today. I also love static web stuff!
@movq@www.uninformativ.de But it makes sense, right? I spend way too much time trying to figure out who replied to whom. I treat twts replies as emails, pretty much.