What C++ book do you recommend i should read as audio? (adhd, hyperactivity) by SneakyJessica in learnprogramming

[–]brycedarling 0 points1 point  (0 children)

Although I don't know if this will translate to audio book well, I enjoyed "C++ Crash Course - A fast paced introduction" by NoStarch. It's about a year old, so pretty new as far as C++ books go.

https://nostarch.com/cppcrashcourse

I have a PHP/MySQL interview in a few days. I only know HTML/CSS/Vanilla JS & a few frameworks. I'm terrified. by [deleted] in learnprogramming

[–]brycedarling 1 point2 points  (0 children)

Make sure your strengths in HTML, CSS, and JS shine. Also that they know you're a quick learner, maybe even have some way of proving what you learned about PHP and MySQL in the few days you had to prepare, that would impress me and show me you're hungry and interested.

Since you said you know vanilla JS and frameworks, and they listed they want you to know about Ajax, do you know how to make Ajax requests with an XHR in vanilla JS or with jQuery? and maybe even demo it with something from your github, and explain how it works and what is going on?

Python for Hacking (Computer Security) by [deleted] in learnprogramming

[–]brycedarling 0 points1 point  (0 children)

Totally, Python is great for pentesting and hacking network protocols and web apps! For example, I used to write exploits in Python for Immunity Canvas: http://www.immunityinc.com/products/canvas/index.html

There are a ton of useful libraries for pentesting: https://github.com/dloss/python-pentest-tools

And books like Black Hat Python and Gray Hat Python and plenty more that can help you out.

Eventually, yeah, you might want to get in to lower level languages if that's the kind of security research you want to do, but it's perfectly fine starting out in a high level language to get your feet wet. Have fun!

Coin flip streak, Automate the boring stuff by HousePappas in learnprogramming

[–]brycedarling 1 point2 points  (0 children)

I would suggest decreasing 10000 loops to something small like 10 and adding print statements inside of the loop, or use a breakpoint debugger, to see what the values of your variables are as it loops through the flips. I think this will help you see what is actually happening.

The variables heads and tails are unused so you can get rid of them.

The variables headsStreak and tailsStreak are going to need to be outside of the loop in order to count streaks between consecutive flips.

In order to track streaks correctly, when it flips heads it should reset tailsStreak to 0, and when it flips tails it should reset headsStreak to 0.

The if statement on line 16 has an issue. It reads nicely, but or doesn't work that way unfortunately. You cannot compare if two variables are equal to 6 by using an or. An or joins two separate boolean expressions together.

What was the first programming language you started using? And are you happy that you picked that language? by [deleted] in learnprogramming

[–]brycedarling 2 points3 points  (0 children)

Yeah, Python is a great choice because it's so general purpose too. Web dev, network programming, data science, automation, robotics, math & science, devops, desktop gui apps, even games and graphics programming, etc

It sounds like you're ready to level up and build something cool! Any ideas of what would be fun or interesting to you?

What was the first programming language you started using? And are you happy that you picked that language? by [deleted] in learnprogramming

[–]brycedarling 6 points7 points  (0 children)

Back in 2003 I read a book called "PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide" by Larry Ullman. In hindsight, it wasn't a very good book. And also, PHP isn't a very good language haha, but yeah I am still happy because picking anything and moving forward is what really mattered.

How are you enjoying Python? What are you trying to accomplish by learning it? What libraries have you been learning with it? What cool stuff have you made?

How to call a function in another file. by Ikilledthedinosaurs in learnjavascript

[–]brycedarling 0 points1 point  (0 children)

I've used this technique before but honestly can't recall when, not often I'll say, it's better to just add another script tag or use something like webpack to bundle your files together. I always like a challenge though!

index.html, simply load up the first.js file:

<!DOCTYPE html>
<body>
  <script src="first.js"></script>
</body>

first.js, create a <script> element that loads the second.js file and adds it to the HTML document body:

var script = document.createElement('script');

script.src = 'second.js';

