Searching yarn

Twts matching #Logic:
Sort by: Newest, Oldest, Most Relevant
In-reply-to » @sorenpeter you raw feed says otherwise. Also, https://txt.sour.is/conv/wj5bcwq.

@bender@twtxt.net Hehe good sleuthing 🤣 I swear it was an edit āœļø Haha šŸ˜‚ yarnd now ā€œseesā€ both every single time, where-as before it would just obliterate the old Twt, but remain in archive. Now you get to see both šŸ˜… Not sure if that’s a good thing or not, but it certainly makes it much clearer how to write ā€œcode logicā€ for detecting edits and doing something more UX(y) about ā€˜em šŸ¤”

⤋ Read More
In-reply-to » I just noticed that my unread messages counter was off by quite a bit. It showed 8, but I only saw one unread message. Even after restarting my client, which recalculates the number of unread messages, it remained at eight. Weird. Looking in the database revealed that this is indeed correct.

Today is the day where everything is falling apart. Suddenly, I get: SQL logic error: cannot start a transaction within a transaction

⤋ Read More

Why is there a ā€œsmall houseā€ in IBM’s Code Page 437?
There’s a small house ( āŒ‚ ) in the middle of IBM’s infamous character set Code Page 437. ā€œSmall houseā€ā€”that’s the official IBM name given to the glyph at code position 0x7F, where a control character for ā€œDeleteā€ (DEL) should logically exist. It’s cute, but a little strange. I wonder, how did it get there? Why did IBM represent DEL as a house, of all things? ↫ Heikki Lotvonen Don’t waste any time here, and go read the article. It’ … ⌘ Read more

⤋ Read More
In-reply-to » (#tbyqv7a) @andros Do edits cause problems? I sometimes make them and didn't realize it may be an issue

@bmallred@staystrong.run I forgot one more effect of edits. If clients remember the read status of massages by hash, an edit will mark the updated message as unread again. To some degree that is even the right behavior, because the message was updated, so the user might want to have a look at the updated version. On the other hand, if it’s just a small typo fix, it’s maybe not worth to tell the user about. But the client doesn’t know, at least not with additional logic.

Having said that, it appears that this only affects me personally, noone else. I don’t know of any other client that saves read statuses. But don’t worry about me, all good. Just keep doing what you’ve done so far. I wanted to mention that only for the sake of completeness. :-)

⤋ Read More
In-reply-to » I share a simple API template with Clean Architecture using #flask and #fastapi https://git.andros.dev/andros/api-template-with-clean-architecture #cleancode #cleanarchitecture

What is clean architecture? That’s a good question.

You think of a pattern for ordering code with good decisions isolating technologies (you can change the web framework or database without break the business logic), easy to test (you only test interfaces and use cases), sharing code between frameworks (entities and use cases), scalability, modulations and standardizing names. Clean architecture is not perfect, it has a learning curve and some abstraction in each technology. You can even find rejection with yours colleagues.
I have a good article on this topic.
https://programadorwebvalencia.com/implementando-arquitectura-limpia-en-python/
#python

⤋ Read More

After I stripped off my clothes and turned around, I came to the conclusion that the plan to shower was cancelled at this moment. The faucet had broken right off and was laying in the tub. I noticed that the diameters of the hot and cold water pipes were surprisingly small, didn’t expect that. Since the pipes were broken flush with the wall, I couldn’t even determine if I had to remove the inner our outer threads, well, remains thereof, in order to attempt to repair this mess. Luckily, I was going to see a plumber mate at the christmas tree collection later anyway.

The first thing that came to mind when I woke up was that I didn’t catch the logical flaw in my dream: absolutely no water was coming out of the burst pipes. The whole scenario took place in summer, so the water couldn’t be frozen either.

⤋ Read More
In-reply-to » @doesnm the logic that keeps on growing! :-D

Need to summary all of these logic. So:\u2028 1. If file named twtxt.txt then grab parent directory name or hostname if file in root (and maybe delete ~?) \u2028 2. If file named nick.txt then grab filename

⤋ Read More

Simplified twtxt - I want to suggest some dogmas or commandments for twtxt, from where we can work our way back to how to implement different feature like replies/treads:

  1. It’s a text file, so you must be able to write it by hand (ie. no app logic) and read by eye. If you edit a post you change the content not the timestamp. Otherwise it will be considered a new post.

  2. The order of lines in a twtxt.txt must not hold any significant. The file is a container and each line an atomic piece of information. You should be able to run sort on a twtxt.txt and it should still work.

  3. Transport protocol should not matter, as long as the file served is the same. Http and https are preferred, so it is suggested that feed served via Gopher or Gemini also provide http(s).

  4. Do we need more commandments?

