• Breaking News

    Sunday, October 28, 2018

    Looking for a program: profile your program with print statements Ask Programming

    Looking for a program: profile your program with print statements Ask Programming


    Looking for a program: profile your program with print statements

    Posted: 28 Oct 2018 06:29 PM PDT

    I used to have a command line program that could profile other programs simply using print statements. You could do stuff like:

    def main(): do_a_task() print("START") do_another_task() print("END") 

    And it would profile between the printing of START and END. I believe it was written in golang and there was a very similar (a clone, even) one written in rust (cliche, I know). Or maybe the other way around.

    Does anyone know the name of one of these programs?

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

    How to use an argument to set an element in the "this" position in the array to the value of the newText argument?

    Posted: 28 Oct 2018 07:09 PM PDT

    Lang: Javascript

    In

    var editTask = function(tasks, i, newText) {

    if (isArray) {

    };

    i'm unsure of how to set the value of the element at "this" position in the array to value of the newText argument.

    For the javascript there are actually 3 files but, I'm not sure how to add more, if even possible to codepen. So, I bundled them together.

    Current Code: https://codepen.io/UnifiedOblivion/pen/aRMrLz

    Any help with what I should be using in the statement would be appreciated.

    Thanks.

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

    Linux users, do you use SUPER-TAB or ALT-TAB to cycle through your programs?

    Posted: 28 Oct 2018 10:00 AM PDT

    Leetcode(easy)- Tree-C# - How to always keep a pointer to the right child?

    Posted: 28 Oct 2018 04:45 PM PDT

    Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child.

     Stack<TreeNode> stk = new Stack<TreeNode>(); TreeNode incTreeNode = new TreeNode(0); TreeNode curr = root; TreeNode nodePtrCurr = incTreeNode; TreeNode nodePtrRight = incTreeNode.right; while (curr != null || stk.Count != 0) { while (curr != null) { stk.Push(curr ); curr = curr .left; } curr = stk.Pop(); //nodePtrCurr.val = curr.val; //nodePtrCurr.right = new TreeNode(0); //nodePtrCurr //nodePtrRight = nodePtrCurr; //nodePtr = nodePtr.right; curr = curr.right; } 

    I am stuck on trying to make a right child and keep a pointer to it. Every time I reach the "end" in inorder I want to add that value to the right child of the current node. The stuff I have commented out are me trying to do that.

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

    Preventing Recursive Loop on a Parent Child Table

    Posted: 28 Oct 2018 04:34 PM PDT

    Hi all,

    I have a Parent of something (call it ParentID) that can have unlimited ChildIDs. When that ParentID is called, it results in not only making a copy of itself, but also making a copy of all ChildIDs. ChildIDs may, themselves, call other ParentIDs.

    How do I prevent a recursive loop from happening where the server gets stuck?

    On the one level, it's quite simple. If I add childID 12414 to ParentID 12413, I can quickly see if 12414 ever calls 12413 and block this addition:

    https://imgur.com/a/r2LlGGV

    However, on the many levels it becomes tough. For example, take ParentID 12413. I assign ChildID 12414 to it. Later on, I make some more assignments, and eventually, through iteration, it turns out that adding 12414 in effect results in the creation of 12413 (which, in turn creates 12414 and so on forever):

    https://imgur.com/a/24BpR57

    Does anyone have any clever ideas on how to prevent entering into iterative loops?

    Thanks!

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

    What are good starting URLs for web-scrapers?

    Posted: 28 Oct 2018 06:46 PM PDT

    I am making a web-scraper that searches for sites of a certain type. I am in the beginning stages of this project - getting familiar with scrapy mostly. I was wondering if anyone has good advice for choosing starting URL's so that the crawlers are most likely to find sites that I am searching for.

    Also, what does the search algorithm look like for crawlers? Breadth-first, depth-first or something else?

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

    Can you help me with a Vertical Sundial Solstice-to-Solstice equation (for a business card)?

    Posted: 28 Oct 2018 04:42 PM PDT

    I need help with an equation to produce hour lines for local time on a vertical sundial. Here is my mock-up of one side of the business card. The local time equation is akin to the work by Mac Oglesby found here. The difference: I need the hour and half hour lines to go from Winter Solstice at the top—to Summer Solstice at the bottom. I am not QB (or any programming language) savvy, but perhaps most of the work has been done in that program detailed on that site above? Is anyone here able and willing to take this on? If so, when it's done I'd like the work to be published back on Carl Sabanski's site:MySundial.ca. (It's very old, but man o' man, there is a LOT of sundial related info there! This sundial equation / program would fit right in with the rest.)

    THANK YOU!! (And please let me know if there is a better sub to post this. r/AskScience, r/CheatAtMathHomework, r/AskAstronomy a better place?)

    PS I tried contacting Mac, but at about 86 years old…perhaps he is not with us any longer. Or maybe my letter to him didn't reach him simply because he moved.

    PPS I forgot this: The sundial is going to be on a business card, so the space available from Winter to Summer Solstice is quite small: about 1" max. The gnomon (which is angled to the North Star from my latitude) is cut out on all but the hinge side, so it can swing out to perpendicular to the business card. Please help double check my numbers, but I think I need the gnomon length of 0.5736" which would put the shortest vertical shadow (at Winter Solstice) 0.5623" below the top of the gnomon and the longest vertical shadow (at Summer Solstice) 1.375" below the top of the gnomon. My 14 year old did the math, so not entirely sure it's accurate. And now that I read thisI wonder if my assumption is at all correct that the sundial winter and summer solstice declination lines are contained in what looks like an upside-down arc. ACK, this stuff is HARD!

    submitted by /u/rees-maxwell
    [link] [comments]

    Need a recommendation for project I'm looking to take on

    Posted: 28 Oct 2018 04:32 PM PDT

    Hey there, I'm hoping to build some software that detects and removes audio feedback. For those that don't know, feedback is the loud screeching that occours when you have a microphone too close to a speaker. For live sound, those frequencies need to be removed and I'm looking to find a way to do that automatically.

    I'm wondering what the best way to go about doing this would be? I've used C++ and MatLab a bit at university but not a huge amount. What would be best for building some filters that attenuate certain frequencies that are hitting a ceratin dB level? Don't know if that's too broad, fairly new to programming but feel free to ask me anything!

    Thanks!

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

    USB Keys

    Posted: 28 Oct 2018 04:19 PM PDT

    what if i have a usb power strip connected to my computer and i use ubs that must be in order to login. so to clarify the power strip will read and tell where it is and if it's in the right order it will login into whatever profile that is configured to. i was also thinking of it able to access other profiles by rearranging the order or by adding a usb or taking away a usb to the strip. is this too outrageous or no.

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

    C programming gets() concept question

    Posted: 28 Oct 2018 03:51 PM PDT

    Why in my code does the program freeze when trying to accept my second getchar() statement? I can't seem to figure it out because I didn't do anything different with getchar(a), and getchar(b).

    Should I just use scanf?

    Code can be found here: https://onlinegdb.com/rkStJpX2X

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

    Need help on: How to monetize a web app that is basically an online tool?

    Posted: 28 Oct 2018 03:29 PM PDT

    We are creating a web application that currently works as an online tool (because its mostly html, js and css and we are not implementing database and other backend stuff, the only thing that we intend to implement on the backend is to allow the login from users to access this tool).

    So here is an overview of the app:

    It allows the user to insert data based on our html forms. Then, with that data they can get rich graphics to understand patterns and other important stuff (this is what has the most value to the user). They have an option to download that data as .json file in their local machines to later upload it if they want and get the charts again without need to input all the data again.

    Now to get monetization to allow us to work and sustain this project we have in mind: to give only login credentials to the users that pay. But then i was thinking that this can be hacked easily, if the user that buy's one login credentials can give them to other users and they can easily access the app without paying. So to prevent this i was thinking to assign the user machine ip to each login credentials. But it seems that its not the most appropriate method (lets say that the users has its home ip, so if is not at home the ip changes and he loses access to the app) so how can implement a better one?

    Note: I know that if we stored the user's input data in our server (instead of allowing them to store their data on their machines) they will not give their credentials (at least so easily) to others because they could see their private data. But right now we want to make it simple using the current method of user storing its own data...

    submitted by /u/Don-g9
    [link] [comments]

    [PHP][JS]no form action performed after clicking submit

    Posted: 28 Oct 2018 12:36 PM PDT

    So to start with a little bit of code:

    JS:

    https://pastebin.com/Yju3KxjG

    and now what I mean, the script displays the first elements where is the "Następne" where the php code is given, but nothing happens after clicking this button, while when the last element is displayed where it is "Zakończ", the php code is already running, and I want to make it every time when I click the "Następne" button the php code was executed

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

    Best practices for computer eye strain

    Posted: 28 Oct 2018 12:33 PM PDT

    Hey guys! What do y'all do to combat computer eye strain while also being productive when you code? Right now I have non-prescription blue light glasses and they do a good job at keeping the glare out of my eyes, but I've noticed recently I can't focus on specific lines of code unless my computer is right in front of my face. I want to be able to see as many lines of code as possible on the screen, but I feel like getting a huge prescription and making the code small is not the right solution. What works for y'all?

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

    Programming a searchable dictionary

    Posted: 28 Oct 2018 09:47 AM PDT

    Hello! First and foremost I am not looking for anyone to write any code for me, more looking to understand the process behind a particular function.

    I'm wanting to create a dictionary-like program that searches through a set of data and returns words based on either their tags or parts of the word. For example, I want to allow the user to search for any word containing the string "man", and have it display all those words. On top of that, I want it to be able to limit those that have a tag named "Chapter 1" or something to that effect. The intent is to be able to search a dictionary for particular words that are limited to vocabulary lists from a textbook, making a sort of dynamic glossary of terms depending on which chapters you want to search through.

    I'm very new to this, and would really appreciate if someone could point me in the right direction to learn more. I've tried searching on google but I'm a little unsure of what search terms would yield the best results, so even search suggestions would be appreciated. If there's a subreddit that is better suited for this as well please let me know so I can post it in the correct place! Thanks!

    Edit: I purposely didnt include a language that I'm trying to program this in because I'm looking to understand what would be the most efficient process. So any tutorial or information in any language would be great!

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

    What Programming Languages are truly Batteries-Included?

    Posted: 28 Oct 2018 07:18 AM PDT

    I am talking about languages like Wolfram Language or Rebol, which ship with a GUI system, internet stuff and so on in the standard library. I don't qualify Python as it doesn't ship with Tkinter ready under Ubuntu for example.

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

    cptsd and programming, what would you do?

    Posted: 28 Oct 2018 05:03 AM PDT

    I have cptsd. Basically it's abuse and trauma from when I was a kid.

    It doesn't let me have normal relationships with managers, collegues etc. It's a mixture of social anxiety, hypervigilance, depression, etc...

    I have had some very demanding jobs, but that's not for me. (consulting, trading, finance, etc.)

    What would you do if you need quiet time and working on your own? Anyone has experienced with freelance?

    I am quiet social with friends, who are very near and dear to me.

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

    C, help about arrays

    Posted: 28 Oct 2018 01:43 AM PDT

    I'm having problems with a project, haven't tested this part since the rest is broken but I just want to ask if it should work. So the project revolves around sorting a bunch of data in an array that we create from a file. First number in file is how many lines of numbers there are. So here's my part to open the file and load the data into the array:

    //(vars: int filename, header, curLine, score[i], etc......)

    printf("What is the name of the input file?\n");

    scanf("%s", &filename);

    FILE * ifp = NULL;

    //open named file

    ifp = fopen(filename, "r");

    fscanf(ifp, "%d", &header);

    //initialize and loading numbers into array

    for(i=0; i<header + 1; i++){

    for(i=0; i<header + 1; i++){

    fscanf(ifp, "%d", &curLine);

    score[i] = curLine;

    }

    }

    thanks

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

    No comments:

    Post a Comment