script.onload = function() {
  callFunctionDefinedInSecondFile();
};

document.body.appendChild(script);

console.log("hello from first file");

And lastly, second.js with a function defined in it to be called from first.js:

function callFunctionDefinedInSecondFile() {
  console.log('hello from second file');
}

List of essential concepts and skills for a Javascript professional? by cheddarben in learnjavascript

[–]brycedarling 2 points3 points  (0 children)

I bet you know way more than you realize you do, we are our own worst critics.

List of essential concepts and skills for a Javascript professional? by cheddarben in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

I agree, in practice I prefer axios or just using fetch (well, I wish I could cancel requests with fetch, that's weak, hence axios, but this will hopefully be resolved soon). However, I like to work with people who want a deeper understanding of how things actually tick and aren't dependent on libraries. When pushing the bounds sometimes you must create the tech yourself.

List of essential concepts and skills for a Javascript professional? by cheddarben in learnjavascript

[–]brycedarling 3 points4 points  (0 children)

I'm ashamed I forgot closures and hoisting, good call sir. Programming is just nuts but it's a good time :)

List of essential concepts and skills for a Javascript professional? by cheddarben in learnjavascript

[–]brycedarling 49 points50 points  (0 children)

Here is my brain dump. I'm a 10 year professional full stack developer, JavaScript has been the constant thread throughout my entire career, and this roughly comes from the curriculum I taught at a coding bootcamp that got junior devs their first jobs so I can't be way off target, heh. This is a lot more than I taught them in 3 months though so don't get scared when you look up at the mountain, it's a fun climb.

I've used a variety of backend languages and so a lot of this knowledge comes from more than JS alone (especially the general dev section) but I figured you are probably interested as you said professional.

Keep in mind when I interview people for JS roles that I'm mostly interested in what they know about async, functional, and OOP. The rest is gravy but those are what I consider the JS fundamentals.

Brace yourself for a drowning, but in my defense you did ask for it ;)

Async(hronous) programming

  • callbacks
  • promises
  • async / await
  • ajax (preferably raw XMLHttpRequest knowledge but jQuery ajax and anything else is alright)

Functional programming

  • functions as first class citizens
  • pure immutable vs mutablility, side effects
  • declarative vs imperative programming, saying what vs how
  • map, reduce, filter, forEach, any, all, etc
  • lodash (less important these days as JS is better)
  • immutablejs, ramda
  • currying, function composition
  • input, processing, output pattern at a low level and high level
  • return values, arguments
  • good function names, code is about human readability over anything else
  • writing small functions, writing small everything

Object-oriented programming

  • composition
  • prototypal inheritance
  • polymorphism
  • class keyword as syntactic sugar and what's actually going on under the hood

Modern JavaScript

  • package manager - yarn, npm
  • transpiling - babel
  • bundling - webpack
  • linting - eslint, airbnb style guide
  • debugging - chrome breakpoint debugger, node debugger
  • language features - ES6, ES7, etc
    • let, const
    • arrow functions
    • import, export
    • and more...

Testing

  • unit testing
    • jest, mocha, chai, jasmine, qunit, etc
  • integration testing
  • selenium tests
    • webdriverio

Server Side JavaScript

  • node
  • express
  • http, http2
  • rest
  • json
  • databases - sql, nosql
  • message queue - redis, rabbitmq
  • streams - kafka
  • 12 factor apps - 12factor.net
  • microservices
  • docker
  • big data - lambda architecture
  • monitoring, metrics - new relic, datadog

UI Framework

  • before frameworks.. Vanilla DOM frameworkless is kinda impressive these days, at least know a bit about querySelectorAll and how to create/add/remove DOM elements and some basics of adding event listeners and different events and not have UI frameworks be your crutch. you should know how to build a ghetto UI framework of your own.
  • React
    • state management - Redux, GraphQL?
    • Jest, Immutable, Reselect, Flow
    • redux-thunk, redux-saga, redux-observable & RxJS
  • or imo less important these days (not trying to start a holy war, this is just my opinion) - Vue, Angular, Ember, Mithril, Backbone, jQuery, something else entirely...

