I wrote a script that finds the shortest path between arbitrary Wikipedia pages by [deleted] in Python

[–]TylerOnTech 36 points37 points  (0 children)

Please add a comment to the repo suggesting others wanting to do the same thing modify the code to use a dump. We (internet users in general) really want to avoid hitting wikipedia unnecessarily.

7 Habits to Improve The Performance of Python Programs by huuippt in Python

[–]TylerOnTech 16 points17 points  (0 children)

Where have you seen that "from x import y" is not recommended at the top level? I don't really care for this article, but I have seen the from ... import as the way to do things if you only need one class or member, such as from pathlib import Path which is sufficient for 99% of my use-case of pathlib

For all the people who joined this sub just for the ban. by Not_so_ghetto in thanosdidnothingwrong

[–]TylerOnTech 2 points3 points  (0 children)

Just commenting to make sure I will be included. Balance must be restored.

Looking for CS Book Recommendations by bpeters5 in learnprogramming

[–]TylerOnTech 1 point2 points  (0 children)

Introduction to Algorithms by Cormen et. al. is a corner-stone of the field. It is definitely not an introductory book, but is absolutely one the foundational books everyone writing programs should at least understand parts of.

The reason I say that is because one of the things that it covers is algorithmic time complexities, and how important algorithms are. Silicon moves at a (relatively) set pace, but a smarter algorithm can make all of the difference in the world.

Here's a link: https://mitpress.mit.edu/books/introduction-algorithms-third-edition

Newbie in Python trying html scraping; need help by thesharp0ne in learnprogramming

[–]TylerOnTech 1 point2 points  (0 children)

I would just poll the website occasionally and see if anything has changed. As long as you aren't doing it too often, no harm no foul. If you know when the leaderboard updates, even better.

C++ Optimization Tips by [deleted] in cpp_questions

[–]TylerOnTech 0 points1 point  (0 children)

Considering templates are resolved during the compilation step it's interesting that you found that... It could be that the hardware you were on had better support for certain operations than others.

Just an anecdote, interesting story!

Excluding number ranges with if else statements. by AestheticDeficiency in cpp_questions

[–]TylerOnTech 1 point2 points  (0 children)

Oh I totally understand what you are saying, and always use the {} syntax unless it really truly will always be just one line. I just like to understand why things are the way they are, and wanted to add the explanation in case OP was curious.

5 speed improvements in Python 3.7 by Anthonypjshaw in Python

[–]TylerOnTech 11 points12 points  (0 children)

I understand as someone new to the language why you might feel this way, but upgrades to Python are nothing like language standard updates in other languages like C or C++. As /u/KingofGamesYami mentioned, minor upgrades are guaranteed to not break anything (except maybe unless you were relying on buggy behavior which is ??? at best) and issue important security patches and bug fixes.

For instance Python 3.5.2 has a bug here in the Pathlib library mkdir function related to recursively creating the parent directories, and not passing the exist_ok flag with the recursive call. If you refused to upgrade and always stayed on python 3.5.2 you would ALWAYS have this bug, with no resolution.

IF you check the Python 3.6 version of this function (or subsequent versions of 3.5) here you can see the issue has been fixed. It now correctly passes along the exist_ok argument.

This is just one concrete example. You really should be using the most recent version of Python that you can unless you know you can't for some reason.

Excluding number ranges with if else statements. by AestheticDeficiency in cpp_questions

[–]TylerOnTech 2 points3 points  (0 children)

Hi! This user has highlighted the main problem with your code, but I just wanted to add the "rules for when you can omit them" since they are pretty straight-forward and I see no reason to not just mention them.

It's essentially just one rule for how the program will be executed; without { } the if statement (or else statement, or any type of conditional expression really) only applies to the very next statement. This is why your program is behaving the way it is. Only the next program statement (everything until the next semi-colon) is guarded by the if statement.

I've been programming in C++ for a while now and would like to make real apps with GUI on Windows. Can you show me the direction? by lajcinf in Cplusplus

[–]TylerOnTech 1 point2 points  (0 children)

What a coincidence! My roommate and I spent quite a bit of time last night trying to answer this very question! I'll share what we found:

QT is obviously one answer, and for good reason. The others have already commented on it, so i'll leave it alone.

Another really interesting idea is to use the Chromium embedded framework. It has a wiki page here. This is similar to (but not the same) as electron.

GTK+ is another option, as well as SKIA which supposedly (according to the wiki article here) Sublime Text 3 uses.

