• Breaking News

    Tuesday, January 30, 2018

    Looking to increase the efficiency of some math-heavy code Ask Programming

    Looking to increase the efficiency of some math-heavy code Ask Programming


    Looking to increase the efficiency of some math-heavy code

    Posted: 30 Jan 2018 06:03 PM PST

    So I have a function for rotating a point in 3D space, I was told it's "surprisingly inefficient," how can I optimize this? My first thought was to create a buffer for the sin and cos functions to reduce calculation times, is this viable?

    Here is the code in question: https://pastebin.com/1dJmSbBK

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

    What calculations are done in Human minds because they would be too slow in computer?

    Posted: 30 Jan 2018 01:48 PM PST

    Example: detecting if a program has crashed, instead of wrapping it in another program that emulates it and says "sorry I have crashed I am going to stop now so no need for you to make any choices to help me with my crash"

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

    What are some ways to attempt to speed up encoding without sacrificing quality?

    Posted: 30 Jan 2018 09:27 PM PST

    I don't know Javascript yet, but I need form submission on a very basic website I'm building to work. Please help!

    Posted: 30 Jan 2018 09:24 PM PST

    Hi all,

    I'm about 20% of the way through the Web Dev Bootcamp Udemy course. It's fascinating in its own right, but I'm doing it specifically so I can build a basic website for a small business I've started with two friends. When I say basic, I really mean it. It's just HTML and CSS (I've used a lot of bootstrap), except for a basic comment/query form, which just includes things like Name, Email, Message etc. I want the user to be able to submit the form and for me to receive the message (I don't really mind how).

    I fully intend to learn Javascript in full and go on to be able to make more advanced sites and apps, but I'd really like to publish the website now, rather than have to push through 80 hours of content just for this form thing. What should I do?

    Thank you all.

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

    [C] why isn't recursion working here

    Posted: 30 Jan 2018 08:00 PM PST

    So I a complete beginner at C. This program is supposed to list all the files, subfolders and the files within the subfolders and keep going until it has listed everything; subfolders, subfolder files, sub-subfolders, sub-subfolder files and so on.

    For some reason it is just looking into the folder you give it and not going into the subfolders. Basically the recursion is not working. Any ideas? Thank you for reading!

    #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> void listDir(char* path){ DIR* dir; struct dirent *ent; if((dir=opendir(path)) != NULL){ while (( ent = readdir(dir)) != NULL){ if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0){ printf("%s\n", ent->d_name); listDir(ent->d_name); } } closedir(dir); } } int main(void){ listDir("./test") } 
    submitted by /u/notyourdaddy
    [link] [comments]

    Deciding on the project. How to evaluate, decide, plan, and act on an idea.

    Posted: 30 Jan 2018 07:51 PM PST

    To summarize: I find myself amidst analysis paralysis and asking for advice deciding on what I should do with the next month of my life. Any links to articles or advice about organizing and acting on your ideas, particularly software projects would be helpful. I have the skill to put together a decent restful web application but I'd ideally like to facilitate a business process that could potentially earn me some money, if not simply serve as portfolio juice. Trouble is laying out my ideas, limiting the scope to something manageable, then prioritizing and deciding what to do. I find myself wanting to follow a check-list of some sort. Any ideas?

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

    Trying to read word for word from a text file using c++

    Posted: 30 Jan 2018 07:11 PM PST

    I have a text file in which I have the names of three people as well as some numbers following their names.

    Example:

    John 34 42

    Jack 23 89

    Jake 13 45

    I'm trying to find a way to read each word and number separately, but all my research tells me to use functions from the sstream library. However, my teacher specified that we cannot use this library. We are allowed however to use fstream and things like getline and basic input/output commands.

    Any ideas on how to get started?

    submitted by /u/Raper-Of-Mars
    [link] [comments]

    Error when reading and writing image in java

    Posted: 30 Jan 2018 06:59 PM PST

    I am trying to read a file and output it as another format but I got the following error:

    Exception in thread "main" java.lang.IllegalArgumentException: image == null! at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(Unknown Source) at javax.imageio.ImageIO.getWriter(Unknown Source) at javax.imageio.ImageIO.write(Unknown Source) at MyImage2.main(MyImage2.java:23) import java.io.File; import java.io.IOException; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; public class MyImage2{ public static void main(String args[])throws IOException{ BufferedImage image = null; File f = null; //read image file try{ f = new File("image.dat"); image = ImageIO.read(f); }catch(IOException e){ System.out.println("Error: "+e); } //write image try{ f = new File("Output.jpg"); ImageIO.write(image, "jpg", f); }catch(IOException e){ System.out.println("Error: "+e); } }//main() ends here }//class ends here 
    submitted by /u/metalloidica
    [link] [comments]

    Decision tree tutorial

    Posted: 30 Jan 2018 02:43 PM PST

    Anyone know a good place to study decision tree algorithms that work based on yes or no questions? I've found some good sources, but I know I must be missing something because I have failed to get it to work properly. Thank you in advance!

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

    Is this a Linear/Constraint Programming/(your suggestion) problem?

    Posted: 30 Jan 2018 09:40 AM PST

    I have reduced the scheduling problem I have to solve at work into the example below. I have been trying to use Googles OR-Tools library (https://developers.google.com/optimization/) to solve the problem because I think this is a Constraint Programming scenario. I am struggling to write a C# solver for this and worry that my lack of knowledge means I am trying to use the wrong tool for the job.

    The Requirement:

    • Given a list of Workers (Andy, Bob, Charlie, Dave) and a list of Locations (London, Paris, New York, Berlin, Moscow, Lisbon, Copenhagen)
    • For any given 5 day week I have a list of about 80 to 160 Jobs.
    • Each day has 420 minutes maximum that the Locations can be accessed.
    • Each Job is at 1 Location, 1 Location can have multiple jobs to schedule, Only 1 job can be worked on at a time at a Location
    • Each Job is completed by 1 Worker, and must completed within the day (no partial jobs)
    • Each Worker requires a different amount of time to complete each job

    e.g. Job1 takes Andy 30 minutes and Bob 45 minutes, while Job2 takes Andy 60 minutes and Bob 15 minute. Job1 and Job2 are both at Location "London" so we want to give Job1 to Andy and Job2 to Bob. This timematrix is calculated externally, and for this example we can say is a random value between 30 and 180 minutes.

    • The daily capacity of each worker is variable (in minutes) e.g. On day 3 of 5 Charlie can only work 300 minutes.

    Primary Goal - Schedule the jobs for a week so as to minimise the total time worked, a worker doing nothing is perfectly fine.

    There are no travel times to consider (these aren't real objects), so "Andy" can finish a job at "London" and instantly start a job at "Paris".

    Any tips on how to solve it, what I should be reading, what I should be googling? I don't normally post my problems for others but I am getting desperate. If this is a Constraint Programming scenario then I can take comfort in being dumb and needing to spend more time understanding how to setup the solver. But this is all so complex to me I think I might even be using the wrong approach completely.

    edit - Adding simplification, smallest time unit is 15 minutes. So I am changing the Andy and Bob examples to match these time windows.

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

    What am I doing wrong with this Java code?

    Posted: 30 Jan 2018 06:06 PM PST

    class Myclass {

    public static void main(string[] args) {

    system.out.println("hello");

    }

    }

    I compile it and it comes back with a bunch of error messages. I have no idea what I'm doing wrong or where it's wrong. I'm probably just being an idiot but I'm all out of ideas

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

    Java: How do you ask user for an integer input but also be able to let them input a string such as "q" to break a while loop?

    Posted: 30 Jan 2018 05:59 PM PST

    How do you override an int input to allow for the input of a "q" to exit a loop?

    "Please enter an integer or press "q" to quit."

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

    need help with a pseudocode algorithm

    Posted: 30 Jan 2018 05:01 PM PST

    My teacher asked us to modify a pseudocode algorithm for the addition of two m-digit numbers. He wants us to make it so that we can have two numbers containing a different amount of digits, and i haven't been able to figure out how to make that happen. So any help would be appreciated. Thanks Here is the original algorithm https://imgur.com/a/09kF8

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

    Copying image file contents from one file to another

    Posted: 30 Jan 2018 05:01 PM PST

    In Java, I want to copy contents of one image file into another, while adding a few header lines in the new file. I tried the following method, but I saw that some of the contents don't get copied and the image appears that some airbrush has been used on it.

    Here is the code I used, which will explain better:

     import java.io.*; public class FileDemo { public static void main(String args[]) { FileReader fr = null; FileWriter fw = null; try { fr = new FileReader("image.dat"); fw = new FileWriter("image3.pgm"); int c = fr.read(); fw.write("P5"); fw.write(String.format("%n")); fw.write("256 " + "256"); fw.write(String.format("%n")); fw.write("255"); fw.write(String.format("%n")); while(c!=-1) { fw.write(c); c = fr.read(); } } catch(IOException e) { e.printStackTrace(); } finally { close(fr); close(fw); } } public static void close(Closeable stream) { try { if (stream != null) { stream.close(); } } catch(IOException e) { //... } } } 
    submitted by /u/metalloidica
    [link] [comments]

    interview question bombed

    Posted: 30 Jan 2018 02:05 PM PST

    i had to parse a 2d array and print the values of each index in this order in javascript. I got half way but ran out of time and it really bummed me out since i had not practiced 2d arrays since college. anyways if anyone is willing to solve it and walk me through how they did it i would really appreciate it.
    https://imgur.com/a/kOBPc

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

    Why do you use an ORM?

    Posted: 30 Jan 2018 02:03 PM PST

    Curious on this. Why would you use an ORM? Personally I've tried to use them in the past, but have found them to just get in the way and create "more complexity" for what should be a trivial task.

    I guess I'm just trying to get an understanding of why someone would prefer ORM vs not using one. Or if I'm just not following a good practice here by refusing to use an ORM.

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

    Writing a GUI with Rust using QT Framework

    Posted: 30 Jan 2018 01:31 PM PST

    What is the status of rust using the QT Framework. I know that Python does pretty good binding for QT but I am also wondering how far the support for rust goes. I was only able to find articles and posts being made a year ago so I would like to know what is the status of rust and qt. I managed to find this link but does not want to waste hours on it to find out it is outdated or does not work as expected. Does anyone had many any experiences on that in the past? Thanks in advance

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

    How do I create something similar to the HELP Menu of MS office 2010 and above. Thanks!

    Posted: 30 Jan 2018 01:22 PM PST

    Git Error - Large Files Detected - possible solutions

    Posted: 30 Jan 2018 01:17 PM PST

    I haven't pushed to Github in a while (50 commits in) and now I have a file that is too large. Right now the only options that I'm aware of are:

    1. Remove the file from each commit via this
    2. Start a new git repo

    1 isn't very appealing as I'd have to go through 50+ commits and neither is starting a new repo. Was hoping for some alternative solutions?

    UPDATE: this did the trick.

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

    Thinking of career moves

    Posted: 30 Jan 2018 01:00 PM PST

    So I am a senior Java developer, and have been working with the same company for a few years now.

    I love the technical side of the work with the programming and problem solving, but at the same time I also feel like I don't get nearly as much human interaction as I would like in this profession.

    I'm now considering trying to move into technical sales or tech evangelist. So I have a few questions regarding this:

    A) Would this be considered a lateral career move, should I expect the same kind of salary or maybe even lower? B) Does anyone have any experience in taking this kind of career path, going from "hard" technical job as a programmer to a "soft" technical job in sales or evangelism? Any recommendations on how I could go about getting into it?

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

    To sandbox untrusted musical instrument code... What (preferably java) system can prove float ranges and max cycles about a code string that only reads and writes in a float array and has constant depth of loops of constant size?

    Posted: 30 Jan 2018 09:58 AM PST

    The PureData (music tool) ecosystem is a mess. People post *.pd files and give you instructions how to make it work with plugins that are, not data, but code, that you go back and read because for some reason its silent.

    Instead, I imagine a system where plugins are data in a limited language that proves max compute cycles and keeps the input and output floats in range -1 to 1, while allowing any range (except NaNs and Infinities) of the state and temp floats. Each float[] would have 4 ranges: input, state, temp, output. A sparse 2d matrix (using sigmoid to scale to input range -1 to 1) would connect all these in a feedback loop.

    Its lots of work to prove these things about an existing language before sending it into a compiler such as Javassist.

    Is there some existing system for the untrusted efficient sequential calculation of simple math in a float or double array with constant depth of loops in loops?

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

    Fewest Coins Problem in C

    Posted: 30 Jan 2018 09:04 AM PST

    So I'm having a hard time trying to come up with an algorithm for this problem in my programming class.

    This is the problem:

    Basic program (max 90%): Write a program to ask the user for the total amount of change that they have in dollars and cents then compute the least number of coins that they could possibly have if their change contains only quarters, dimes, nickels and pennies. Output the total number of coins as well as a table showing how many of each type of coin. For example, if the user inputs $12.63, your output should be:

     The fewest coins that you could have is 54: # quarters: 50 # dimes: 1 # nickels: 0 # pennies: 3 

    Extra feature (max 100%): Ask the user to input their total amount of change AND the number of nickels that their amount contains. Note: this does NOT assume that they have the minimum number of nickels possible. Based on their input, compute the fewest number of coins that they could have.

    For example, if the user inputs $12.63 and 3 nickels, your output should be:

     The fewest number of coins that you could have is 57: # quarters: 49 # dimes: 2 # nickels: 3 # pennies: 3 

    Could someone help me figure out how to get started on this? I am writing this in C .

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

    Any advice on how to create a portal when joining a network?

    Posted: 30 Jan 2018 07:50 AM PST

    I have a client that wants the wifi of his apartment business be a monthly subscription to their tenants? i am thinking of redirecting the tenant to a portal when accessing the wifi, to input a code to start the countdown or timer, then the owner will just provide the code when the tenant payed for it.

    I am still a computer science student, where should i start? is this doable? are there any API's that i should know? how much does it cost when developing this system?

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

    Querying the result of a mongo query?

    Posted: 30 Jan 2018 07:24 AM PST

    I am using node.js and mongoose with mongoDB.

    I have two models. An author model and a book model. Each author has an array called books that are object IDs that reference books. I want the user to be able to search for books by author but then also apply other search criteria such as book title.

    So when the user searches for an author I do an Author.find with that name, which can return multiple results. From there I populate the books array and then from there I am not sure what to do. I can easily get all books from all authors and return that but I am not sure how I could go about doing another search over the books returned from this model. This is a relatively simple thing to do with SQL so I assume it would be possible here.

    Relavent Code:

    https://pastebin.com/Lpc55BJ2

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

    [Tools] Code revisions shown in WinMerge - any way to mark/tag changes?

    Posted: 30 Jan 2018 02:43 AM PST

    I am doing a code review for a developer who has a habit of submitting changes for multiple bugfixes/features in one commit (I realise they shouldn't do this, but I don't want to focus on that here, I am stuck with it for now).

    I typically use TortoiseSVN and WinMerge to view the changes for a commit so that I can review them. This works well for smaller changes but it becomes very hard to keep track of everything when there are many changes across many features and many files in a single commit. I need to look at the changes in a non-sequential way in order to understand them.

    What I am looking for is a way to mark diffs that are shown in WinMerge in some way, so that I can categorise and tick them off as I work. For example, this could be to mark them in a different colour, mark them by feature ID etc. I was hoping for a plugin to WinMerge or similar, but I am happy to switch tools if needed.

    Currently I copy the feature from the new to the old document, and I know that I am finished reviewing when the documents are identical. This unfortunately makes the reviewed changes invisible, but it is better than nothing. Is there a better way?

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

    No comments:

    Post a Comment