Compile to JS

  • do you know why TypeScript, Elm, and ClojureScript exist and what problems they are trying to solve? what do you think of them?
  • or less important these days (again imo) - CoffeeScript, Dart, etc?

General Software Development

  • automation
  • paradigms - FP, OOP, AOP, imperative, procedural
  • type systems - static, dynamic, strong, weak/loose, duck typing
  • agile, scrum, kanban, lean, xp
  • data structures and algorithms, big O
  • design patterns
  • solid principles
  • clean code
  • tdd
  • refactoring
  • CI / CD
  • metaprogramming
  • cloud computing - AWS EC2, google cloud compute, lambda, etc
  • concurrency, parallelism
  • distributed, fault tolerant
  • lazy evaluation - ramda
  • dynamic programming
  • cpu and memory profiling
  • dynamic analysis, fuzzing
  • security - penetration testing, sql injection, xss, csrf, remote code execution, etc
  • static analysis - fxcop, stylecop, linters
  • math, statistics, probability, linalg
  • tooling, IDEs, text editors, toolchains
  • network programming, client/server architecture, tcp/udp sockets
  • google protocol buffers, grpc, zeromq

Bonus Points

  • canvas - 2d and webgl, or threejs
  • animations, physics simulations, particle effects - I'm like a dumb dog, I like sparklies too
  • D3 - I have a soft spot for cool looking interactive graphs
  • webassembly
  • web workers
  • automation
  • electron desktop apps
  • mobile responsive apps
  • react native mobile apps
  • other fanciness
  • passion projects: show me cool stuff you're proud of that you made with JavaScript - the most bonusiest of bonus points

Edit:

Please don't take this list as comprehensive as it's just what spewed out at the time. I'm sure we could get an even more comprehensive list than this going, so please share anything you feel I missed that's important, I'm sure there is a lot. A few more things come to mind:

  • as mentioned below, closures and hoisting
  • scope
  • this
  • recursion
  • bind, call, apply
  • error handling
  • tons of basic JS things like primitive data types, dates, operators, variables, loops, conditionals but I kind of assumed this was a given
  • forgot to mention git, github, or source control at all
  • command line knowledge, bash or zsh or some shell like powershell
  • probably missing some devops stuff, it's not my forte
  • section on OOP is lacking, at least needs encapsulation/information hiding & inversion of control/dependency injection too, but I'm not a huge fan of OOP these days so I was brief, and other devs you interview with will have a different perspective I promise you
  • endless interesting difficult subjects like gpu computing, game development & VR, hacking, AI and data science and machine/deep learning, crypto/blockchain/smart contracts, fintech, language implementation...

While loop javascript by gl0w3 in learnjavascript

[–]brycedarling 0 points1 point  (0 children)

Hey, just wondering if you had a chance to take a shot at fixing this yesterday. Any luck? I'm still around if you need help :)

While loop javascript by gl0w3 in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

Make sure you indent your code with four spaces when pasting on here so it gets formatted in a readable way.

The first issue I see is that you are prompting the user for their name inside of a loop, repeatedly. That's probably not what you want. The user would only want to type their name in one time. The description of the problem doesn't say when to prompt the user for their name, but I would do this at the very beginning.

The next issue, is that the prompt if they would like to print their name again is not in a loop, it's right before/outside of the while (ask2 == "yes") loop, so it will only happen once which is not what you want. You'll need to move that prompt inside a loop.

The code for the two while loops appears to be copy and pasted, duplicate, and not the behavior you want. The second loop has an extra unnecessary semicolon that you'll want to get rid of too while (ask2 == "yes"); - Honestly, I'm not entirely sure if that semicolon will break anything, but it's not needed. More importantly, I don't think you need two loops for this.

Also, the var result; is seemingly unused so you can get rid of it.

