Better HN
topnewbestaskshowjobs
Log inSign up

gregmac

9,763 karma · joined Mar 4, 2015 (11y ago) · 1,712 submissions

Simplicity is underrated.. YAGNI.
Submissions

comment 3y ago · link · parent

Having never heard of this, it just looks like a list of regex patterns. Am I missing something? There's lots of lists of patterns available [1]

If I came across this in code, I still have similar issues to regex. I have to question the source and what unit testing exists, that the tests cover the particular cases we care about, and if composed it needs tests anyway.

For context, I always split my regexs to a function and add unit tests for them, and ask the same in PRs. It is one of the easiest tests to write and most beneficial: if I don't discover a case I missed while I come up with example inputs, it protects any future modifications by future devs. It also empowers devs that don't know regexs well to be able to modify them (because they know it won't break) and to approve a PR with one.

I don't see how grok patterns avoid the need for tests (especially if composed), and if there are tests anyway, they're just a level of indirection.

In the worst case, when there's inevitably a bug (or app-specific missing situation) in one of these, it's harder to fix than just having a regex directly.

[1] https://github.com/mmkjony/awesome-regex-1 , https://regexlib.com/DisplayPatterns.aspx?cattabindex=5&cate...

comment 3y ago · link · parent

Many of these have a `TryParse` method [1] which makes for nice syntax, and of course then you get a variable of the correct type.

    if (int.TryParse(userInput, out var number))
    {
        total += number;
    }
This is cleaner code compared to try/catch and usually faster (though debatable if it matters) [2].

[1] https://learn.microsoft.com/en-us/dotnet/api/system.net.ipad...

[2] https://stackoverflow.com/q/161942

comment 3y ago · link · parent

Does anyone know of (or work on) an app still doing user-agent sniffing to determine browser features (as in, the sniffing code has been touched in the last ~decade)? If so, why do it that way?

comment 3y ago · link · parent

My office (near Toronto) was up for lease renewal about 1.5 years ago. Pre-pandemic about 50% of people were working from home at least some of the time, and by 2021 there were maybe 2-3 people in the office regularly (in a space that could easily have 45). The company was debating what to do but did want some physical space, and possibly would have just stayed considering the investment in build-out, networking (including at least a rack of internal servers and other infrastructure, with dedicated fibre to other company datacenters), video conference rooms, etc. What I heard was the building was trying to nearly double the rent, so this made a pretty easy decision and the place was closed. Servers were migrated to other locations, and everything else was shipped to other offices, given to employees, sold or scrapped.

Now it's 6 months later, and last time I drove by it still has our old sign up, and I can see online the entire space is still available to lease. Seems silly to risk it in the current market and take $0 instead of keep a quiet, established tenant.. but what do I know.

comment 3y ago · link · parent

I also transitioned to bitwarden about 18 months ago, but I haven't deleted my lastpass account yet.

I've used LastPass for password history once, and a couple times for notes (which don't get exported).

Now I want to delete my lastpass account completely but what would be helpful is if I can mark all my bitwarden passwords that are still the same as the ones in LastPass, as I'd like to change all of them. Anyone know a way to do this?

comment 3y ago · link · parent

> it cannot be read by exploiting a buffer overflow

What does the attack that does this actually look like? Lastpass reads text off an html page and decides when to inject auto-fill prompts and/or enter in a password. Is it possible for a buffer overflow to be exploited there, that lets an attacker (who controls the site) gain access to a password for a different site? How does that work?

Is there some other attack possible here? Ie: is it possible another user-space application can read passwords from memory used by the password manager? How does another app know it's a password? How does it trigger a buffer overflow?