⤋ Read More

If some of you budding fathers want to know how I created a computer nerd to one day work for Facebook in the big USA, well you purchase a $1000 Xmas present, an enormous thick book with C++ programming, and say, you can play as many games as you like kids, but James has to create them using computer software.

SO James created once a 3D chess program with sound, took 6 months or so, really hard to beat, not based on logic moves point by point like other chess programs, this one was based on the depth of looking for patterns, set it to 5 moves ahead and you were toast every time. Nice program too, sadly gone over the years, computers suffer from bit rot. We used to try and mark rotten hard drive discs once as bad sectors, not sure how UBuntu does this these days, I see a dozen errors on the screen every time I load.

Today I would purchase for my kids AI CAD simulation software with metal 3D printer and get your child to build fancy 3D models and engines from scratch. This will make them an expert in the CAD AI industry by the time they are 14 years old. Sadly AI is here to stay and will spoil the Internet.

⤋ Read More
In-reply-to » you need to send an email @quark if you want an account. I know that might be very profitable. Maybe Odo can disclose it if I give him a new bucket.

@sorenpeter@darch.dk a poem about me giving Odo a free bucket:

A glint in his eye, a sly, Ferengi grin,
Quark crossed the promenade, a curious thing within.
No jeweled trinket, no weapon so grand,
But a simple pail held tight in his hand.

Odo, the Constable, with a brow raised high,
ā€œA bucket, Quark? What trickery do you try?ā€
The Ferengi huckster, with a salesman’s flair,
ā€œA gift, my friend, a constable’s rare!ā€

ā€œFor those late-night spills, a morphing mishap,
This bucket, dear Odo, will catch every scrap.
And should a suspect turn to goop and flee,
This pail’s the answer, a guarantor, you see!ā€

Odo’s lips twitched, a hint of a smile,
At Quark’s twisted logic, his mercantile style.
ā€œPerhaps,ā€ he conceded, the bucket held tight,
ā€œA useful addition, in the pursuit of right.ā€

So Quark made his sale, with a wink and a nod,
A bucket for Odo, a Ferengi oddity, odd.
But on Deep Space Nine, where chaos takes hold,
Even a pail can be worth more than gold.

About the account, thanks, but I already have way too many. :-D

⤋ Read More
In-reply-to » I never paid a lot of attention to Ben Shapiro before, but what he says is so transparently asinine it boggles the senses. You really have to have a Fox-addled mind to believe that the search for the submersible was completely faked and that the powers-that-be knew the entire time that it had imploded. To believe that a vast conspiracy among hundreds, thousands (?) of people from several countries and spanning several days was orchestrated to lie to the public in order to.....uh, achieve what exactly? "Undermine institutional credibility"? What does that even mean?

Ol Ben sets himself up as an intellectual for the right. He got promoted up with his connections with PragerU. Talks like he is the smartest one in the room. Though his arguments are full of logical fallacies. He is up there with Joe Rogan and the ilk destroying rational though in America.

⤋ Read More
In-reply-to » I may have misspoken in my haste/anguish. I don't know of any examples of Ben Shapiro advocating rape. I do know them of Jordan Peterson. He's known for that, but I've seen it myself. So, to be clear, I don't know if Ben Shapiro is a rape apologist and have no evidence of that. Wouldn't surprise me frankly because the set of ideas he does talk about tends to include being A-OK with crimes against women, but anyway.

@xuu@txt.sour.is LOL omfg.

This is the absurd logical endpoint of free market fundamentalism. ā€œThe market will fix everything!ā€ Including, apparently, encroaching floodwater.

I do have to say though, after spending awhile looking at houses, that there are a crapton of homes for sale for very high prices (>$1 million) in coastal areas NASA is more or less telling us will be underwater in the next few decades. I don’t get how a house that’s going to be underwater soon is worth $1 million, but then I’m never been a free market fundamentalist either so 🤷 Maybe they’re all watertight.

⤋ Read More
In-reply-to » Progress! so i have moved into working on aggregates. Which are a grouping of events that replayed on an object set the current state of the object. I came up with this little bit of generic wonder.

(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 Objects

A 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
}

⤋ Read More

@prologic@twtxt.net What if the reply does what fork does, for any replies to the top post, but not the top post itself? You know, like email does. Other than to reply to the top post (for which I use reply), I don’t use reply but fork, to reply to posts underneath because it is the logical thing to do.

⤋ Read More