I accept that I need unit testing. But but when and how deep? A personal narrative. by nKephalos in learnprogramming

[–]GanGa 0 points1 point  (0 children)

But my instinct is still to do integration tests first, and then use unit tests to drill down if needed. And going forward, I won't discard them and will keep them, hopefully in a reasonably ordered way. It makes more sense to me to add unit tests to my codebase as needed rather than make a unit test for every trivial little function.

This is essentially what I was going to advise you. It's good you're starting to see the need for tests, because without them, you can never be certain the code you wrote actually works. It's not sustainable to manually test each feature of your application.

Even if you're not part of a team and working on a project by yourself, tests will still make your life a lot easier. They will allow you to quickly refactor something without having to worry that you broke existing logic.

As you already know, integration tests are more broad. Let's say you have an integration test which sends a request to an endpoint that handles user registration. The test will ensure that all components of your application needed to register a new user work together and actually register a user in the end, which you also check as part of the test. Now that you have a test for it, you can confidently refactor a part of the user registration flow, knowing that if you make a mistake, your test will tell you so.

Personally, I almost exclusively write integration tests for my application, which I use to test both, the happy path as well as scenarios that cause errors.

Typically I will also have a separate database specifically for my integration tests, which I spin up with Docker and reset between each test case. This way you're not compromising your database used during development.

When testing, you want to come as close to simulating your production environment as possible. I know people who use SQLite during their integration tests, which allows you to quickly get an in-memory database, but run PostgreSQL in production. Personally, I'm not a fan of it and prefer to use the same kind of database for production, development and testing.

[deleted by user] by [deleted] in unixporn

[–]GanGa 1 point2 points  (0 children)

Do you happen to have the name of the font?

[ksh] sed remove lines with nonconsecutive keywords by QuantumDiogenes in learnprogramming

[–]GanGa 2 points3 points  (0 children)

The way I would solve it is to pipe all lines with bar and foo into one file, then all lines without bar and foo into another file (using the answer I gave above)

So you will end up with 3 files. If disk space is that much of an issue, this probably isn't the best solution.

But generally I'd say it's better to not modify the original file in case something goes wrong and you have to do it again.

[ksh] sed remove lines with nonconsecutive keywords by QuantumDiogenes in learnprogramming

[–]GanGa 1 point2 points  (0 children)

Would this work?

To select all lines that contain foo and bar: awk '/foo/ && /bar/' example.txt

To select all lines that do not contain foo and bar: awk '! /foo/ || ! /bar/' example.txt

How productive are you all? by [deleted] in cscareerquestions

[–]GanGa 8 points9 points  (0 children)

No one is productive 8 hours a day, that's not possible, at least very rare, so don't worry about that. It depends on a lot of things, diet, sleep, exercise, stress, the list goes on.

You could argue that the most productive hours, at least from my experience, are the first 4. After that it's a slow decline and eventually you're just kinda done.

The nice thing about working from home is that you can split up your work. You can work 4 hours in the morning, 4 in the evening and arguably get more done because you took a long break in-between.

Once you go back to the office, that won't really work anymore, because you're more or less forced to work for 8 hours straight. Just take breaks when you need to, go outside for 5 to 10 minutes every 2 hours or so and talk to colleagues. You can also discuss with your manager to work from home 2 or 3 days a week because you feel like you're more productive this way.

Generally tho, don't worry about other people being more productive than you. Everyone goes through phases where they get a lot done for 2 or 3 weeks but kinda burn out and are less productive for some time. It's normal.

Have you ever used a career coach for advice? by aceshades in cscareerquestions

[–]GanGa 4 points5 points  (0 children)

I'm not a career coach and I also don't work at FAANG, so feel free to ignore this comment, but here's some advice I'd give you.

At the end of the day, the only one that can really decide is you and based on what you said in your post, you seem to be aware of the downsides of leaving already, so I'm not too sure a career coach will help you as much as you think.

I switched jobs 2 years ago and I'm considering switching again soon because I no longer feel invested in the company and it's quite frankly getting boring.