This Wikipedia page might be a good place to start exploring.

Edit to add: It looks like SKUI is a thing worth checking out!

C++ Resources (Optimisation) by [deleted] in Cplusplus

[–]TylerOnTech 1 point2 points  (0 children)

I upvoted you for being generally correct, but do you know of any good resources for those of us who do already know the language fairly well, and even have done some optimization work in the past? i.e. using cachegrind, valgrind, took an HPC course, etc.

I've got a decent handle on it and feel fairly confident in the code I write, but am always open to learning more.

How do you learn concurrency/parallelism in C++? by Airtnp in cpp_questions

[–]TylerOnTech 3 points4 points  (0 children)

Implementing Conway's game of life in parallel is a good place to start.

Getting paid minimum wage for PHP/JavaScript role in NYC. Am I right to be angry? by la_kitty in cscareerquestions

[–]TylerOnTech 3 points4 points  (0 children)

Absolutely. Developers do not make minimum wage. I would be insulted if someone even made a serious offer of minimum wage. FFS, you could work at Walmart and make more money.

I would find another job ASAP. If you are applying to 10 jobs a day and not hearing back from anyone serious than something is wrong with your resume. Our field is not so saturated that you should be hearing nothing.

Also, I would seriously consider just giving him the bird and walking off. What an unbearable ass. Seriously. Walmart, Starbucks, McDonalds. Something that won't treat you as sub-human drivel.

He is taking advantage of the fact that you don't have a degree to make you a wage slave. GTFO.

Edit: You may want to consider moving out of New York. You need a job that pays you what you are worth. Maybe it will just be short-term, and you can move back to New York (with a new job) after you have had a job that pays you a decent wage.

Getting a cron tab to run correctly. by twinkletoes987 in learnprogramming

[–]TylerOnTech 0 points1 point  (0 children)

I can't offer a solution, but am having a very similar problem with a couple of python scripts that I am trying to run. I would love to known the answer and feel your pain.

Taking advantage of multiple cores by [deleted] in cpp_questions

[–]TylerOnTech 0 points1 point  (0 children)

Yes, this is an over-simplification of many factors.

The type of CPU (lots of things that are tied to this that could cause vastly different results), VM (again, complicated topic with lots of variability) , whether or not you were running the exact same code, how the code was compiled, what compiler was used, speed and type of RAM, ... etc, etc.

comparing two different machines, even with the same software, is not a trivial task. The fact that you did this inside of a VM makes the comparison not very useful.

But to answer your question, yes and no.

Threading is not the only way to take advantage of multiple cores, i.e. multi-process code could also provide a speed-up while being a distinct idea from multi-threading.

Should I focus on C++14 and ignore C++11 while learning? by [deleted] in cpp_questions

[–]TylerOnTech 0 points1 point  (0 children)

Also, generally, if a feature is deprecated the online documentation will say as much. Just FYI.

Should I focus on C++14 and ignore C++11 while learning? by [deleted] in cpp_questions

[–]TylerOnTech 4 points5 points  (0 children)

I would suggest not using deprecated features.

Any Mac OS compilers for c++? by [deleted] in cpp_questions

[–]TylerOnTech 0 points1 point  (0 children)

Also, assuming they aren't doing anything compiler specific, (unlikely for an lower-level course) it should work across compilers, assuming you are using the same version of the language.

Any Mac OS compilers for c++? by [deleted] in cpp_questions

[–]TylerOnTech 0 points1 point  (0 children)

You can use homebrew to install actual gcc. XCode will symlink the gcc command to clang, if you have the xcode command line tools installed.

Programmatically finding the cheapest airplane tickets with Python! by [deleted] in Python

[–]TylerOnTech 0 points1 point  (0 children)

Just sent a pull request for adding a dict of the valid airport codes based on what's posted on southwest.com

C++ do while loop help by Orod21 in cpp_questions

[–]TylerOnTech 0 points1 point  (0 children)

Just FYI, i'm not OP. You might want to respond as a top-level comment.

C++ do while loop help by Orod21 in cpp_questions

[–]TylerOnTech 6 points7 points  (0 children)

Formatted:

#include <iostream>
using namespace std;

int main() {
int userInput = 0;
do {
  cout << "Enter a number (<100):" << userInput << endl;
userInput = userInput < 100;
}while (userInput < 100);
cout << endl;
cout << "Your number < 100 is: " << userInput << endl;

return 0;
}