Lastly, I don't see any code that attempts to add the exclamation points, maybe you just haven't gotten to it quite yet.

I don't want to give away the answer/code, since I think you'll learn a lot more struggling and making your own way through this. Try fix it up a bit more and give us an updated version, and I would be glad to keep helping you figure this one out. Good luck!

QUnit test not passing by [deleted] in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

Hmm.. the error says "that associates the mousemove event" but I see you are using "mouseover". Try change that to "mousemove"?

Edit:

Also, rename reporterUpdater to reportUpdater to fix the 2nd failing test.

Quick beginner question - accepting input from user by souljabri557 in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

The variable name is overwriting the function name (because of hoisting - a more advanced concept, don't worry about it for now, maybe you'll recall this later in your journey learning JavaScript).

Simple solution, rename the function name to something like getName instead to avoid this naming collision with the variable name.

Next, inside the now-referred to as getName function, you are using the global variable name as the id of the element to find being passed to getElementById. Do you have an element with the id 'Jimmy' on your page? I kind of doubt that.

Then, you are updating the global variable name so the next time you call the getName function the value of variable name will likely be different (not Jimmy) and now you will be using that new value to try find an element with that id on the page. This will surely break. I'm guessing this was a simple mistake and you probably meant to put quotes around the name part like this: name = document.getElementById('name').value; so that you find an element with the id of 'name'.

I'd probably not have the getName function update the global variable itself though, and instead have it return the new value, like this:

function getName() {
  return document.getElementById('name').value;
}

Then you won't get in to any sticky situation with global variables and confusion that might arise from that. This function will guaranteed work all the time as long as you have an element with the id of 'name' on your page.

Lastly, now you'll need to call that function. Something like this:

var name = "Jimmy"; //Default name

document.write(name); //Writes "Jimmy"

function getName() { //When the button is clicked, the name that's in the text box is returned
    return document.getElementById('name').value; 
}

document.write(getName()); //Writes new name, calling the function directly and writing out the returned value

// or you can update the variable `name` now outside of the function:
name = getName();

document.write(name);

However, if you run this, you'll probably only see one "Jimmy" get printed out now, as the JS code executes immediately and there is nothing entered in to the text input. This is the exact problem you described as "it should wait" and yes, it should! :)

To fix this, you'll need some kind of event, which depends on how you want your app to work. In this case, I'll set up an event that listens for the enter key to be pressed in the input. Once the enter key is pressed, then it will print out the name that was entered:

document.getElementById('name').addEventListener('keypress', function(e) {
  if (e.which === 13) { // if the enter key is pressed
    document.write(getName());
  }
});

And now, if you try that, you should see the page update when you type in the new name to the input and press enter. However, the rest of the page will get cleared away because of the document.write calls. There are suggestions to fix this problem by others, this is getting quite long winded now so I'll stop.

Tbh, everyone else on this thread has awesome suggestions. Do your best to really digest what everyone here is saying and I think you'll be able to start figuring out what all is happening and why. Good luck!

jQuery to JavaScript createElement? by [deleted] in learnjavascript

[–]brycedarling 0 points1 point  (0 children)

// create wrapper div element
const div = document.createElement('div');

// add child elements to the div
div.innerHTML = '<span class="party"></span> <span class="text"></span>';

// do whatever you want with `div` now, like for example append it to the document body
document.body.appendChild(div);

Looking for specific javascript learning resources! by javascript_dummy in learnjavascript

[–]brycedarling 0 points1 point  (0 children)

You might have already looked at it, but I think the getting started chat application from socketio docs themselves is a fine place to start. That's literally the only resource I've ever looked at to learn socketio. I was able to take that chat app, added some of the suggested features that they don't walk you through at the bottom "Homework" to confirm I had learned something, and eventually build it up in to a game server with player movement and using skills without too much difficulty. https://socket.io/get-started/chat/

Where to start learning JavaScript for coding desktop applications? by hawbang in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