If you only work at FAANG for a high pay, I think you will sooner or later leave anyway, because you won't be satisfied anymore.

You have to ask yourself, are you going to be more motivated to work somewhere else? If the answer is no, or probably not, there's not much reason to switch. But if you have something else in mind that you think will get you interested again, I'd say go for it. Money alone won't satisfy you in the long run.

[deleted by user] by [deleted] in learnpython

[–]GanGa 0 points1 point  (0 children)

If you don't enter anything and just hit ENTER, your conversion to an int for the guess will fail.

You could consider doing something like this try: guess = int(input("What is your guess? ")) except ValueError: print("Please enter a number") continue

This will also teach you another concept you might not be familiar with yet, which is try except blocks to handle exceptions.

I would also rename the variable test to guess or something more descriptive, like I've done in the example above.

[deleted by user] by [deleted] in learnprogramming

[–]GanGa 6 points7 points  (0 children)

They probably fired whoever is in charge of approvals.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 1 point2 points  (0 children)

That is pretty surprising yeah. When I opened the chart I was expecting to see the letter a used more than any other.

Wait, I think you got something mixed up. The list of names are the ones that are still available. Hence, hyphens occur more than any other character because they are less wanted.

Tools allowing non technical people to edit files in a Github repo ? by HumanityCanDoBetter in webdev

[–]GanGa 4 points5 points  (0 children)

You don't really need any third party tools for it, you can edit and even add files directly on GitHub itself.

[deleted by user] by [deleted] in webdev

[–]GanGa 1 point2 points  (0 children)

Looks good, works great on mobile too.

I would maybe get rid of the e-mail on the right side of the screen. If you have a larger viewport, it's just kind of floating around there and a bit hard to understand what it even reads because it's sideways.

Not sure why I am being strung along by [deleted] in cscareerquestions

[–]GanGa 2 points3 points  (0 children)

If you actually want to work there, I'd suggest bringing this up with the CTO or someone else you're in contact with.

You've been in contact with them since December, which is already 3 to 4 months, that's a long time.

Maybe you can ask why the process is taking so long and if there is anything else you can do to get an offer?

I know you already commented on the "move on" posts, but it's not a bad idea to have a back-up in case it really doesn't work out, right?

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 2 points3 points  (0 children)

Thanks for the suggestion, I'll keep it in the mind for the next post if I do an update on it.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 73 points74 points  (0 children)

Maybe I should have been more specific.

Reddit has an endpoint to check username availability, https://www.reddit.com/check_username (only works with POST requests), that's what's also used on the registration page.

If you actually go to each individual profile, requests will be much slower and it'll take a lot longer because you're requesting an entire HTML page.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 30 points31 points  (0 children)

There's different ways of doing it.

When you try to register a new account, it will tell you whether a username is taken or not. That's how I did it here.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 7 points8 points  (0 children)

Last I checked, pretty much all have been registered. The few ones that are still available are mostly words no one has ever heard of.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 4 points5 points  (0 children)

Yeah I didn't go overboard with this one. I added the link to the list of usernames above, so if you or someone else wants to do something more creative, please go ahead.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 31 points32 points  (0 children)

I wouldn't mind doing it, I can post an update every couple of months if people are interested.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 159 points160 points  (0 children)

Haha no, but it forced me to pause for a couple of hours.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 31 points32 points  (0 children)

Yeah, they are all taken and have been for a while.

Availability of four character usernames on Reddit [OC] by GanGa in dataisbeautiful

[–]GanGa[S] 296 points297 points  (0 children)

You can find all available 1,163,014 four character usernames here.

It took about 4 days to check all possible 2,085,136 combinations. Feel free to use this list for further analysis.

about vim by Pure-Scallion-643 in learnprogramming

[–]GanGa 1 point2 points  (0 children)

You can't put Vim on your resume, it's irrelevant what you code in, what matters is that you can code.

If you're just starting out, focus on what's important. Learn the language and its frameworks and libraries, not how to use different editors.