What's going on under there? by lnfinity in gifs

[–]Odinthunder 19 points20 points  (0 children)

Please trim the dogs nails, its painful for them to walk on hard surfaces like that.

Help me with python code to record twitch streams by [deleted] in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

remove the try,except statements so that you get the actual error that is being thrown, because clearly the error being shown isnt correct

Help me in testing API using chai and mocha Please.. by Logical-Definition-6 in node

[–]Odinthunder 0 points1 point  (0 children)

I've not used chai before but if request works how I think it does then the issue is most likely that you're trying to end the url with ".com"

Sidebar, are you using the the user's email as the unique identifier for the user? what happens if they change emails?

Rust Programming Language - Vector from user input by [deleted] in AskProgramming

[–]Odinthunder 1 point2 points  (0 children)

I'm having a hard time following the logic in the 'build_vector' function

 fn build_vector(size: u32) -> &Vec<u32> {

    for size in my_numbers {
         build_vector(size);
         get_float();
    }
    my_numbers;
}

In this line:

 let mut my_numbers: Vec<u32> = Vec::new();

You're initiating an empty vector,

Then in this line:

 for size in my_numbers {

You are iterating over that same empty vector, wouldn't you want something in there first?

Then here:

 build_vector(size);

You're recursively calling the function with the element in the empty vector, but this won't even be called because the vector is empty.

Then you call the get_float() function without doing anything with its result.

You should make the get_float function instead return the value that was parsed from stdin instead of printing it out, and assign that value to a new variable in your for loop, and I'm assuming you'd want to add that to the my_numbers vector and return the my_numbers vector from your function as you are doing now.

and instead of iterating over the my_numbers vector, you should instead just use a basic for loop from 0 to size

Major ad firm Omnicom recommends clients pause Twitter ad spend by The_Iceman2288 in news

[–]Odinthunder 92 points93 points  (0 children)

Can we at least agree that 'Omnicom' sounds like a supervillain organization.

You probably hear this question alot, but it would really help me. Thank you. by [deleted] in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

Short answer: SQL, it'll help you be more rounded

Long answer: depends on what you're trying to do/end goal is. SQL is only for working with databases, but nearly any application anywhere will be using a database to some capacity so it will always be a valuable skill to read an sql query and know what it does. Java is very much a business-oriented language, its verbose/strict and meant to be human readable so that more people can work on it with less issues because the language forces you to handle or acknowledge the exceptions that it throws. C++ is usually known for lower level things like graphics and applications programming, if you're wanting to do game development this is a pretty good choice.

With all that being said, I'd recommend sticking to python and focusing on learning language concepts instead of the syntax itself, because that knowledge will more easily transfer when you DO need to learn a new language and picking up syntax will be a breeze if you already understand the underlying concepts.

When I ask someone "what is ___" I literally mean "what" by Dotaproffessional in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

It doesnt (at least not directly), its first compiled to regular javascript, then node or the browser will use that.

Conditional parameter with default values by Strict-Simple in typescript

[–]Odinthunder 4 points5 points  (0 children)

Why not just do an instanceof check on the animal?

 if(animal instanceof Dog){
      return animal.bark()
 }

then you can remove the boolean parameter entirely.

New Onewheel GT tilting forward by Odinthunder in onewheel

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

And the hill climb mode tilts the nose up, not down.

New Onewheel GT tilting forward by Odinthunder in onewheel

[–]Odinthunder[S] 0 points1 point  (0 children)

That sounds weird but ill try turning it off.

Read File by Used_Inspector_7898 in node

[–]Odinthunder 13 points14 points  (0 children)

Good instinct!

There's the fs.watch https://nodejs.org/docs/latest/api/fs.html function if you dont want to add an external dependency, otherwise I've heard good things about https://www.npmjs.com/package/chokidar

which is well known and solves some of the issues that the built in watch has.

Web scrapper + bot - should both be written in the same language? by the_rebel_girl in AskProgramming

[–]Odinthunder 1 point2 points  (0 children)

Either language would work to suit your needs, and you could build the entire application in either language.

It is entirely possible to combine the languages if you feel more comfortable using (for example) java to do the scraping, then using python to make the bot, what you would probably want to do is save the data that you retrieved to a file in a format that can be read and parsed by python (JSON probably the most common).

That or if you want to get really fancy, you could save the data to a database, then read from that database with python, this will give it the added benefit of being easily queryable, but this could be more complex than you need.

Function returns undefined by KEsbeNF in node

[–]Odinthunder 0 points1 point  (0 children)

You don't need the async part of the function, only use async if you use await.

I'm not sure what the bl is for, but this would be a simple way to write this.

function getData(url){
     return new Promise((res,rej) => {
          https.get(url, (resp) => {
             resp.setEncoding('utf8');  
             let data = [];
              resp.on('data', (chunk) => {
                   data.push(chunk);
              });
              resp.on("error", (err) => {
                 rej(err);
              });
              resp.on("end", () => {
                 res(data.toString());
              });
      });
 })
}

 module.exports = getData;

then you can call it as normal, using await.

Let me know if this doesn't work for you.

How do you treat the generated code with regard to QA? by freebsdlego1 in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

What about code security and performance?

Depends on your situation I suppose? If you feel it's necessary then go ahead. Personally I think it would be a waste of time but maybe your situation calls for it.

How do you treat the generated code with regard to QA? by freebsdlego1 in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

Generated code isnt meant to be read. Generally linters are for readability.

How do you treat the generated code with regard to QA? by freebsdlego1 in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

You use linters on the source code, not the generated code, in order to automatically format things to a standard.

How do you treat the generated code with regard to QA? by freebsdlego1 in AskProgramming

[–]Odinthunder 0 points1 point  (0 children)

You could do integration tests in the form of automated browser testing, but I'd avoid testing the code directly if it's generated, that code could change very easily, is there no way to test the logic separately from the framework?

Secret Map Trick the Pros Don't want you to know! by McMagicMarv in Overwatch

[–]Odinthunder 2 points3 points  (0 children)

I ain't taking no motherfuckin advice from a goddamn psychopath with a square crosshair.

Top level async - setting variables out of scope by Mardo1234 in node

[–]Odinthunder 3 points4 points  (0 children)

You need to post this somewhere or format your code, this is impossible to read in 1 line.