• Breaking News

    Wednesday, May 13, 2020

    I still don't understand what problems Dependency Injection solves Ask Programming

    I still don't understand what problems Dependency Injection solves Ask Programming


    I still don't understand what problems Dependency Injection solves

    Posted: 13 May 2020 12:36 PM PDT

    I know what DI is and how to use it, I just don't understand why to use it and what errors I will get not using it.

    I've been looking at explanations e.g. https://stackoverflow.com/questions/14301389/why-does-one-use-dependency-injection

    And the top answer used a class called Logger to justify a fault scenario i.e. he said using this statement through multiple classes is problematic

    var logger = new Logger(); 

    But why can't I have multiple of these statements in different classes throughout my code? If they exist in a different scope each what does it matter if I use DI or not to create a ILogger interface? Vs just instantiating a separate logger as a dependency for each class that needs it

    submitted by /u/raretrophysix
    [link] [comments]

    Can a program that was written in one language be decompiled into another?

    Posted: 13 May 2020 12:22 PM PDT

    Small and free "database" for a simple website

    Posted: 13 May 2020 10:35 PM PDT

    So I am trying to practice some web development after learning a little bit of React. I would love to make a birthday website for a friend. I plan on hosting it on github. I would love to have a section on the website where I can have our other friends type a little blurb and maybe upload a picture for her to be able to scroll through kind of like a bunch of instagram posts but in one place. I thought it would be easy to send out a google form to everyone to fill out their blurb and maybe the picture so that it would automatically go to a google sheet. I was wondering if it is possible to pull data from google sheets to a website? If thats not possible is there another easy to set up database that I could set up because I guess I could just manually put all the data in there before her birthday.

    submitted by /u/gingy4
    [link] [comments]

    [HELP] Don't want to bring all features on the staging branch to master

    Posted: 13 May 2020 10:21 PM PDT

    First of all, I'm sorry If I post to the wrong sub.

    So our team always pushes code to the staging branch for our management to test the website. And we used to work on a branch like this:

    Feature branches -> Develop -> Staging -> Master (production)

    The Develop, Staging, and Master are configured with CI, automated deploy to each environment server.

    And once we finish our features and reach the staging branch, some of the features we developed and committed to staging are not ready yet to bring/merge to master, only some of the features are we want to merge to master (production).

    For instance, management still testing or the test for certain features is taking longer.

    How do we solve a problem like this? I have read about git cherry-pick, but is it good for this scenario? Or do you have any suggestions? Thanks.

    submitted by /u/tonywei1992
    [link] [comments]

    Is there a way to have an LED Matrix show something as the pi is booting up?

    Posted: 13 May 2020 10:04 PM PDT

    So i made an MLB Matrix and added a on/off button to the pi. My issue now is that the matrix takes forever to begin showing the scoreboard, so I don't know if the pi is actually booting up, or off. Is it possible to have the matrix to show at least one Led on to tell the user that the pi is booting up?

    submitted by /u/JustCallMePapii
    [link] [comments]

    Am noob. Need to make small windowed and command line programs, preferably for windows.

    Posted: 13 May 2020 09:11 PM PDT

    All i know is what myy school taught me about C++ . I can make only basic command line programs. I want to make a program that interacts with local files and web. I have no idea how to make gui programs. With which language should i start?

    submitted by /u/EnArvy
    [link] [comments]

    What is standard practice for re-used code between files which are not classes?

    Posted: 13 May 2020 06:29 AM PDT

    Specifically within the context of Python.

    I have three source files, neither of which are classes or contain classes. There's a few functions shared between them: loading CSV into dataframes, doing some arithmetic based on the dataframes, and then plotting. Otherwise code is distinct between them.

    Is it appropriate to leave them as-is or put the shared code in a separate file and just include them? I've learned about polymorphism and code reuse but only within the context of classes. If two classes share some code, I should make an interface or superclass, etc. I'm not sure for non-classes, however.

    submitted by /u/setzRFD
    [link] [comments]

    Nested loops problem

    Posted: 13 May 2020 08:20 PM PDT

    Hi I am a beginner in python and want to making a web pages for python. Can someone help me please make this for loop efficient to simply n^2 and right now it is n^3. Sorry if the code looks disfigured in here, i'm not used editor in reddit

    site.route("/bookcar")

    def bookcar():

    response = requests.get("http://127.0.0.1:5000/api/car") response2 = requests.get("http://127.0.0.1:5000/api/car-manufacturer") response3 = requests.get("http://127.0.0.1:5000/api/car-colour") response4 = requests.get("http://127.0.0.1:5000/api/car-type") carData = json.loads(response.json()) manufacturerData = json.loads(response2.json()) colourData = json.loads(response3.json()) typeData = json.loads(response4.json()) 

    for car in carData:

    for manu in manufacturerData:

    if car["car_manufacturer"] == manu["id"]:

    car["car_manufacturer"] = manu["manufacturer"]

    for color in colourData:

    if car["car_colour"] == color["id"]:

    car["car_colour"] = color["colour"]

    for cartype in typeData:

    if car["car_type"] == cartype["id"]:

    car["car_type"] = cartype["type"]

    return render_template("bookcar.html", cars = carData)

    submitted by /u/idkmanlololol
    [link] [comments]

    Can anyone recommend a good software charity to enroll with?

    Posted: 13 May 2020 07:48 PM PDT

    Advice on college courses

    Posted: 13 May 2020 07:42 PM PDT

    Hey r/AskProgramming

    I need your advice on what courses to take. Currently, I'm enrolled at a community college and am going for a software dev AS. I'm required to take 4 out of 6 CIT electives along with my main courses. None of them jump out as more interesting to me than the others, so I want to take the ones that will be the most useful to me. They are:

    Programming in C;

    Web Development;

    Office productivity applications(edit, description of course for clarity: This course provides students with knowledge and skills involved with common office productivity applications. Student learn the features and functions of the Excel spreadsheet application as well as the Access database application. Students learn to effectively use and integrate data from spreadsheets with a database in the development of solutions for business-oriented problems. Critical thinking and quantitative reasoning through project-based activities is emphasized.;

    Data Structures and Programming C++;

    Mobile Application Programming Android;

    Mobile Application Programming iOS;

    It seems to me the best plan would be to take the first four and skip the mobile app ones, as I assume they would have a wider and more general use. But then again I'm still pretty new to programming, so maybe I'm missing something. I already reached out to my instructor from last semester for his advice, but he hasn't got back to me yet. So, here I am! Any of these jump out as being important or necessary? Should I stick with my plan? Or should I not worry about and just take whatever? Any and all advice would be very much appreciated!

    submitted by /u/Steel_Moon
    [link] [comments]

    Unit Testing Coverage

    Posted: 13 May 2020 06:17 PM PDT

    Question about Unit Testing Coverage

    Let me say that I have a Class A and Class B, and they have a good unit test coverage.

    And I have a Class C that uses Class A and Class B as Constructor params, should I Write a test for the creating of the Class C? as I already covered the creation of A and B?

    The use will be like:

    new C(new A(....), new B(....)); 

    More like this:

    Class A{ // bla bla bla } Class B{ // bla bla bla } Class C{ private A attr; private B attr_2; public C(A x, B y){ this.attr = x; this.attr_2 = y; } } 

    Thanks in advance for the help :D

    submitted by /u/cassiofachinelli
    [link] [comments]

    What could theoretically be possible if we had one more boolean aside from True and False?

    Posted: 13 May 2020 05:53 PM PDT

    By this i mean, having transistors and logic gates figured out for 3 values.

    For example 310 is much larger than 210. Would this contribute anyhow to the development of computers?

    ***i know this isnt a programming related question but i figured there could be someone who would find this interesting on this sub. Thanks

    submitted by /u/kleineaxolotl
    [link] [comments]

    Should I stick to 1 coding project/language, or stick to multiple projects/languages.

    Posted: 13 May 2020 05:32 PM PDT

    Should I do multiple projects at a time (work an equal amount on each one), or stick to 1 project, and once I am done that project, move to another? Let me know what you think.

    submitted by /u/8blackears
    [link] [comments]

    How to use Meson with D and generated source files OR manually specify order/dependencies in Meson

    Posted: 13 May 2020 05:11 PM PDT

    As an example of the problem I'm having...

    hello.d ~ a generated source that only contains an immutable string

    main.d ~ main source, depends on hello.d

    import hello: hello; import std.stdio; void main() {hello.writeln;} 

    generate.d ~ source for the program that generates hello.d

    import std.stdio; void main() {writeln("immutable string hello = \"hello\";");} 

    meson.build

    project('badexample', 'd') generate = executable('generate', 'generate.d') hello = custom_target('hello', output: 'hello.d', capture: true, command: generate) executable('main', ['main.d', hello]) 

    This almost works as expected, but results in module hello is in file 'hello.d' which cannot be read because gdc can't find hello.d (because it hasn't been generated yet) when generating module dependencies.

    How do I tell Meson that generate needs to produce hello.d before attempting to compile main.d?

    In Makefile terms I want to do this...

    main: hello.d main.d gdc hello.d main.d -o main generate: generate.d gdc generate.d -o generate hello.d: generate ./generate > hello.d 

    Zip file of the example build if anyone is interested.

    Images of the dependency graph I have and the graph I want

    Edits: formatting and more information

    submitted by /u/84vdFpOMx9_d4B5FYRTV
    [link] [comments]

    Unsigned int

    Posted: 13 May 2020 04:55 PM PDT

    I'm new to programming and I'm studying c++ currently. I'm wondering when you would use an unsigned int, or any unsigned data type. From what I've read, I know that you can store a larger positive number in an unsigned int.

    submitted by /u/va-jj23
    [link] [comments]

    Best way to handle if a user inputs a number larger than Int32?

    Posted: 13 May 2020 01:08 PM PDT

    I'm not expecting anything larger than Int32 for some inputs.

    submitted by /u/infinitude_21
    [link] [comments]

    Why am I getting an invalid syntax error in my encode with Python 3?

    Posted: 13 May 2020 12:39 PM PDT

    A task we have been given is to crack a given set of password hashes by using Python 3, the text file contains a unique set of hashes with salts and the final version should produce a text file containing as many cracked hashes as possible. This is what I've created so far but the encode is wrong. Could anyone tell me what is wrong, I'm fairly new at this?

    Below is the code

    salt_chars = ("1", "2", "3", "a", "b", "c") "salt".join = [random.choice(salt_chars)for salt in range(0,10)] passwd = input("Enter your password: ") hobj = hashlib.md5(passwd+salt) hobj = hashlib.md5(passwd.encode() + salt.encode()) hobj.hexdigest() with open ("spacedinosaur.txt", "w") as ucd: ucd.write(salt+ ":" + hobj.hexdigest) salt = "" pwdhash = "" with open ("ucd.txt", "r") as udc: for line in udc: 1 = line.strip() splitln = 1,split(":") salt = splitln[0] pwdhash = spltln[1] actual_hash = hashlib.md5 (passwd.encode () + salt.encode(hexdigest()) encode(hexdigest) if actual_hash == expected_hash: if actual_hash == expected_hash: print("Access granted") else: print("Access denied") 
    submitted by /u/reddwarfdog
    [link] [comments]

    [Koa] No response sent after event?

    Posted: 13 May 2020 02:49 PM PDT

    Code:

    // Error handling app.use(async (ctx, next) => { try { await next(); } catch (err) { console.log('err', err); ctx.status = err.status || 500; ctx.body = err.message; ctx.app.emit('error', err, ctx); } }) 

    I've taken virtually the same code from the docs on error handling but the following line:

    ctx.app.emit('error', err, ctx); 

    blocks the response from being sent (I get 204 instead of 500) and I'm not sure why that is?

    If I comment it out, then I get the right status code and body.

    Does this have to do with how the event loop works in Node?

    Thanks!

    submitted by /u/RikuBarlow
    [link] [comments]

    Is this in correct big-O complexity? (sorry if this is an obvious question)

    Posted: 13 May 2020 02:14 PM PDT

    Technical Interview in 2 weeks, best practice for preparing?

    Posted: 13 May 2020 01:57 PM PDT

    I was recently invited to do a technical interview. They said that it involves logic questions and pseudo code. Would anyone have recommendations on how to prepare?

    Antoher one of the main things that I want to improve in is Leetcode. What is the best way to approach these? Especially with 2 weeks to prep?

    submitted by /u/GGAllinsPizza
    [link] [comments]

    Is this in increasing big-O notation? (sorry this may be simple, but I am very confused)

    Posted: 13 May 2020 01:25 PM PDT

    https://ibb.co/Jcv06Q6 here is the order I put the functions in. If anything is wrong, please let me know!!! It would be extra great if you referred me to a place to learn how to correct it! I appreciate all of you :)

    submitted by /u/SackOfFlesh
    [link] [comments]

    [C] - Cast const pointer to pointer to array of consts :P

    Posted: 13 May 2020 12:44 PM PDT

    Hey everyone.

    I have a pointer

    const double *y 

    which is write protected. I want to access it as an "2D array", I do this by casting it the following way:

    typedef double(*double2d)[size]; double2d y2d = (double2d)y; 

    So now I can access it as

    y2d[10][1] = 3.14; 

    However, this loses the const qualifier, which gcc mentions:

    cast discards 'const' qualifier from pointer target type [-Werror=cast-qual] 

    Now, how the hell can I do the cast correctly, so this stays protected? The values at the pointer should be protected, so should't that mean that I would do it like this?:

    typedef double(*double2d)[size]; const double2d y2d = (const double2d)y; 

    This does not work, but I can't figure out why.

    Edit: Seems like this is a bug in gcc. Clang correctly recognizes that the const'ness is preserved:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81631

    submitted by /u/raycluster
    [link] [comments]

    People who work on the industry, were you ever scared that your skills wouldn't be enough?

    Posted: 13 May 2020 12:47 AM PDT

    I'm a college student at the moment. I'm on second quarter and I'm still not getting every subject as good as I would like to. I'm afraid that when I get a job in the future I'll get asked to do something i will have no idea how to handle. Has this ever happened to you?

    submitted by /u/Callattar
    [link] [comments]

    Is it possible to make a tts creator that only uses redefined sentences?

    Posted: 13 May 2020 11:18 AM PDT

    Basically lets say you recorded a few famous quotes of an actor that passed away. Can you tell the program what he said and then let him hear what he said, so it can try to make a voice out of it? I know there are websites that already create tts for you, but, you need to say already defined sentences and since you can't make a dead celebrity say something for you, you have to use what's already said.

    submitted by /u/Rofle44
    [link] [comments]

    No comments:

    Post a Comment