(I'm ignoring apps running with kernel or privileged access: that seems like game over)

comment 3y ago · link · parent

Absolutely.

I've bought several things specifically because they use esp32 and I can flash Tasmota or EspHome on them. In fact it's a far bigger factor than price.

comment 3y ago · link · parent

Does anyone buying an "exclusive" copy actually believe they're getting that?

The pricing is also interesting from another angle, if we take them at their word ("5 copies" vs "exclusive"): why accept 25% less overall? Assuming this is a cryptocurrency transaction, it surprises me the simplicity of dealing with a single buyer is worth that. Can anyone with more insight explain?

comment 3y ago · link · parent

I see a few things that might be worth adding, as some were explicitly why I switched from LastPass a few years ago:

* Security model. What is stored server-side unencrypted? In what circumstances is the server-side encrypted data available on the server in plaintext?

* Defaults: "parent-safe"? What trade-offs are made with the defaults picked?

* Ability to edit (Android) app associations. Bitwarden has this, and it solved a huge problem I had with duplicates on LastPass. There's URI entries like androidapp://com.example.app that are easy to manually merge and keep together with corresponding web sites.

* Domain matching. Bitwarden can do: base, host, exact, starts with, or regex. Lastpass had an "equivalent domains" managed from obscure settings, which never really worked the way I wanted. I used to have a billion entries for things in .mydomain.com, but bitwarden fixes this and by setting that flag properly I get only relevant things for each internal app. At the same time, for .myapp.com and .myapp.local I can get the default dev login, so when I deploy a new instance/tenant for dev, it "just works".

Username generation. Can it do plus-addresses? Catch-all domains?

comment 3y ago · link · parent

What's described here is not a website; it's not even HTML (it's "HXML" [1] )

Ignoring that, and addressing your question: there are several things apps can do that websites can't, even if the app is really just a wrapped/packaged website (and actually HTML):

Native notifications

Background tasks

Full access to sensors

Access to file system and contact lists

Handler for system actions

Offline support (though this requires more work beyond a mere 'wrapper')

Also, don't underestimate the marketing/branding impact of having an app icon that's always there. Sure, you can get users to bookmark a site, but it's a very different action from having an app icon, and it opens and works in a different way. To techies this is a rather pointless distinction, but to most users this is huge.

[1] https://hyperview.org/docs/example_index

comment 3y ago · link · parent

It's possible to silently do this as part of logging in.

I've done this with normal login for several (legacy) systems I've worked on, migrating users from md5 or sha1 to better algorithms.

comment 3y ago · link · parent

> at least on the App Store and Google Play you can't verify that the open source code is what's shipped

Is there a reason Google and Apple couldn't change their deploy flow to pull from a git repository? As in:

1. Developer pushes to a specific remote (or pushes a specific tag or branch)

2. Apple/Google run the build on their systems, sign it, etc

3. If passed, the app deploys and the published app is annotated with the specific git hash (which can also be displayed in the app store)

For open source, it gives the public verification ability.

For closed source, it is still useful for internal verification. I work adjacent to some mobile teams and most still do builds on a developer's desktop and upload that. I am working towards getting CI for everything, partly to reduce dependence on any one developer's system (eg: I hear things like "Only Tom knows how to do builds to give to Apple, but he's out today") and partly for security. As much as I believe we don't have developers with malicious intent, there's still no way to know that a build uploaded from a developer's desktop really is what's in source control.

comment 3y ago · link · parent

When I've heard people making similar claims, what I've usually found is they're testing "glue" code: controllers, routers, etc. Personally I find this a near total waste of time: it's hard to write the tests, almost never actually catches a bug, and failures in this code are totally obvious during a smoke test - automated or not.

I write a lot of "application" code (cli, service and back-end) and a lot of tests. Parsing, calculations, file generation, regex .. that catches lots of bugs.

The value comes from keeping the complex code separate from the glue, and of course testing it. And you can easily test dozens of cases, which is usually not true of integration tests due to complexity and run time.

comment 3y ago · link · parent

You can pretty much say the exact same thing about stealing someone's wallet or purse. There's a lot of travel advice to the effect of "don't keep everything in one place". A phone is no different.

A phone at least has the benefit of being backed up. In theory, I could log into a couple accounts on a brand new phone and have access to everything within tens of minutes. Contrast to the hours of phone calls and weeks of waiting it takes if I lost my driver's license, passport, etc.

And though a phone can be used for payments, it must be unlocked. Not true of the physical credit/debit cards (swipe or tap) or cash found in a wallet/purse.

If you have non-backed-up 2FA tied to your phone, you should fix that. Batteries die, and phones can be physically damaged, bricked for some software reason (they're computers, after all), dropped into the ocean or off a cliff, or just legitimately lost (ie: falls out of pocket into the cracks of a car seat and battery dies).

I won't weigh into the punishment-deterrent argument at all, I'm merely pointing out that in theory there's actually a lot less disruption having your phone stolen vs having a wallet/purse stolen. Both suck, of course. Replacing a phone is almost certainly more expensive, but it should be significantly faster to recover from. And backup your 2FA.

comment 3y ago · link · parent

There is a spec (RFC 4180 [1]) but it's definitely not widely followed. Worse, for a lot of data there's no problems for potentially years, until your numbers get too big or the first time a quote or comma gets in the data.

In my experience one of the biggest barriers I run into -- and the primary reason I hate using CSV -- is Microsoft Excel. It misinterprets numbers as dates, it convers big numeric identifiers to exponents, and more. Even merely opening a RFC4180-compliant file and saving it changes the data, and even Excel itself will often have a different misinterpretation of the de file.

If humans never used Excel for CSV, it would be a viable format. At the same time in most cases where humans aren't in the loop (machine-to-machine communications), there's better formats. You could spec "RFC4180 CSV" and hope no developer just sees the "CSV" and assumes they understand. Or specify something like a JSON streaming format and avoid a whole lot of headache.

[1] https://www.ietf.org/rfc/rfc4180.txt

comment 4y ago · link · parent

What the GP is talking about is not letting developers install stuff on their PC. I assume this is also "run unknown exe" because.. well I can't see any reason local root could hurt the network in a way my user account couldn't. Unless maybe the PC is shared, there's no difference of install (local root) compared to run as normal non-user, as far as attack surface on the network.

So this comes back to: do you block "potentially malicious" executables or not? How do you tell if a new never-before-seen executable needs to be blocked, without either just blocking every unknown executable ("dev can't get anything done") or opening a giant loophole ("anything in x directory is safe")?

Let me write it a different way: An exe with an unrecognized name and unrecognized sha256 suddenly appears on my computer. Maybe I just compiled it from source I wrote, or maybe it is a random thing I downloaded and unzipped. How does a decision get made on whether my system will run that or not?

comment 4y ago · link · parent

I wonder how this type of question even gets written. Does the author purposely put in these "gotcha" questions to see if you read the textbook? Or are they literally unaware of how bad the question is written - ie: their knowledge is limited to the point they don't see the nuance or unambiguity?

comment 4y ago · link · parent

I actually don't think I've ever seen that one in the wild! I've seen 7-Dec-2022 which looks goofy to me but is at least unambiguous.

What does a full timestamp look like? For consistency I hope it goes all-in on being little-endian:

    ss:mm:HH DD-MM-YYYY

comment 4y ago · link · parent

> it requires a development team to realise that just because they're good at programming computers it doesn't mean they're good at administering them. Yes, it sucks that you're not allowed to install bonzibuddy.exe from Limewire

What exactly is IT doing when a dev requests to install randomtool.exe? Why is it a developer is incapable of that same thing?

> Realistically, how often do you need to install brand-new non-standard software?

Well, does my own software count? I mean, I've run an executable that didn't exist 5 second ago more times than I could possibly count. I've also built installers for said software, and then executed and installed it on my machine.

Is that ok? If so, why (if I also can't download and run something from github)? If it's not ok... how I supposed to do my job?

comment 4y ago · link · parent

"This date format works for almost 61% of the year" isn't a great selling point.

comment 4y ago · link · parent

> Apparently some folks, like the people running ccTLD registries, believe that allowing the public to know IP addresses for large numbers of domains is a "security" issue.

There's some merit to this.

Doing the reverse lookup - finding all other domains that resolve to the same IP (or same subnet) can leak a lot of information. For example: what other businesses are run by the same entity, and test/staging/admin infrastructure.

It can also be another way to attack a specific http server, since different names on the same IP can be routed to different applications or even different internal servers.

Actually relying on this is silly security-by-obscurity, but there's really no upside to publishing a detailed map.

comment 4y ago · link · parent

Another big difference is the way we consume. "Watching TV" used to mean watching whatever was on in the current timeslot, which often meant flipping through channels until you found the least-bad thing you could tolerate.

In the last 10-15 years that style has all but disappeared* and been replaced with Netflix-style services (and maybe PVRs for sports fans and 60+), where you don't watch "TV" but watch "a show".

Browsing tiktok or YouTube might be the closest thing that people still do to channel flipping, but since it's customized and endless, there's never a need to settle for the "least-worst" thing you can find.

(* I'm sure there are people that still do this, but I'm saying this based on my circle of close family/friends, many of whom are non-technical).

comment 4y ago · link · parent

FWIW I used to use software (Speedfan, and later something else I don't remember), but after upgrading to Noctua fans, I found whatever is built-in to the motherboard works just fine and gave up on the complication of software. I'm on my second system like this, and I've found they've both been a good temperature and nearly silent most of the time. Even maxed out, it still seems to be quieter and cooler than it would be with most (cheap) fans.

comment 4y ago · link · parent

Do we need to have a single letter? Is it acceptable to combine prefixes?

Eg: 1 QB (quettabyte) == 1,000,000 YB (yottabytes) == 1 MYB (mega-yottabyte)

Without the new prefixes, we could have gone to 1 YYB (1,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, or 10^48 bytes)

comment 4y ago · link · parent

I agree with the other comments about it often being a hint to break apart a method, but there's still valid reasons to reassign.

I'd rather focus my energy on adding unit testing, and refactoring to be testable. If you have easy-to-read unit tests that cover all possible edge cases, I stop caring (as much) about how the actual method is written. Be as optimized/clever/concise as you want. I don't care if you reassign your local variables.

comment 4y ago · link · parent

> A problem I have at my current place is that the dev team in my opinion is far too happy to add new features whenever they're requested.

> And you might argue, "well why don't you abstract more".

A place I work was acquired by a company that owned our main competitor. When we were comparing them, I used to joke that the team had spent 10 years saying "yes!" to literally every feature request.

They of course did it with abstractions, so it "wasn't that much more complicated".

Feature-for-feature, our software could only maybe 15% of what theirs did, while theirs could do 95% of ours. The difference was the features we picked were the only ones 80% of the customer base actually used.

Worse, because everything was abstracted, setting up those simple use cases was usually an order of magnitude more complex for the users: something that was a checkbox in ours was 15 different toggles and inputs, and very easy to screw up. Sure it could also be setup to handle hunderds more scenarios.. but in reality only there were just a few that only a tiny fraction of users even cared about.

That, to me, is the danger of abstractions - at least it they make it up to the UI layer. QA (and automated testing, if it was written) still has to test the hunderds of scenarios because they're possible. Support has to understand. Dev has to maintain.

It was interesting to compare the approaches, at least, and I came away with the conclusion: I never want to build that way. I'm all for internal abstraction: build the capability and flexibility to expand in, but have a very concrete and constrained UI that only exposes what actually has real value. And make it dirt simple to do the most popular use cases.

comment 4y ago · link · parent

> When you're starting those "replace X system" projects, what you're not anticipating is that half of those projects fail: they're either end up taking way longer than planned, or they don't get finished at all because they miss some critical requirements. The bigger the project, the more risky it is.

Totally agree! However, there are ways to do them successfully. I've done it many times.

There's no need to ever get into a position where you miss a critical requirement, let alone having it prevent completion. My favorite method is building replacement systems in parallel, leaving the existing stuff in place. Often there's a good opportunity to do a totally new feature this way first (maybe allowing you to increase your total addressable market), before you start adding existing features from the old system.

> Because, let me guess, you want to refactor, but you can't sell refactoring to the management.

Ugh. This statement grates at my soul.

First, let's deal with "want to refactor". Up front, as a technologist, I'll admit I do sometimes want to refactor bad code/systems/whatever purely because they're bad. However, as a professional, I know I need to justify that work.

This brings to the second part, "sell refactoring to the management". This is just not a conversation that I ever have.

If I am (or my team is) being slow due to constantly refactoring code, management is going to question what I'm doing and hold me accountable.

If we're slow and causing customer complaints because every time we touch code we add more bugs and start a break-fix cycle... management is going to question what I'm doing and hold me accountable.

What I do is look for spots where there's a provable return on investment (justification), and simply make that part of the next bug or feature we're working on. If you can take a system/component/whatever that is constantly getting bug fixes, spend slightly longer on the next fix (because you're refactoring) and then have fewer bugs after and/or be able to implement features faster, that's a win. Do it a couple times, and you'll never be questioned about this type of work.

The discussion around doing a large-scale replacement is entirely different, and the ways to justify it are using real numbers such as: potential to hit new market; time spent on support; time spent fixing (repeat) bugs; time it takes to implement changes; time spent fixing new bugs anytime someone modifies the system. Just like above, if you can't prove this, you shouldn't be doing it.

>> Looking forward we have customers asking

> And how far in the future are we looking? It might be years before it becomes a real problem.

Let me clarify my sentence: "Looking forward in the backlog, we currently have open customer requests.."

I agree with the sentiment I think you're getting at, which is you shouldn't build to unknown future requirements. You'll pretty much always get it wrong. I teach this to juniors with an analogy like: If you build a foundation for a skyscraper before you actually need a skyscraper, what you'll often find is it needs one more underground parking level than you thought and to be rotated by 15° -- so everything you built is not just wrong but is actively blocking you from building what you need.

> You might be absolutely right in your desire replace the login system. Or you might be a perfectionist that's eager to solve problems that don't matter.

Let me just be clear, because I wasn't originally, that my "login system" was a fictional example. The real examples I have require too much time to explain adequately.

> The great thing about incremental process is that for a relatively small cost those risks go away.

The point is sometimes a rewrite makes more sense because it solves several problems at once. This is where I take issue with the original article.

You hit on the reasons a full out rewrite fails: Not understanding all requirements. Doing a switch without backwards-compatibility. Going months/years without delivering value.

At least I think this is where we align again: The key to a successful rewrite is building incrementally, delivering value as quickly as possible.

comment 4y ago · link · parent

I have the same reaction. Sometimes there's multiple problems that can all be solved at once, and it is like a force multiplier. Often it's from what you could call "outside the box" thinking, where you maybe take a totally different approach.

For example, there's a bug in the login system, again. Ok, we could probably fix it, but this is an old system built by outside contractors (aka "built cheaply, but expensive to maintain"). It's not the first bug, and won't be the last. There's some technical debt in the way it stores unsalted sha1 passwords, password resets work in a way that allows an attacker to effectively lock out accounts and do a DoS. Looking forward we have customers asking about MFA and SSO support that this system just can't do.

"Solve only one problem" philosophy says to just fix the bug. This is a case where replacing the system (whether buy or build) might make more sense. You have to be pragmatic about this of course, because if you can't live with the bug for however long it takes to replace the system, it isn't going to fly.

I'd still advocate some constraint, though: iteration 1 should fix the bug(s) and underlying tech debt, but shouldn't be adding anything new.

Some of the most productive work I do is this style because it's often only a bit more effort. I used "login system" only as an easy to understand example, it's often more subtle, along the lines of: refactor a class so it has unit tests and fixes 3 other related but low priority bugs at the same time, instead of just patching. Instead of a day, it takes a week, but more value was delivered (other bugs fixed), there's significantly lower chances of bugs in the future (as future dev work happens), and we can reduce or eliminate manual QA on that component. The extra 4 days have saved dozens we'd spend over the next year if we dogmatically stick to "one thing at a time".

239.

Arduino unveils the Opta – “Micro PLC” for industrial IoT(hackster.io ↗)

120 points · by gregmac · 4y ago · 86 comments

1
789
58