Bitwise operators are lower than equality so the compiler sees (magnet & (mask != 0)) != 0
You would have been fine if you'd used the implicit test by leaving out the !=
Ha. Yeah, I'm definitely not used to throwing bits around.
The secret is to always use parenthesis everywhere to enforce a particular order of operations, and to use intermediate variables to break up complicated expressions.
Some bitwise and logical operators have lower precedence than checking for equality, which WILL screw you, as you found out. If you're in the habit of excess parenthesis, that's never a problem. Can look a little ugly however.
Bitwise operators are lower than equality so the compiler sees (magnet & (mask != 0)) != 0
You would have been fine if you'd used the implicit test by leaving out the !=
Ha. Yeah, I'm definitely not used to throwing bits around.
The secret is to always use parenthesis everywhere to enforce a particular order of operations, and to use intermediate variables to break up complicated expressions.
Some bitwise and logical operators have lower precedence than checking for equality, which WILL screw you, as you found out. If you're in the habit of excess parenthesis, that's never a problem. Can look a little ugly however.
I think my love for excess parentheses is why I enjoy Scheme so much...
I'm dabbling with an Arduino experiment where I need to address four individual magnet coils for a stepper motor. I've never had to do much of anything with flipping individual bits before, so this is a very fun learning experiment.
There is a stepper driver library for Arduino, but where's the fun in that? Because the Arduino IDE sucks and has a long feedback cycle to test stuff, I'm writing a prototype in Go first.
...
Success!
...but then I ran into problems where I want to define full steps and half steps, which requires running a combination of magnets, because I suck at bitwise ops. To the google machine!
If you're messing in embedded, now is the PERFECT time to get comfortable with bit twiddling.
Bit twiddling is how you talk to the hardware!
Do you have anything else running on the Arduino? What do you have the stepper attached to?
That sounds like something people get arrested for.
0
Options
admanbunionize your workplaceSeattle, WARegistered Userregular
it's fine as long as you're not bit twiddling in public
Now all I have to do is turn my CLI program into a website. That should be quick and easy, right?
Actually tbh if it's Python, you can grab flask/bootstrap and be up in a few hours probably. (IDK I don't do web stuff that's just what I used last time. )
Fancy? Nope. But works decently out of the box for the basics, and I'm sure can be fancied up later if you actually do web stuff/CSS/etc.
0
Options
thatassemblyguyJanitor of Technical Debt.Registered Userregular
Bitwise operators are lower than equality so the compiler sees (magnet & (mask != 0)) != 0
You would have been fine if you'd used the implicit test by leaving out the !=
Ha. Yeah, I'm definitely not used to throwing bits around.
The secret is to always use parenthesis everywhere to enforce a particular order of operations, and to use intermediate variables to break up complicated expressions.
Some bitwise and logical operators have lower precedence than checking for equality, which WILL screw you, as you found out. If you're in the habit of excess parenthesis, that's never a problem. Can look a little ugly however.
Using parenthesis, especially in embedded, is considered best practice. We had a team that didn't use them, and yes, they had many hidden bugs.
I will cut myself a small amount of slack for the real code being split across two methods, but come on! This is why I'm a big fan of doing all entity changes at the same place and then immediately either saving to DB or adding for save later and treating the object as immutable.
And now for something completely different! Changelogs/release notes, how do you people handle them?
I've recently switched teams at EchoCorp, from a domain team to what is tentatively called a backend platform team (population: me, though I do a lot of work together with our cloud ops team).
We use Renovate for automatic dependency version checks, which works nicely. It does MRs with great summaries of what changes in dependencies, including their changelogs when available.
So basically we're looking for something that can automatically make decent-looking changelogs for us to help us do automatic versioning and documentation.
For my personal stuff I've been using Semanticore, which works really nice at handling automatic versioning, and if you do conventional commits, then commits are separated by the type of commit/MR.
But at the end of the day that's still just a list of commits. Our frontend platform team uses changesets, which seems really nice for their monorepo -- you make a new changeset that includes your description of the feature, that eventually gets merged, and when you're ready for a release, changesets reads the changeset files, figures out what the new version should be, and makes a nice changelog combining the info from the changeset files. This decouples features/fixes from one or more commits.
Not sure how well that would work outside of a monorepo though, and it seems a bit coupled to the JS/TS world.
We have one we make you update--via like, CI rules, IDK how it works--manually when you want to release a thing. As in "put some notes in, monkey". CI will yell until you do it properly.
Really depends what level of granularity you want. We don't care about "every individual commit", just "bugfix/enhancement/feature" and whether it's breaking or not, so it's easy enough to fill out.
And now for something completely different! Changelogs/release notes, how do you people handle them?
I've recently switched teams at EchoCorp, from a domain team to what is tentatively called a backend platform team (population: me, though I do a lot of work together with our cloud ops team).
We use Renovate for automatic dependency version checks, which works nicely. It does MRs with great summaries of what changes in dependencies, including their changelogs when available.
So basically we're looking for something that can automatically make decent-looking changelogs for us to help us do automatic versioning and documentation.
For my personal stuff I've been using Semanticore, which works really nice at handling automatic versioning, and if you do conventional commits, then commits are separated by the type of commit/MR.
But at the end of the day that's still just a list of commits. Our frontend platform team uses changesets, which seems really nice for their monorepo -- you make a new changeset that includes your description of the feature, that eventually gets merged, and when you're ready for a release, changesets reads the changeset files, figures out what the new version should be, and makes a nice changelog combining the info from the changeset files. This decouples features/fixes from one or more commits.
Not sure how well that would work outside of a monorepo though, and it seems a bit coupled to the JS/TS world.
Anyone have any suggestions here?
We just manually update a changelog and enforce it before merging. Honestly, I feel like unless the amount of check-ins on a project is huge and constant, all these automated tools are overkill and just add unnecessary complexity. I wouldn't be surprised if more time is wasted, on average, configuring them and fixing them when they break than if someone just did the work manually.
i track most of my bugs and features in a trello board in a fashion reminiscent of kanban, and when its time to release I just go through everything in the "ready for deployment" column and write a note (if it needs to have a note written)
We're doing code review of code that is older than our interns.
I'm going to cry now.
I love old code archeology though. It's great! Comment lines like "this used to be to save memory, but the server has over 1gb of memory now so we don't need it".
Even if your order of operations is correct, I don't want to stop and have to think about it.
At the recommendation of a company testing our internal code for security vulnerabilities I installed SonarQube.
It complains so fucking much about "code smells" with nesting ifs and parenthesis. My brothers in christ, this is how heartbleed came to be, stop that shit, you're not making code safer by consolidating blocks to save visual space.
The dumbest part is it didn't even bitch about anything security, just this code smell shit.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Posts
I do 2ms delay between each step, giving about 18 seconds per rotation, which feels a bit off according to my math.
Then it stopped working.
Right now I get 6.77V out from the 9V battery that's powering this, so I guess I'll buy a fresh one tomorrow.
Ha. Yeah, I'm definitely not used to throwing bits around.
The secret is to always use parenthesis everywhere to enforce a particular order of operations, and to use intermediate variables to break up complicated expressions.
Some bitwise and logical operators have lower precedence than checking for equality, which WILL screw you, as you found out. If you're in the habit of excess parenthesis, that's never a problem. Can look a little ugly however.
I'm going to see if we can get these implemented on our enterprise instance
Now all I have to do is turn my CLI program into a website. That should be quick and easy, right?
That sounds like something people get arrested for.
If you can't see it, it's not public right?
*puts on trenchcoat*
Actually tbh if it's Python, you can grab flask/bootstrap and be up in a few hours probably. (IDK I don't do web stuff that's just what I used last time. )
Fancy? Nope. But works decently out of the box for the basics, and I'm sure can be fancied up later if you actually do web stuff/CSS/etc.
Using parenthesis, especially in embedded, is considered best practice. We had a team that didn't use them, and yes, they had many hidden bugs.
I like using named intermediate values for readability, but that doesn't seem to be as common a convention as I might expect.
Absofuckinglutely.
Even if your order of operations is correct, I don't want to stop and have to think about it.
It never even occured to me that there is the concept of things having lower precedence than equality. Brain still can't quite accept it.
You probably used it all the time without realizing it. relies upon && being lower than ==
I see that and want to group the sub expressions to make sure
*inserts a mutating operation into the && operator for giggles*
If anyone did that to my codebase I would cut them
This is precisely one of the ways it reduces bugs. Readable code means it's easier to review, and remove bugs before a commit goes into the repo.
Readable code tends to also be code that is well understood by the author and has fewer problems before review, also.
Pfft, do a mutating operator bool
Gavindel's brain: This is fine. We called save!
I will cut myself a small amount of slack for the real code being split across two methods, but come on! This is why I'm a big fan of doing all entity changes at the same place and then immediately either saving to DB or adding for save later and treating the object as immutable.
I'm going to cry now.
I've recently switched teams at EchoCorp, from a domain team to what is tentatively called a backend platform team (population: me, though I do a lot of work together with our cloud ops team).
We use Renovate for automatic dependency version checks, which works nicely. It does MRs with great summaries of what changes in dependencies, including their changelogs when available.
So basically we're looking for something that can automatically make decent-looking changelogs for us to help us do automatic versioning and documentation.
For my personal stuff I've been using Semanticore, which works really nice at handling automatic versioning, and if you do conventional commits, then commits are separated by the type of commit/MR.
But at the end of the day that's still just a list of commits. Our frontend platform team uses changesets, which seems really nice for their monorepo -- you make a new changeset that includes your description of the feature, that eventually gets merged, and when you're ready for a release, changesets reads the changeset files, figures out what the new version should be, and makes a nice changelog combining the info from the changeset files. This decouples features/fixes from one or more commits.
Not sure how well that would work outside of a monorepo though, and it seems a bit coupled to the JS/TS world.
Anyone have any suggestions here?
Really depends what level of granularity you want. We don't care about "every individual commit", just "bugfix/enhancement/feature" and whether it's breaking or not, so it's easy enough to fill out.
We just manually update a changelog and enforce it before merging. Honestly, I feel like unless the amount of check-ins on a project is huge and constant, all these automated tools are overkill and just add unnecessary complexity. I wouldn't be surprised if more time is wasted, on average, configuring them and fixing them when they break than if someone just did the work manually.
i track most of my bugs and features in a trello board in a fashion reminiscent of kanban, and when its time to release I just go through everything in the "ready for deployment" column and write a note (if it needs to have a note written)
I love old code archeology though. It's great! Comment lines like "this used to be to save memory, but the server has over 1gb of memory now so we don't need it".
To me, it's just hacks on top of hacks.
As I've said in the past, Javascript is a horrible language written by a horrible person.
At the recommendation of a company testing our internal code for security vulnerabilities I installed SonarQube.
It complains so fucking much about "code smells" with nesting ifs and parenthesis. My brothers in christ, this is how heartbleed came to be, stop that shit, you're not making code safer by consolidating blocks to save visual space.
The dumbest part is it didn't even bitch about anything security, just this code smell shit.
coincidence? or not...