• Breaking News

    Monday, February 24, 2020

    Coding anxiety Ask Programming

    Coding anxiety Ask Programming


    Coding anxiety

    Posted: 24 Feb 2020 07:31 PM PST

    I've been fighting this bit for some time, and I truly am at a lost as to how to combat this effectively...It either comes up when I'm trying to learn something new, or when I'm working on ONE project and my thoughts wonder to "you should be working on THIS instead, this will NEVER be useful in a work situation!"

    Does anyone else have this sort of issue? and if so what strategy's have you guys developed to try and fight it?

    Not trying to be whiny, just some newbe whose trying to get past his own fears.

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

    Is there a library/package to get all imports from Java files using Python?

    Posted: 24 Feb 2020 12:26 PM PST

    MATLAB or Python?

    Posted: 24 Feb 2020 07:29 PM PST

    I need to take one of the other for my class. I am a Material Science engineer, hopefully going into the field of nano tech. They are both intro courses that my school offers. I have no idea which one will benefit me more. Also, which one is harder?

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

    Storing JWT tokens in the database

    Posted: 24 Feb 2020 01:41 PM PST

    Is it ok to do it? I have to be able to invalidate them so that the user can logout so tokens should be stored in the db somehow. I know that the point of JWTs is to work without needing the db but I have already written the code. If they have a short expire time (e.g. 1 hour) is it safe or should they be hashed?

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

    Scrap forum threads and create a directed graph from the results - need advices

    Posted: 24 Feb 2020 04:52 PM PST

    Hey guys, I need your help in picking the right tools and languages for this small project of mine.

    Given a link to a thread in a forum (not reddit BTW), scrap the first comment in the thread. Keep the text and title, extract all links to other threads in the same forum.

    For each link to a thread, do previous stage.

    Continues until no new threads are linked.

    I want to visualise the result with a directed graph - each vertex would be a thread(*), the edges would be the linking between threads - (original thread, link thread) (i.e from which thread was the current thread linked).

    (*) Each vertex would show the title of the thread, upon clicking a vertex the text of the first comment would pop up.

    I was thinking of using python for the scraping but I'm not sure it'll handle the visualisation. So I was thinking of creating a local client-server, with React as client side, to visualise the data received from the Python "server". In React I'll use cytoscape to create graphs, in python - networkX.

    I thought of simply using nodejs for everything as the scraping is basic and it should be rather easy to visualise the results.

    But both solutions feel cumbersome to me.. I'd love to hear more opinions!

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

    Best Key Combinations for Custom Hotkeys?

    Posted: 24 Feb 2020 09:54 PM PST

    Hey guys,

    I'm writing a python script that uses a lot of hotkeys.

    Originally I was usually Shift + F1-F9 to run these hotkeys however combinations like shift-f5 in a browser refreshes, shift-f3 is find, etc. I was thinking of using ctrl + F keys instead but many of the ctrl + F combinations also have many random uses in other applications.

    What key combinations would be the best to be completely uninteractive with browsers, game, excel, windows itself, etc. so that I can dedicate to the sole function of activating a function script?

    Thanks!

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

    How to monitor whether a remote process has crashed?

    Posted: 24 Feb 2020 04:25 PM PST

    I have a large number of instances across multiple cloud providers. Each of them is running a single Java program. I want to check that all of these Java programs are running and haven't crashed, and if/when one of them crashes, I want to be alerted about it.

    At the moment I have a hacked-together solution which will loop through an array of all the IP addresses, and send a command through SSH to each of them to check ps -ef
    and count the number of Java processes are running. If that number is zero then I will popup something on my screen to alert me.

    Is there a better solution? Ideally I could use a Zabbix-style tool to handle it for me but I don't know if anything exists that serves this need.

    submitted by /u/Future-Professional
    [link] [comments]

    Trying to figure out why Github Pages will not serve my documentation

    Posted: 24 Feb 2020 04:22 PM PST

    Hey all!

    I use sphinx to build html documentation, and am in the middle of open-sourcing some of my company's private repos.

    Internally, we serve documentation from an S3 bucket through Cloudfront so we can put access controls in front of it. But for open source, I figured publishing via Github Pages would be the path of least resistance.

    However, I cannot get the service to work correctly.

    Here is my repo, with my index.html in the /docs folder.

    Here is the site, which is not applying any of the linked css, and with all page links broken.

    I tried to isolate the issue by making a test repo with just the built documentation, and publishing from master.

    As you can see, this one does not even try to serve the index.html, I just get a 404 page.

    These files work both locally and when serving from AWS, so I'm a little at a loss for why Github Pages is not serving it correctly. I feel like I must be making some sort of dumb oversight. If anyone with more experience could take a look and point me toward the error of my ways I would really appreciate it. I'm a backend engineer for the most part so website logic is a little outside my normal wheelhouse. Thanks in advance!

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

    Is there an easy program/script I can use to use to input a list of numbers that I have into a websites search box?

    Posted: 24 Feb 2020 07:51 PM PST

    For example:

    I have a list of 1000 numbers combinations that I want to search on a website that allows me to search one number combination at a time. Once I search a number the website will tell me if that number has an active account in their system or not.

    To save me searching one by one, is there any easy way to input the list of numbers I have into a program or scrip and have it search the "Search box" on the website one number at a time.

    After each search I would also need to program/scrip to tell me if it produced a result for that number and keep that information handy for me.

    So once its done, I will see the result of the 1000 numbers being search letting me know which of those numbers turned up an active account.

    I know people will ask what I'm doing, but nothing dodgy here. I have a list of ABNs (Australia Business Numbers) and I am searching through my airline portal to see if those companies have an active account with that airline.

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

    Is there anything that works in C, but not in C++?

    Posted: 24 Feb 2020 01:01 AM PST

    I see C++ as C with "more stuff to do", like an extension. However, is there a function, method, or anything that works perfectly in C but fails to run in C++?

    Can you easily on C++ if you know C?

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

    I have a question regarding heap memory.. Can we use heap memory only through the malloc() ( or by extention calloc() ) function. If yes, Does int *ptr = 10 is stack memory?

    Posted: 24 Feb 2020 10:30 AM PST

    Network connection of programs on different languages (C++ and Python).

    Posted: 24 Feb 2020 01:59 PM PST

    Now I'm trying to create simple multiplayer game and I have one problem: I want to use python but, as I know, its programs can't work without python interpreter installed, so it will not work on all computers.

    And I thought: "Maybe, I can make server-side program on python and client-side on C++?" Is it possible to connect C++ and Python programs using local network? If it is, how?

    I know how to use winsock on C++ and socket module on python. I've tried, but my programs can't connect to each other...

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

    What "philosophy" should I follow for this C++ derived class problem?

    Posted: 24 Feb 2020 01:41 PM PST

    Suppose I have a class which has a private variable float* temp, and a member function which does something like this:

    void MyClass::my_func() { temp = (float*)malloc(8000); ... stuff ... free(temp); } 

    Basically it allocates temp, does some stuff with it as working space, then frees it up when it's done.

    Now suppose I want to derive a class which does the same, except that it allocates and deallocates temp only once, in the constructor/destructor. What's the "right" way to go about doing this, without completely overriding my_func and having to write all of stuff again? Doing that would leave me with two identical blocks of code where I should only have one (as I might rewrite it later in the base class and the derived class should then see the benefit of those changes automatically).

    The two ways I can think of involve altering the base class to accommodate the derived class, which feels like it goes against the spirit of derivation in the first place. I could add a wrapper function, my_func_outer(), which allocates, calls my_func(), and then deallocates, which I could then override in the derived class so it only makes the call to my_func(). Or I could add a boolean to control whether or not allocation/deallocation happens in my_func(), but this would look a bit "weird" in the base class because it would always be set to true and so would look superfluous.

    Is there a standard pattern I should use to do something like this?

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

    Loop in sql

    Posted: 24 Feb 2020 01:12 PM PST

    How would i get a bunch of customer ids in sql from one table then then loop through all of them and get their purchases from another table that has a customer id column

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

    How do I create a "Venn Diagram" style website?

    Posted: 24 Feb 2020 12:45 PM PST

    Let me start off by saying that I am incredibly new to programming. But I am looking to build a website with the same concept as this one.

    The idea is that I will be able to copy and paste a list of ingredients into a box and have it cross-reference a pre-set list and have the site spit out anything that matches. I am guessing that something like this already exists on GitHub, but I have no idea what to even search for. Any help would be much appreciated.

    Thank you!

    Edit: I don't need any fancy graphics or anything, this is just for personal use to cross-check product ingredients for my skin allergies.

    submitted by /u/biscuit-basket
    [link] [comments]

    Code It Yourself: Any suggestions?

    Posted: 24 Feb 2020 11:09 AM PST

    Hey Guys, so, I learned programming some years ago and nowadays I enjoy training my coding abilities by creating technology by my own, for example database systems and operation systems. I was thinking about creating a subreddit just to debate DIY systems (involving code). Do you guys have any suggestions if I should create one or is there any good material on Programming DIY?

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

    Primitive types

    Posted: 24 Feb 2020 05:28 AM PST

    Hello you beautiful minds.

    Just a quick question about how most programming languages handle primitive data types.
    So when I write the following code...

    byte number = 42;

    Does the literal "42" immediately get interpreted as an int and is then implicitly converted to a byte when the compiler sees that we're trying to store it in a memory space intended for a byte . Or does the compiler immediately interpret it as a double by identifying that we would like to place this integral type into a memory space that is intended for a double?

    I'm asking because if it can immediately identify it as a byte then why can't most compilers do this for floating point numbers? (I'm referring to the compulsory use of f/F for float for example.)

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

    [JS] Trying to add a bunch of stuff, subtract one value Adobe Acrobat Pro.

    Posted: 24 Feb 2020 09:02 AM PST

    Fairly simple. Add a bunch of stuff, subtract one value. Currently running

    var v1 = getField("fill_49" + "fill_50" + "fill_51" + "fill_52" + "fill_53" + "fill_54" + "fill_55" + "fill_56").value; var v2 = getField("PettyCash").value; event.value = v1 - v2; 

    All it's giving me is a negative of the PettyCash amount. I'm sure I'm doing something dumb.

    submitted by /u/oreo-cat-
    [link] [comments]

    Grouping and Suming Multiple Columns MYSQL

    Posted: 24 Feb 2020 08:33 AM PST

    I have a two tables one is products that has productid, productname, customerid1 and quantity and another customers table that has customerid2,customername and dates

    what i want to do is collect all the customerid2 from customers table between two dates. then match those ids to customerid1 in the products table with a join. then group all the products by name sum their quantity, then group all the customers by name for each product and sum their total quantity,

    **customers** Column , Column, Column customerid2:1, name:jon, date:2020 customerid2:2, name:steve, date:2020 customerid2:3, name:ted, date:2020 customerid2:4, name:ned, date:2020 **products** Column , Column , Column , Column productid:3 , productname:car, customerid1:1, qty,5 productid:3 , productname:car, customerid1:2, qty,5 productid:1 , productname:boat, customerid1:3, qty,1 productid:1 , productname:boat, customerid1:4, qty,2 productid:3 , productname:car, customerid1:1, qty,5 

    the final output should be:

     car total:15 customer id:1 name:jon qty:10 customer id:2 name:steve qty:5* boat total:3 customer id:3 name:ted qty:1 customer id:4 name:ned qty:2 

    my code:

    $sql = SELECT customerid2, name, date, productname, SUM(qty) FROM customers JOIN ON customerid2 = customerid1 WHERE date BETWEEN '2019' AND '2020' GROUP BY productid, customerid2 ORDER BY qty 
    submitted by /u/aaguzzowork
    [link] [comments]

    [JS] Accessing CSS descendants through querySelector vs concatenated id?

    Posted: 24 Feb 2020 07:32 AM PST

    EDIT:

    I updated the code and implemented a third way of doing it via child classes, that my pal u/Blando-Cartesian suggested. Looks pretty legit. Which of these three is preferable? And how do I go deep with querySelector if I invoke it from my element? You see I have to write 2 lines to get something that I'm sure can be done in 1 line. Cheers.

    https://www.w3schools.com/code/tryit.asp?filename=GC92FBE89LUE


    Hi guys!

    https://www.w3schools.com/code/tryit.asp?filename=GC8T9SKI2UKC

    I made some example code to try out the new thing you taught me where I can access descendants with first-child and div:nth-child(n). And also to ask you about accessing those deep values from JS, and which approach is better.

    So, from what I suspect, if I use querySelector, then the computer has to loop through the first layer of children to find forst or nth child, and then it has to loop through every subsequent layer of children of a certain type, until it gets deep enough and finds the element it searches for. Also, there seems to be room for error and unexpected behaviour if you don't watch out specifically in which order you create children elements. And also these selector thingies seem a bit wonky. I also don't know how to string two of them together (seen in code).

    On the other hand, if I use id and concatenation, then I basically create a billion ids, and if I want to access one, the computer has to loop through them all. Not just the men, but the women and children too. I mean, I do kinda need id to distinguish items, but lst time I made my own id in the dataset property. I don't need the id in the CSS sense that it is supposed to be used.

    So I'm asking you which approach should be prefered performance-wise for this specific situation where you have an uncertain number of items which are all the same, but they share a class, and they have to be able to have their class changed.

    I am personally leaning towards the first solution, but I don't know enough about how stuff works.

    Tnx!

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

    What are the highest paying fields in programming?

    Posted: 24 Feb 2020 06:48 AM PST

    Thinking Machine Learning/data science, security, and maybe embedded systems. But these are merely rumor after lurking on some websites.

    I currently make 60$/hr and looking to aim at whatever is needed to increase my value. I live in a low cost of living area in South East Michigan. Can't move.

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

    [Urgent Help] Scientific Calculator. C++

    Posted: 24 Feb 2020 06:44 AM PST

    Im in a beginner C++ student, and I am very lost for my midterm my teacher made my group make a scientific calculator with the following functions. Im in charge of the trigonometry section and I am very lost and not sure how to start or do anything. as I said I am a beginner this is my first programming class which begun in January, the teacher is not very helpful and very redundant. he goes over a whole section every class/

    He is asking for the Calculator to have the following Functions.

    Trigonometry ( NEED HELP WITH THIS)

    • Sine
    • Cosine
    • Tangent
    • Secant
    • Cosecant
    • Cotangent
    • Inverse sine
    • Inverse cosine
    • Inverse tangent

    Exponentials and Logarithm

    • • Exponential e^x

    Power (X^2, X^n)

    • Natural Log
    • Log base 10
    • Hyperbolic sine
    • Hyperbolic Cosine
    • Hyperbolic Tangent
      Complex Numbers
    • Multiplication
    • Addition/Subtraction
    • Conjugate
    • Polar to Rectangular
    • Rectangular to Polar
      Combinatrix

      • Combination
      • Permutation
      • Factorial
      • Fibonacci Series
      • Pascal's Triangle
      • Arithmetic Sequence
      • Arithmetic Series
      • Geometric Sequence
      • Geometric series
        Matrix (Up to 4X4 Matrix)
        • Addition
        • Subtraction
        • Transpose
        • Inverse
        • Determinant • Multiplication
        Statistics and Financing
    • Mean

    • Median

    • Mode

    • Standard deviation

    • Variance

    • Simple Interest

    • Compound Interest

    • APR Financing

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

    Using mutexes and condition variables to generate/fetch data for multiple callers (multithreaded C++)

    Posted: 24 Feb 2020 06:12 AM PST

    I can't seem to get my head completely around mutexes and condition variables, so I'm hoping that by describing what I want to do, someone can point me in the right direction.

    I want to create an output image using multiple threads (one per row). Outputting each row of the image requires creating three input rows, with each subsequent output row re-using two of the three input rows from the previous row, e.g.:

    Output row 1 needs input rows 1, 2, and 3
    Output row 2 needs input rows 2, 3, and 4
    Output row 3 needs input rows 3, 4, and 5

    The input rows are generated as required, because the input "image" is too large to hold in memory. So I'm imagining a function, OutputRow, which requests pointers to the three rows it needs:

    void OutputRow(int y, float* output_data) { float* temp1 = Input->GetRow(y); float* temp1 = Input->GetRow(y + 1); float* temp1 = Input->GetRow(y + 2); ... do some stuff and write the output row to output_data ... Input->FinishedWith(y); Input->FinishedWith(y + 1); Input->FinishedWith(y + 2); } 

    The first time a particular row is requested from Input, it sets about generating the row. But if a second or third request comes in for that row, I want it to check whether that line has finished being generated, and either a) return the pointer to the finished input row, or b) make the caller wait until the row is ready, and then return the pointer.

    Once Input receives three FinishedWith calls for the same row, it knows it can safely delete the row from memory (and/or recycle that allocated memory for storing a new row).

    So far, I know I need a mutex which GetRow will lock while it checks to see if a row has already been generated, and if it hasn't been generated, then it should start generating it. But I'm guessing I also need a mutex per row, so subsequent requests can be put on hold until the row is aready. Does that make sense? Will I also need to use a condition variable so that the second and third calls to GetRow can be alerted when the data is already, or will trying to lock a mutex suffice?

    Timeline:

    1. OutputRow(1) is called from the first (of n) threads. It calls Input->GetRow(1), which we assume finishes with no problems, and then calls Input->GetRow(2)
    2. Input->GetRow(2) successfully locks Input's main mutex and checks if row 1 is already generated and cached
    3. OutputRow(2) is called from the second thread. It calls Input->GetRow(2). This tries, but fails, to lock the main mutex
    4. The call in (2) finishes its check and finds that the row doesn't exist. It creates a new mutex for the row, locks it, unlocks the main mutex, and starts generating the row
    5. The call in (3) is now free to lock the main mutex and proceeds as the other call did, checking if the row exists. It finds that the row exists, and has an associated mutex which it tries, but fails, to lock (because the row is not yet fully generated)
    6. (4) finishes generating the row, unlocks the row's mutex, and returns the pointer to the calling function (OutputRow(1))
    7. (5) is now able to lock the row mutex, which it immediately unlocks, and returns the pointer to the calling function (OutputRow(2))

    ...

    1. Some time later, Input receives the third of three FinishedWith(2) calls, and frees up the row data.

    I'm a bit suspicious that this doesn't involve condition variables. Have I missed something? Will I slow things down by trying to lock a mutex rather than waiting on a condition variable?

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

    Looking to learn a lang for longterm use for a devops/Backend career, College Student rn

    Posted: 24 Feb 2020 01:53 AM PST

    Rn a Junior year student, Learnt GO this summer. I want to mostly work on systems,Microservices,api's and Devops software(as in writing the tools rather than implementing them). Professionally i have only worked in python and C. Should i learn something like Java to get a Job(still a long way from it, 3 more years,2 years of bachelors + included masters thesis) or do i learn rust ? or just stick to go and try to get better at Go.

    I have heard a lot of good things about rust.I program for fun tbh so i want to learn something intersting and fun but it also should get me a job 3 years down the lline. The place i interned at this summer is moving towards Go,lot of other places where my friends work are moving towards it as well.

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

    No comments:

    Post a Comment