When I needed similar system for producing weighted choices, I initially tried designing some kind of a fancy bell curve-like math function. But in the end, I realized I feel a lot more comfortable just setting a segmented line and pulling numbers from that, similar to your implementation. KISS.
Posts made by cartman82
-
RE: There's got to be a better way of doing a random choice from a weighted set (C#)...
-
RE: More unified Windows GUI frameworks?
@Rhywden Interesting. Seems like their version of React Native, just with a dotnet runtime instead of javascript puppeteering native widgets. Windows and macOS, no linux announced. I'm a bit skeptical about mobiles being bundled with desktops, that never works out well.
I'll definitely try it out when it comes out, but I don't have high hopes they won't fuck it up.
-
RE: More unified Windows GUI frameworks?
@anonymous234 said in More unified Windows GUI frameworks?:
Too fucking late to get your shit together, Microsoft. Enjoy seeing Windows APIs fade to HTML5 and Android apps.
YES.
They needed to start working on a cross-platform app framework the moment company was restructured to not be Windows-centric anymore.
Their own new products are now using Electron, who are they kidding with this shit?
-
RE: Video game spotlight thread
@Zecc said in Video game spotlight thread:
Oh @cartman82, if only you knew back in 2017 how 2020 would be like.
I was old and naive.
-
RE: Why is my dockerized nginx proxy getting stuck in a boot loop?
If you can't touch images, what is it you can even do to resolve this? This nging docker running locally on your computer? Can you shell in?
-
RE: manually defined automated testing
@Zenith said in manually defined automated testing:
@cartman82 This library is a little different. When compiled as an EXE, it has some built-in demos. Part of it runs these tests. Another part shows off custom controls. Otherwise it's just a DLL that fixes alot of stupid/half-baked stuff in the framework.
Ok, if you need to be able to click something and show off that everything works as it should, then it makes sense. More like a demo mode for the consumer than a test suite for the developer.
-
RE: manually defined automated testing
@Benjamin-Hall said in manually defined automated testing:
@cartman82 Last I checked, most people use some form of test runner and VS has built in "run all the tests and tell you the output" functionality. Pretty complex ones as well.
That's what I mean. Test runner spits out test output as text, and optionally IDE ingests it and annotates code based on it.
-
RE: manually defined automated testing
This is the strangest thing ever. You are making a test that basically builds into a gui app that shows the results.
I'd usually want test results outputted in some kind of text format. In dev, my IDE can parse that format, and apply it back into the codebase. So I'd see little play icons above each test and red/green indicator of what happened when it was last run. In CI, I would see that output in the log, or get sent in an email, or something.
What is the advantage of doing it this way? Is this the standard in windows app development? (the last time I did windows dev, I had no tests, or version control for that matter)
-
RE: Security Snake Oil Inc.
Almost all of it.
Someone comes up with some rule that seems reasonable at a time. And it maybe is. So it gets adopted.
But then, even if majority starts thinking that rule is bullshit or no longer applies, no one will speak up about it and put their reputation on the line to remove it.
Because the upside of that move is all in the reduced opportunity cost, which is diffuse and difficult to quantify. You personally get nothing out of championing it. The downside, on the other hand, is direct, evocative and the blame directed squarely at you. Why didn't you think of the children!?
So you stay silent. So does everyone else, in a prisoner's dilemma kind of situation. That's why we have shit like bank password policies accumulate like fat in our veins, slowly snuffing us out.
Your SPA rules seem to be in the same vein.
-
RE: Thoughts on why so much .NET code is just awful...
@kt_ said in Thoughts on why so much .NET code is just awful...:
So, how does the sewer freedom taste?
The same, but they have foosball table, so eh.
-
RE: Thoughts on why so much .NET code is just awful...
@MSgtSoupSandwich said in Thoughts on why so much .NET code is just awful...:
Wow, I left .NET over 5 years ago now, and all this sounds pretty much how I remember it.
Help. How did you escape?
Slowly filed away bars with a file I hid in my butt, swam through sewers the entire night to reach freedom.
-
RE: Thoughts on why so much .NET code is just awful...
Wow, I left .NET over 5 years ago now, and all this sounds pretty much how I remember it.
-
RE: Windows Subsystem for Linux
I played with both WSL and MSYS2 on Windows. Both have their issues, neither is quite on the level of a real linux host.
WSL's big problem is interop with Windows. If you want to open a windows program from shell or have a windows debugger connect to a process running in linux-land, you're gonna have a bad time. It's possible to do some of that stuff, but not without constant issues.
MSYS2 / cygwin has better interop with Windows (not ideal), but it's not actually real linux. It's slower too, it has limited variety of software, it has problems with stdin/stdout when interfacing with Windows CLI apps.... It's basically a weird half-supported hack. This is what I'm using at the moment, but it's not ideal.
Mac has the best GUI-over-nix you can possibly get. Sure, it's some outdated version of BSD instead of real linux, but you can install enough gnu stuff that there is little practical difference. The problem with Mac is, if you are used to Windows/KDE paradigm and keyboard layout (and like it), it's gonna be an uphill battle. I tried adapting MacOS to work more like Windows, but that setup was always kind of glitchy and "90-ish % there".
In the end, VM running on Windows is probably the way to go. There are two speed bottlenecks you'll encounter:
- Disk access, there is shitty NTFS underneath the linux image slowing everything down. I heard you can go around it if you have a raw partition you use only in VM, but haven't tried it.
- Graphics. It used to be that VirtualBox didn't support 3D acceleration properly and I had to run some lightweight DM, like XFCE, to get decent speed. New versions now support the same interface as VMWare, so things work much better now on that front.
-
RE: Game Deals Thread
Grim Fandango Remastered is good classic adventure game, if you're into that.
Wasteland 2 seems like a great classic style RPG, but I haven't played a lot of it.
Shadow Warrior 2 is a cool FPS.
Talos Principle is a fantastic first person puzzle game.
$15 dollars seems worth it, considering this is against the usual PlayStation prices.
-
RE: Stardock, Star Control, I'm in space?
I was sniffing around Origins on Steam before the ban, but the reviews were mediocre and price too high.
If those authors are smart, they'll use the increased visibility created by Stardock's marketing to prop up their (better?) game, instead of wasting time in courts.
-
RE: When the reviewer doesn't understand my Javascript it's his fault
This situation sounds infuriating.
For the coding standard, I recommend setting up
prettier
and making it mandatory to format all PR-s.Some teams also use very strict eslint to combat shit like this, but IMO that's going a bit too far towards trying to solve a political problem using technology. The best solution for a guy like that (if you don't have pull to get him canned) is to put him on writing supplementary code (eg. tooling or unit tests) or work on support projects ("need a JS coder to handle jQuery on a marketing site? I have just the guy for you").
-
RE: Android Studio
Android emulator is the worst. I hate how it tries to play smart with stupid little gizmos hanging off the window instead of having a normal menu. WE ARE NOT LAUGHING WITH YOU, ANDROID EMULATOR, YOU JERK!
Android studio, on the other hand, makes the android dev almost bearable, if you have strong enough machine.
-
RE: Appropriate error response body for CSV
@Tsaukpaetra Called via CGI I presume? :)
-
RE: Appropriate error response body for CSV
I ended up doing the 2-step solution I said was pain in the ass.
Initial request prepares the CSV and saves it to cache. Client gets a JSON message in the usual format, containing link to the unauthenticated endpoint serving CSV-s (using one-off token for security). It then immediately opens the link, initiating download.
This setup takes care of a few issues stated in the thread above (validation, errors) and a few unstated ones (passing security token). Since I don't predict mammoth CSV downloads in the near future, I am just keeping the CSV content in server RAM, which makes implementation less of a PITA than I feared.
In case the download link produces an error (much less likely than the initial request), I generate a simple HTML body and send that back instead of the CSV. The api codebase isn't really geared up for producing HTML, but I figure this use case is rare enough that I don't need to optimize for it.
-
RE: Appropriate error response body for CSV
@kazitor said in Appropriate error response body for CSV:
What I could do (and I did a few times before) is have a two-step process. One JSON request to "prepare" the download, and this returns either the usual error payload or the download link. The browser is then redirected to the download link, which is handled like a static asset (cached somewhere on server HDD, for example).
That's what I would assume would be done. The question is what extent of is present.
That was kind of PITA the last time I did it. I needed to handle half-saved corrupted files, TTL, cleanup... Necessary if it can potentially take more than 5 seconds to generate a report, but PITA nonetheless.
If I can get away with an empty body and direct CSV response, I'll totally go for that.
-
RE: Appropriate error response body for CSV
@Gąska said in Appropriate error response body for CSV:
It sounded like your only reservation against returning empty response was that empty response gets replaced by stupid JSON. As in, if it didn't do that, there wouldn't even be a question what to do.
No, I meant if I didn't do anything special, my web app would return JSON by default. I can totally replace it with empty body on my end.
-
RE: Appropriate error response body for CSV
@kazitor said in Appropriate error response body for CSV:
@cartman82 It's out of my personal experience, but could the download link send some simple JSON response (perhaps with appropriate headers) upon error, and some JavaScript attached to the download link is somehow able to determine whether it received a file or error?
Not directly. The issue is that download is basically treated not as AJAX, but as a completely separate request. So there is no javascript on the other end, just pure browser (or curl/telnet/whatever) client getting an HTTP message.
What I could do (and I did a few times before) is have a two-step process. One JSON request to "prepare" the download, and this returns either the usual error payload or the download link. The browser is then redirected to the download link, which is handled like a static asset (cached somewhere on server HDD, for example).
-
RE: Appropriate error response body for CSV
@Gąska said in Appropriate error response body for CSV:
@cartman82 the nginx way - put enough spaces that the algorithm detecting empty response gives up and and doesn't put their own shit in there.
I am not up to speed, what would I be trying to achieve with this?
-
RE: Appropriate error response body for CSV
@kazitor said in Appropriate error response body for CSV:
Can you not just send an error page/dialog saying that there was an error (and elaborating as appropriate)?
Well, I would point user's browser towards the download CSV link, so whatever happened there would have to happen outside my SPA. I guess I could switch to HTML and display an error page, but I would have to recreate a lot of context user is expecting to see (design aesthetics, language they picked...). Dunno if it's worth the trouble...
-
Appropriate error response body for CSV
Hey, a quick question. Let's say customer clicks on a "Download CSV" link, but there is an error on the backend. I'll obviously set the HTTP status, but what's the appropriate response body?
If I do nothing special, they'll just get the usual JSON payload which seems crappy. Should I send a special error CSV? If so, user might be confused at getting a different CSV than they expected. Or maybe send an empty body?
Dunno. What do you think?
-
RE: The peril of "cheap" domains
@pie_flavor said in The peril of "cheap" domains:
@Benjamin-Hall And Cartmanistan makes plenty of money off of Rust sites which by convention all end in .rs.
Don't forget cleverly named https://lobste.rs
-
RE: The peril of "cheap" domains
@El_Heffe said in The peril of "cheap" domains:
I've always felt that domain names should cost at least $200 a year. Maybe more. If you aren't willing to spend that much then you aren't serious and need to get the fuck off the Internet.
For business domains, yes. And something like
.me
or.my-country.me
should be free. -
RE: Game Deals Thread
Why are all these crappy time limited demos being treated as "deals" all of a sudden? In shareware days, you used to get 1/3rd of the game for free, for fucks sake.
-
RE: The peril of "cheap" domains
@El_Heffe said in The peril of "cheap" domains:
At one time, suck.co.ck was available. I wanted to buy it but it was a bit expensive and I'm not really in any sort of business that would need that.
Oh dude. You could have setup like a full screen billboard that you can easily change, then when arguing on forums, be like "you can see my reply on my site, suck.co.uk".
-
RE: The peril of "cheap" domains
@Gąska said in The peril of "cheap" domains:
Fundraising. Submitting request for new gTLD costs money.
Of course. And that's why they are all more expensive than the "normal" ones.
-
RE: Who are you?
It's very distressing indeed. If only we had an avatar CDN, with long caching...
-
The peril of "cheap" domains
We needed a domain for internal use. Boss cheaped out and bought an
.icu
domain, which is like the cheapest of the cheap "premium" domains on namecheap, for like $1 or something.Except, oops. That price is a giant scam, because after first year (when you have all your infrastructure well and tied to the domain), price jumps to like $15, which is more than a
.com
.This isn't even the worst I've seen, some TLD-s jump to twice the price of the Big Three or more.
Boss: "Oh, OK. It doesn't mater, it's not that much money anyway."
Except, now we need to test DNSSEC and we can't get it for this shit domain. Only the top 15 or so TLD-s are supported on namecheap.
What the fuck is the point of all these stupid TLD-s they are adding? They are not cheaper, they are not better, advanced features don't work and no one takes them seriously anyway. Try explaining to customer that they should go to "mybusiness.business" instead of "mybusiness.com" to buy from you.
This recent attempt to extend domain space away from com/net/org has been a colossal failure so far.
-
RE: Game Deals Thread
@Parody said in Game Deals Thread:
Subnautica is now free from the Epic Game Store for the next two weeks. Might as well get something from all that Fortnite money!
Fuckers!
-
RE: So I tried Go the other day
@Gąska said in So I tried Go the other day:
How do you figure out what to expect if you don't even know what can happen?
Blacklist instead of whitelist.
I don't care about 99% of possible error conditions. The ones I care about, I'll research and handle. If I don't expect it, then send 500 to user and/or crash the app. I'll figure out what it was from logs and fix it if needed.
Yes, I see how certain kinds of programs might need guarantees about execution flow, but that hasn't been the case with any of the programs I've worked on (mostly desktop, cli and web apps).
-
RE: So I tried Go the other day
@Kian said in So I tried Go the other day:
@cartman82 won't deny that RAII was a bit broken before C++11, which caused a lot of issues. But the "bureaucracy" added nowadays is "write auto foo = std::make_unique<Foo>(); instead of Foo* foo = new Foo();".
In exchange, you never have to write a "using" or "finally" clause to remember not to leak every other kind of resource. Never quite understood why people that like automatic management of memory like manual management of everything else.I am not a C++ guy, so I'll take your word for it. But you don't have to convince me, you have to convince people like Pike and Blow, who are actually designing new C-replacement languages :)
-
RE: So I tried Go the other day
@Gąska said in So I tried Go the other day:
Whoever thought non-local error handling is problematic has smoked too much C/C++ crack. Their concerns have no place in memory managed languages.
The problem isn't non-local error handling. The problem is not being able to tell which functions throw exceptions and which don't.
I never found that to be a problem. If I care about a certain type of error, I figure out what to expect and catch it. Otherwise, I let it bubble to the general error handler at the app or request level.
Figuring out what errors to expect can be an issue, forcing me to dig through the library source code or docs. But it's exactly the same type of problem with callback/return style error; you still need to figure out which error codes are possible and what to handle and what to pass through.
In fact, Java-style exceptions are the only construct that tries to address that issue. And those are a bit too verbose for most real world use cases and are shunned even by exception advocates, so...
-
RE: So I tried Go the other day
@topspin said in So I tried Go the other day:
And C++ has had RAII from the beginning...
That's basically adding a lot of bureaucracy to get what memory managed language does out of the box. I can understand why a lot of C gurus are boycotting the pattern.
-
RE: So I tried Go the other day
@Zecc said in So I tried Go the other day:
What took hours of careful orchestration and error juggling is effortless with promises.
I wish you good luck with stack traces and never forgetting .catchs and returns.
One general catch on the request level. All errors roll back to that. If I want custom error, I can add intermediate catches and throws, but those are nice-to-haves, not show stoppers.
Background processes (not tied to requests) must be caught manually, but if I fail to do so, the application crashes and I fix it.
Stack traces can be a bit iffy, but I have utilities that extend them at crucial junctions (eg. going to the database, web, hard drive, etc.), so it's generally not a huge issue.
-
RE: So I tried Go the other day
@dkf said in So I tried Go the other day:
Use case: I'm trying to think how a database transaction would be handled; mechanisms to scope those to a particular section of code with success-exits committing the transaction and erroring-exits automatically triggering rolling back are superb for ensuring that data access semantics are correct, and are hugely simpler than doing it by hand. In truly sensible languages, I can do this by just giving a block to something (that depends on the language) that says “I'm scoping a transaction to this block”, and you can simulate it with various techniques in other languages (I've got utility code for Java that makes this fairly easy even without a framework like Spring; there's still little syntactic overhead). The more code it takes at each use, the more likely programmers will get this wrong.
I am doing this with a Promise in javascript and it works great.
-
RE: So I tried Go the other day
@MZH said in So I tried Go the other day:
I thought the main complaint against C++-style exceptions was their non-locality.
What I meant was, people who had to deal with exceptions in C/C++ go to design their new memory-managed language and are now ideologically opposed to exceptions, even though a lot of their issues go away when you don't have to worry about releasing memory.
Mostly because of the challenges of getting the memory management right. With garbage collection, those objections are mainly moot.
^ exactly.
-
RE: So I tried Go the other day
@wft said in So I tried Go the other day:
Error handling got me flashbacks from the C days. Rob Pike might have a kind of a personal grudge towards proper exceptions, but making them nonexistent and forcing everyone into explicitly handling errors in every damn place they might occur is as stupid as it gets (I know there's panic and recover, but it's of no help if nothing in the standard library ever uses it).
Until about 6 months ago I was maintaining a node.js codebase that relied exclusively on callbacks with the
function (err, result)
signature. So I was doing pretty much what Pike and his bunch would want go developers to do.In the new code-base, I use Promises. And I am NEVER going back. What took hours of careful orchestration and error juggling is effortless with promises.
Whoever thought non-local error handling is problematic has smoked too much C/C++ crack. Their concerns have no place in memory managed languages.
-
RE: So I tried Go the other day
@anonymous234 said in So I tried Go the other day:
I hate the "global variables are bad" meme. Global variables store global state. Global state is a thing that most programs, by necessity, have. Yes, state should always be as contained as it can be, but that doesn't mean you can't have program-wide state. And any way of "hiding" it makes things worse.
I like injecting state whenever possible, but that gets harder and harder the further away from singleton services you get.
I mean, has anyone tried injecting DateTime state, instead of relying on the implicit global? I did that here and there (mostly through duck-typing), and it's not easy. When I do manage it, it makes testing so much easier, though.
-
RE: Alternatives to CMDER?
@sweaty_gammon said in Alternatives to CMDER?:
I just really want tabs and something that doesn't crash when I CTRL+C when quitting running an angular-cli app. It works fine in the standard git bash that it uses minitty.
Hard to get cli stuff working nicely on Windows. That's why web devs are all on Linux or Mac. It's a world of difference in ergonomics.
-
RE: Alternatives to CMDER?
@sweaty_gammon said in Alternatives to CMDER?:
@cartman82 I am not that interested in that though. I've got WSL and Babun if I want a Linux like environment.
Ah so you just want a terminal emulator program that runs cmd? Can't help you there, mintty is probably the best you can get.
-
RE: Alternatives to CMDER?
@sweaty_gammon said in Alternatives to CMDER?:
@cartman82 That is basically the git terminal I get when installing git.
Similar. You can install more stuff with pacman, though.
-
RE: Alternatives to CMDER?
I've been using MSYS2 for a few years and I am fairly satisfied with it.
It uses mintty as its terminal emulator, which is fine. I also like to have my nix environment inherit ENV from windows and to use the same HOME directory as Windows (c:\Users<username>), so that everything is integrated. Last time I was setting it up, these had to be configured manually.
Times are changing though, as WSL is getting better and better, and MS is finally adding proper support for consoles. So maybe my next install will switch to a more native toolset.
-
RE: :wtf: How can this be so wrong??? (AKA the Discopocalypse thread)
@boomzilla said in How can this be so wrong??? (AKA the Discopocalypse thread):
We started using Dicksource in May 2014. We were no longer welcome as of September 2016 though it took us a few months to actually migrate. Probably early 2017, but I don't really recall off the top of my head.
The question is, when we started using it, how old was the project? Looking at github graphs, looks like 2013. So we were using it from when it was 1 years old until it was 3.
-
RE: :wtf: How can this be so wrong??? (AKA the Discopocalypse thread)
@hungrier said in How can this be so wrong??? (AKA the Discopocalypse thread):
Did something happen to Angular 2?
Angular 2 had no update path from Angular 1, you had to rewrite the entire application. Kind of like python 2 -> 3 transition.
-
RE: :wtf: How can this be so wrong??? (AKA the Discopocalypse thread)
When did we get off Discourse again? 1 year in, 2 years, 3 years...?
-
RE: The latest npm security kerfuffle
Here's a reddit comment I can get behind.
The discussion in github is really sad for me to read and it's a nice example why the npm ecosystem suffers from security issues more than any package management ecosystem. The claim that "Developer shouldn't do background checks on anyone who is willing to maintain the package, shut up and say thank you for the time he spent" - is so asinine and childish I don't even know how to respond. It's definitely a culture thing.
For a long while now I don't have any direct dependency that isn't backed up by a company or is a well known framework. But I feel it's kinda pointless, case in point, the supposed backdoor reached monaco editor.
I hope that some of the bigger js players will start to "scrub" their dependencies. And if their dependencies don't do the same, try to move away from them as fast as possible. It would probably be a difficult 1-2 years until the ecosystem will be stable again , but It's crucial. I actually really like writing code with ES2017 and Typescript, and it's a shame that just when the language got reasonable enough, the ecosystem now feels like a giant problem.
Here is just a quick case I found in 2 minutes: I started looking at webpack, their dependencies all look reasonable enough, but they use eslint, and eslint uses this package: https://github.com/shinnn/is-resolvable. There is no reason why this small, not-complicated piece of logic can't sit inside eslint. And eslint is a great tool, but it's non crucial to a project. If I'm a webpack maintainer I remove eslint until they fix it. That's the kind of process we should go through.
People can keep on writing all those small packages to pump up their github repository list. I'll promise to keep on using them in non-work related projects.
I have definitely started "scrubbing" my immediate dependencies and only importing packages I really need. My own published packages veer towards zero dependencies.
So far I haven't tried to reduce derived dependencies (and it's not that easy if the package you needs doesn't follow this philosophy). But at least lock files help a bit there.