• Breaking News

    Sunday, April 7, 2019

    Java code runs much faster on worse computer Ask Programming

    Java code runs much faster on worse computer Ask Programming


    Java code runs much faster on worse computer

    Posted: 07 Apr 2019 08:54 PM PDT

    I was testing a Java radix sort out on my laptop, then moved my work over to my desktop and it appears to be about 30% faster on my laptop, which has a worse processor. Laptop = i7-4710HQ and Desktop = Ryzen 1600. This is confusing to me because I was under the impression that processor power was the main driving factor behind a program's performance outside of actual optimization in the code. What hardware is Java dependent on? Thanks for any info.

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

    Pair Programming?

    Posted: 07 Apr 2019 11:25 AM PDT

    Early CS Student here, I'm just curious. How often is pair programming (on one computer, not referring to GitHub) used in the real world?

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

    Help using <= in pnorm, RStudio

    Posted: 07 Apr 2019 08:37 PM PDT

    Hey there, I am using RStudio to do a stats programming assignment in R. The question is asking for the pvalue of (-1 < Z <=1). When I put that in 1- pnorm though I get the error of unexpected '<=' in "1-pnorm(-1 < Z <+"

    My solution was to split it up into two pnorms such as 1 - (pnorm(-1 < Z) * pnorm(Z <= 1))

    I was just curious if this is correct? Thank you for your help!

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

    Can the Dining Philosophers problem be implemented dynamically?

    Posted: 07 Apr 2019 08:35 PM PDT

    Can you implement it in such a way that philosophers can leave or come at the table at any time, as long as they're not in the action of eating or talking?

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

    Help me Please (C program)

    Posted: 07 Apr 2019 07:52 PM PDT

    Question:

    WRITE A PROGRAM that counts the number of negative values, the number of positive

    values and the number of zeros in a float array.

    in C

    I have no idea how to do it, please help me:(

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

    How do you give the rvalue generated by a constructor the lifetime of an lvalue?

    Posted: 07 Apr 2019 05:34 AM PDT

    while(model.condition) { auto data = yield_data(); auto _= manipulate(model, data); model.get_info(args); } 

    I have an RAII object of type manipulate, whose destructor undoes the mutation it causes when it falls out of scope, much like std::lock_guard. The problem is that the user has to type auto _= or the destructor will get called before model.get_info(); I don't like that the user has to type auto _=. Why would a user think to create an object that is never used?

    My first idea was to make the constructor [[nodiscard]]; but constructors have no return values. Is there a way to tell the compiler that manipulate rvalues should have lvalue lifetimes?

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

    Making the switch from Cloud 9 to Amazon AWS Cloud 9 and need help with Git Hub

    Posted: 07 Apr 2019 05:08 PM PDT

    I already had my website linked with Git Hub and I have since transferred my files from Cloud 9 to AWS (since Cloud 9 will be shut down by the end of the year). I had to reinstall some gems and wanted to make sure my Git Hub was linked correctly.

    First off, how do I have a separate Git Hub repository or whatever for different websites? I went to GitHub and it seems like my uploads from both websites I've been "git push origin" ing are under the same name. How can I go about transferring what I have into a new project/repository name to make sure they stay separate?

    Also, how can I verify that Git Hub is linked successfully...and that my website is uploaded successfully? What is the best way to test this?

    Thanks for all your help!

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

    Converting c++ to f# HElp

    Posted: 07 Apr 2019 04:48 PM PDT

    Can some one please help me covert this code to f#?

    #<include stdio.h>

    #<includestring.h>

    int digit(char);

    int main(){

    char roman_number[1000];

    int i=0;

    long int number =0;

    printf("enter any roman number(valid digits are

    I, V, X, L, C, D, M): \n");

    scanf("%s",roman_number);

    while(roman_number[i]0{

    if(digit(roman_number[i])<0){

    printf("invalid roman number:%c",roman_number[i]);

    return 0;

    }

    if((strlen(roman_number) -i)>2{

    if(digit(roman_number[i]<digit(roman_number[i+2])){

    printf("invalid roman number");

    return 0;

    }

    if(digit(roman_Number[i]) >= digit(roman_Number[i+1]))

    number = number + digit(roman_Number[i]);

    else{

    number = number + (digit(roman_Number[i+1]) - digit(roman_Number[i]));

    i++

    }

    I++;

    }

    printf{"its decimal value is: %d",number);

    return0;

    }

    int digit(char c ) {

    int value =0;

    switch(c){

    case 'I': value = 1; break;

    case 'V': value = 5; break;

    case 'X': value = 10; break;

    case 'L': value = 50; break;

    case 'C': value = 100; break;

    case 'D': value = 500; break;

    case 'M': value = 1000; break;

    case '\0': value = 0; break;

    default: value = -1;

    }

    return value;

    }

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

    How to calculate average throughput of a “Circuit-Switching” based network?

    Posted: 07 Apr 2019 04:30 PM PDT

    I need to learn how to calculate the average throughput of data without knowing the user count. I'm posting my homework question below.

    There are two routers named S1 and S2. The bandwidth of the link connecting the two routers is 100Mbps. The bandwidth of the links that connect users to the routers is 10Mbps. The users connected to the S1 router are always sending data to the users connected to the S2 router. All S1 users generate 1Mbps traffic on average. From time to time, the traffic generated by S1 users reach up to 10Mbps instantaneously. If circuit switching is implemented, what is the average rate of data transfer on the network? Why?

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

    I've been trying to debug this issue for hours, I'm so baffled by why this is happening and no one's responded on Stack Overflow so I'm gonna post here too, if anyone can even point me in the right direction it would be massively appreciated

    Posted: 07 Apr 2019 03:43 PM PDT

    Copy paste from StackOverflow:

    My main form 'frmMenu' acts as the home UI menu form which has a panel that docks a few other child forms within an MDI container and buttons on the side to change between child forms. My primary child form 'frmEquipment' has a Listview 'lstBasket' which acts as a basket that is filled with whatever the customer wants to purchase.

    On the 'frmEquipment' form, you can browse to choose an item you want and when you select an item it opens a new form 'frmEquipmentWindow' which displays more information about the item along with a picture. Here they select how many of the item they want and when confirmed it is then sent back into the Listview where the name, quantity, and price are added accordingly.

    Note: before the item is added, there is a check to make sure the item isn't already in 'lstBasket' to prevent clashes with quantities. Next to 'lstBasket' there is a label 'lblPrice' and any time a new item is added or changed it updates with the basket price

    The first time I run the program, the code runs good and my functions to change quantity, add new items, void items all run smoothly. So the problem isn't directly in how I'm adding or changing items in 'lstBasket'.

    Let me explain where the problem occurs:

    If I change what child form I'm using in 'frmMenu', let's say to 'frmAdmin' and then back to 'frmEquipment'; when I try to add an item again, it all confirms like normal and 'frmEquipmentWindow' closes (signifying it added to 'lstBasket') yet 'lstBasket' is displaying no data.

    Even though no data is being displayed, if I try and add the same item my validation check will come up telling me the item is already in 'lstBasket' and will not let me add it. However, 'lblPrice' doesn't apparently update and stays on £0.00 ???

    I've seen other people say they've had issues with View.Details not showing data but I haven't found a single fix for the issue across multiple posts. I'll post as much code as I think is relevant but please ask if you want to see more.

    //The code from frmEquipmentWindow that updates the ListView frmEquipment form = (frmEquipment)Application.OpenForms["frmEquipment"]; if (form.lstBasket.Items.Count != 0) { for (int i = 0; i < form.lstBasket.Items.Count; i++) { string shortName = form.lstBasket.Items[i].SubItems[0].Text; if (shortName == lblBrand.Text + " " + lblName.Tag.ToString()) { MessageBox.Show("You already have that item in the basket"); basketCheck = true; return; } } } if (basketCheck == false) { DialogResult answer; double totalPrice = itemPrice * temp; answer = MessageBox.Show("The total price is £" + totalPrice.ToString("0.00") + " for [" + temp + "] " + lblName.Text, "Are you sure you want to add this to your basket?", MessageBoxButtons.OKCancel, MessageBoxIcon.None); if (answer == DialogResult.OK) { form.lstBasket.Items.Add(lblBrand.Text + " " + lblName.Tag.ToString()); form.lstBasket.Items[form.lstBasket.Items.Count - 1].SubItems.Add(temp.ToString()); if (priceCheck) { form.lstBasket.Items[form.lstBasket.Items.Count - 1].SubItems.Add("£" + totalPrice.ToString()); } else { form.lstBasket.Items[form.lstBasket.Items.Count - 1].SubItems.Add("£" + totalPrice.ToString() + ".00"); } form.lstBasket.View = View.Details; form.updateBasketPrice(); GlobalVariables.itemsInBasket = true; this.Close(); return; } else { return; } } 

    I don't declare the ListView in code but it is generated in the Designer class for the form:

     // // lstBasket // this.lstBasket.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.clmN, this.clmQ, this.clmP}); this.lstBasket.FullRowSelect = true; this.lstBasket.Location = new System.Drawing.Point(739, 117); this.lstBasket.MultiSelect = false; this.lstBasket.Name = "lstBasket"; this.lstBasket.Size = new System.Drawing.Size(303, 379); this.lstBasket.TabIndex = 5; this.lstBasket.UseCompatibleStateImageBehavior = false; this.lstBasket.View = System.Windows.Forms.View.Details; this.lstBasket.SelectedIndexChanged += new System.EventHandler(this.lstBasket_SelectedIndexChanged); // // clmN // this.clmN.Text = "Name"; this.clmN.Width = 156; // // clmQ // this.clmQ.Text = "Quantity"; this.clmQ.Width = 65; // // clmP // this.clmP.Text = "Price"; this.clmP.Width = 85; 

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

    How many monitors do you use? What sizes / types are your favorites?

    Posted: 07 Apr 2019 02:45 PM PDT

    I'm currently using a 15" mb pro and I constantly have to minimize and resize windows for a decent workflow so I decided to get monitors to make my life easier. I just wanted to post here to get hear some opinions before I buy. Also hoping to hear some thoughts on regular vs curved monitors if anyone can give some insight into that.

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

    Is there a list of free programming related cloud services?

    Posted: 07 Apr 2019 01:43 PM PDT

    Im not thinking educational sites or free / open source APIs & libraries , im thinking more in lines of:

    • onlinegdb which is a free online compiler
    • github pages for free hosting
    • google collab offering free gpu & tpu for training your python machine learning model
    • mongodb's free tier (200mb mongodb database)
    • AWS lambda free tier
    • google drive, dropbox, and other free storage

    and other similar cloud services which you usually need to pay for (hostings, storage, processing intensive tasks.. ).

    Ive found this: https://dev.to/sahilrajput/useful-websites-for-programmers-36k but its mostly APIs and libraries, but I'm looking more for cloud services.

    Bonus points if there are APIs to use this services programatically, and the service is reliable (eg no shifty 'FREE HOSTING' which then terminates your site because you get like above 5 visitors a day).

    Main desire for this is that I'm fascinated by making it possible for anyone with just an internet connection (meaning possible with mobile too) to do great things for free (eg make a website and host it for free or program in python and use the colab's free GPU and Drive as storage).

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

    How to handle software licensing? / Opinion on License Spring?

    Posted: 07 Apr 2019 01:40 PM PDT

    A few years ago, I made a little program to automate much of my bookkeeping and it has made my accountant's life so much easier during tax season that he told me a few days ago that he wants me to sell it to his clients.

    It caught me by surprise, I'm usually all for open-source and never thought I'd sell any app, but if he's going to profit from it, then I should profit as well (he hasn't lowered my rate, and if he gets done faster he can take on more clients, no?).

    My first thought was that I'd need licensing, otherwise it's unlikely that I'll sell more than 1 copy ;). I have no experience with this at all so I'd like some input. So far this is what I've got:

    • 2FA-style in-house licensing. Customer calls me when he's ready to activate, he gets a code on his screen generated from the current time and I give him the code that unlocks the program. The problem with this is that it requires me to be available and have access to my computer when they call.
    • Using a free licensing service such as License Spring. I'd rather go that route because it's more of a set it and forget it approach. I give the customer a license key when he buys it and License Spring makes sure it's only activated on 1 PC at a time. Too good to be true?

    What would you do? Do you have suggestions for other methods or alternatives to License Spring?

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

    Need some advices and tips

    Posted: 07 Apr 2019 01:37 PM PDT

    Hey guys!

    I started to learn coding for about 5 days now with the youtube channel called CodingTrain.

    My question is:

    Where can I get some beginner projects for exercies or something to improve my low level skills in programming?

    Here's a link. This is my first game. It is not finished yet. Im thinking about what should i add in it. Maybe pause option?

    https://editor.p5js.org/danikasz/full/H7RYUkA5S

    You control the white circle with arrow keys. Your goal is to get the yellow circle (score). The game count how many scores you collected. The gray circle is some kind of an enemy. If you touch it it set your streak to "0" and teleports you and itself away in random location. The blue rectangle is a teleport. If anything touches it it teleports the object somewhere randomly. You also have a highscore which contains the highest streak you ever had. I added a reset button if you want to reset the whole game.

    It would make me happy if i get any review and advice or just some kind of comment.

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

    My application won't use the DLL in the folder, and keeps trying to use the one in /SysWOW64.

    Posted: 07 Apr 2019 09:36 AM PDT

    My application won't use the DLL in its folder, and keeps trying to use the one in /SysWOW64.

    Even after write protecting it to ensure it's not getting removed (it's not). I need it to use my modified DLL for this application only, but no matter what I do it won't. Running the program after build and running in the VS debugger gives the same result:

     'hl.exe' (Win32): Loaded 'C:\Windows\SysWOW64\opengl32.dll'. Cannot find or open the PDB file. \ 

    EDIT: u/maxvollmer Is actually our project leader, he's posting below. in case you can't scroll down:

    " The executable is third party and closed source. The custom opengl32.dll is an interceptor that allows running the original game in VR. I wrote it. It is 32 bit and works perfectly fine on every system except OPs. I tried helping OP, but am at a complete loss, everything checks out and the custom opengl32.dll should be loaded - but it isn't. I'll stay around to provide information on the technical level, while OP will be available to answer questions related to OPs system. "

    EDIT2: Turns out the reading of the wrong DLL wasn't causing my crash as the application runs now. We still have the bug though...

    submitted by /u/-Chell
    [link] [comments]

    Why does my Qt app ignore the setting of applicationDisplayName?

    Posted: 07 Apr 2019 09:17 AM PDT

    Hi everyone,

    I am running a small app on KDE Plasma 5 created with Qt and the KDE framework. Almost everything works like a charm, just one part doesn't work. I just cannot set the application display name. I have the following code:

    int main(int argc, char **argv) { QApplication application(argc, argv); KLocalizedString::setApplicationDomain("blender-render-control"); KCrash::initialize(); KAboutData aboutData(QStringLiteral("blender-render-control-center"), i18n("Blender Render Control Center"), QStringLiteral("1.0"), i18n("A simple application to control the blender render control server"), KAboutLicense::Custom, i18n("Copyright 2019, Knerd <knerd@knerd.knerd>")); aboutData.addAuthor(i18n("Knerd"), i18n("Author"), QStringLiteral("knerd@knerd.knerd")); aboutData.setOrganizationDomain("knerd.knerd"); aboutData.setDesktopFileName(QStringLiteral("knerd.knerd.blender-render-control")); KAboutData::setApplicationData(aboutData); QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("knerd.knerd.blender-render-control"))); application.setApplicationDisplayName(i18n("Blender Render Control Center")); application.setApplicationName(i18n("Blender Render Control Center")); QCommandLineParser parser; aboutData.setupCommandLine(&parser); parser.process(application); aboutData.processCommandLine(&parser); auto *window = new MainWindow(); window->show(); return QApplication::exec(); } 

    From reading the docs and checking some examples, this should set the application title in my KDE environment. But it doesn't, the application name is the name of the executable.

    Is this a bug in KDE or am I doing something wrong?

    Related Stackoverflow question: https://stackoverflow.com/questions/55554757/qapplicationsetapplicationdisplayname-not-always-falls-back-to-qapplicationa

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

    Unable to remove event listener on document

    Posted: 07 Apr 2019 12:21 PM PDT

    I'm unable to remove a named, unmodifiable (const) function from an event listener.

    someFunction() {

    const listener = () => {

    console.log('should not run');

    }

    document.addEventListener('touchmove', listener);

    document.removeEventListener('touchmove', listener);

    }

    When the code runs, the listener is added but not removed.

    We use gatsby for our project, and deploy to netlify for testing. This bug does not occur when I develop on localhost, but does occur on netlify and on Prod.

    My guess is that somehow gatsby changing something to make it impossible to remove listeners on the document, but I've never heard of something like this being possible!

    This function is unmodifiable, and there are no options being passed in the third parameter, so I would expect this listener to be removed. It does not. This is the only time I'm referencing the function listener, I created it specifically to isolate the problem.

    What I would really appreciate is some insight on why this could be happening, when I look online at why eventListeners can't be removed, it's always because the function passed is anonymous or was not the same, this is a named const, only referenced once, so it should be the exact same on removeEventListener.

    To clarify:

    The code I have linked is representative of the code I am running, there aren't any extra things going on within someFunction, I removed them all for debugging purposes (to isolate the problem)

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

    How to Start A Project ?

    Posted: 07 Apr 2019 02:19 PM PDT

    So i'm a second year CS student trying to create a Project for experience purposes .

    My project requires every feature (Data base , sockets , threads and GUI ) therefore i will make my project via Visual Studio C# .

    I need to know how should i start it . should i first sketch my idea in paper and then execute it or just go in ?

    Should i start with the data base or the sockets .

    any INFO would be appreciated and if there is a Video or something that also would be great .

    thank you in advance .

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

    [Karel] Please help me with my computer science module!!!

    Posted: 07 Apr 2019 09:27 AM PDT

    Hello! So I was tasked to complete this challenge by my prof and I am going crazy because I have absolute 0 programming background and skills. I tried my very best but Karel moved in every way I wanted but did not pick up any beepers at all.

    Anyone that is fluent in Karel please do pm me your email address and I'll email you the photo of the challenge. Any help would be very much appreciated from a poor communications student who has to take computer science as a pre-requisite module ;~;

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

    Platform Dependent and Platform Independent

    Posted: 07 Apr 2019 08:53 AM PDT

    Why is C platform dependent and java platform independent ? Is it beacuse java creates its own operating system??

    Also what is write once, run anywhere?? Isn't it true in C also....like you write code once but can run same code on linux,windows or mac???

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

    Have you read through ALL the git commands?

    Posted: 07 Apr 2019 07:03 AM PDT

    I started watching this video on how the handmade heroes guy uses git. He made it sound like it was completely normal to read through all 300,00+ commands git has. So is this something most devs do or is this guy just going a bit overboard?

    Edit: egg on my face I think the video was meant as an April's fools joke

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

    Reading specific string inputs from user help (in C)

    Posted: 07 Apr 2019 05:24 AM PDT

    Hello - Basically, what I want the user to type:

    h X,Y (e.g h 5,20) [exactly this format, h then space then integer then comma then integer)

    So far I've created this piece of code:

    char input[5]; scanf("%[^\n]%*c", input); while ((input[0] != 'h' && input[0] != 'H') || (input[1] != ' ') || (isdigit(input[2] == 0) || (input[3] != ',') || (isdigit(input[4]) == 0) scanf("%[^\n]%*c", input); 

    If I want to get the numbers now, I just do: input[2] - '0' and get it.

    Now the problem is, I don't know what to do if the number is a two digit one. Like, if the user types h 10,10

    How do I get the value? Also, what do I need to do besides change the array from input[5] to input[7]?

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

    C++ project

    Posted: 07 Apr 2019 02:20 AM PDT

    What's wrong with the code?

    l am trying to make the program read from the file and then assign the values to different arrays.

    #include <iostream>

    #include <string>

    #include <fstream>

    using namespace std;

    int main()

    {

    const int isize=2; 

    string name\[isize\]; int id\[isize\],maths\[isize\],english\[isize\],science\[isize\]; long double averagescore; char gender\[isize\]; 

    ifstream students; [students.open](https://students.open)("stut.txt"); int i=0; 

    while(!students.eof())

    {

    students>>id\[i\]; students>>name\[i\]; students>>gender\[i\]; students>>maths\[i\]; students>>english\[i\]; students>>science\[i\]; i++; 

    }

    cout<<id[0];

    }

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

    No comments:

    Post a Comment