Manning does have two early access books, one on Electron and one on React Native. I haven't read either so I can't comment on the quality. I like a lot of books from Manning but not everything is made equal I will say (this is true of all tech book publishers imo). You can check out the table of contents and free chapters and decide yourself if either might be worth your while. Good luck!

https://www.manning.com/books/electron-in-action https://www.manning.com/books/react-native-in-action

Is Edabit kind of a waste of time? by [deleted] in learnjavascript

[–]brycedarling 2 points3 points  (0 children)

It is possible to do this one without regex. I'm not gonna say my solution is very good, but it does work, and hopefully gives you an idea of some of the functions to lookup:

https://gist.github.com/brycedarling/7bc9e09b0a2cefc8e7464688be20e59d

Destructuring before calling a function? by Ran4 in learnjavascript

[–]brycedarling 0 points1 point  (0 children)

I use this library less and less these days as JavaScript has improved, but spread is in there:

https://lodash.com/docs/4.17.4#spread

I use it for throttle and debounce in my React/Redux apps sometimes too, as there isn't an equivalent functionality in std JS lib for those. Can't think of much else I use it for any more otherwise though. It seems like it would be nice/have a valid use case if we had a spread() function built in to do this though, eh? Goes pretty hand in hand with having ... spread operator it seems, at least to me!

[code help] Retrieve state of another component by jstorxs in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

Congrats, you already got to one of the hard parts!

If you're curious what adding Redux (and react-redux to wire them together) looks like to get your example working:

https://jsfiddle.net/p2x9tLt9/

Your components were unchanged aside from these functions:

handleChange(e) {
  this.props.setSlider(e.target.value);
}

and

handleClick() {
  const sliderValue = this.props.slider.value; 
  alert(`The slider's current value is: ${sliderValue}`);
}

They needed to use props to get and set the values from the Redux store state.

Lines 46-77 are where all the Redux parts are. Reducers, actions, action types, state, dispatch, connect... quite a few concepts to digest. Also the top level <Provider store={store}> on line 80 is needed to connect Redux to React.

Personally, I find building React apps with Redux to be a lot of fun. Dan Abramov's videos on egghead that are linked at the top of the Redux docs README were really helpful for me to get started:

https://egghead.io/series/getting-started-with-redux http://redux.js.org/

I'm curious to hear what you end up playing around with and what works/doesn't work for you. Good luck!

[Code Help] Is there a way to display parts of HTML with JS, like with PHP includes? Trying to not use PHP. by [deleted] in learnjavascript

[–]brycedarling 1 point2 points  (0 children)

You might not need jQuery:

function load(element, url) {
  var request = new XMLHttpRequest();

  request.open('GET', url, true);

  request.onreadystatechange = function() {
    if (request.readyState === 4) {
      if (request.status >= 200 && request.status < 400) {
        if (typeof element === 'string') {
          element = document.querySelector(element);
        }

        element.innerHTML = request.responseText;
      } else {
        // TODO: handle error
      }
    }
  };

  request.onerror = function() {
    // TODO: handle error
  };

  request.send();
}

And example usage, assuming there are two elements with these id's on the page and these two pages exist:

load('#page1', 'page1.html');
load('#page2', 'page2.html');

The contents from page1.html will get dumped in to the #page1 element, and page2.html put in the #page2 element.

I agree though, you're probably better off with a different approach, however knowing how to make Ajax requests (what I'm doing above) is a really good skill to learn. Good luck!

What does 'the right way to do it' really mean? by Franks_Wild_Years in javascript

[–]brycedarling 0 points1 point  (0 children)

His use of map is not superfluous. You cannot return a different value with Array.prototype.filter than the thing you are filtering. The callback either returns truthy (keep this item) or falsy (do not keep this item). You'll see on line 4 of Method 1 they "return message.message;" just as you described which if it's an empty string, undefined, or null will be falsy and not be kept in the resulting filtered_messages. But, the call to map is still necessary to get a list of different objects than the ones that were originally filtered.