• Breaking News

    Sunday, January 20, 2019

    [Question] How do I make an executable that just runs a basic python or terminal command? [See post for details and context] Ask Programming

    [Question] How do I make an executable that just runs a basic python or terminal command? [See post for details and context] Ask Programming


    [Question] How do I make an executable that just runs a basic python or terminal command? [See post for details and context]

    Posted: 20 Jan 2019 04:16 PM PST

    So I'm running Rasbpian on a RPi 3 b+, and I'd like to create a program that literally opens up a website. So the objective is to have an icon I can click on which opens my default web browser and launches a particular website.

    In python I can do

    >>> import webbrowser

    >>> webbrowser.open('http://example.com')

    Or in terminal, simply

    open http://website.com

    But that's the extent of what I know how to do right now (I'm very much a beginner).

    I don't know whether to use python or just terminal for this, I realise it probably makes little difference. The main thing I need to know is how to turn these into executables that I can put on my desktop/launch-bar/menu etc... I'm pretty sure I will need some extra code/commands to tell the program to literally "open this in terminal and execute the following:", but I don't know what that command would be, and I don't know what I should save the text edit as (.bat, .exe?) once the code is all there. Finally I don't know what to open the file with once it's done, do I tell it to launch it with terminal by default or something?

    Sorry for the absolute noobage. I'm new to programming, new to raspberry pi, new to Linux, new to driving a computer solely via terminal....

    Thanks in advance, I appreciate all assistance.

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

    [Java] Really Basic Calculator Not Working. Would appreciate some help

    Posted: 20 Jan 2019 11:48 AM PST

    So basically, I've started learning Java through some YT tutorials. Now I've decided to try and make my own Java program, which is a basic calculator. Basically you start the program, it asks you to enter a number, then an operator (*,-,+,/) and your second number. I'm sticking to Integers for the time being. My problem is, whenever I run my code, let's say with "1 + 5" I get 0 as my result. Like I said I'm new to Java and would appreciate if someone could check out my code.

    package testProjectOne; import java.util.Scanner; public class Test { // VARIABLES static Scanner reader = new Scanner(System.in); static int num1; static int num2; static String oper; static int result; // END VARIABLES public static void main(String[] args) { System.out.println("Enter a number: "); num1 = reader.nextInt(); System.out.println(""); System.out.println("Enter an operator (/, *, -, +): "); oper = reader.next(); System.out.println(""); System.out.println("Enter your 2nd number: "); System.out.println(""); num2 = reader.nextInt(); System.out.println(eval(num1, num2)); } private static int eval(int num1, int num2) { if (oper == "+") { result = num1 + num2; } if (oper == "-") { result = num1 - num2; } if (oper == "/") { result = num1 / num2; } if (oper == "*") { result = num1 * num2; } return result; } } 

    Here's a picture of my output.

    https://imgur.com/a/ywf9Z7Q

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

    Can maven be configured to only run unit tests that depend on something that changed?

    Posted: 20 Jan 2019 07:55 PM PST

    At my work, we have been using ant for building for years and like decent developers, we started out making good unit test. But the unit tests eventually grew and took long enough to execute that it was decided to no longer make them automatic after building. It would only be required prior to committing. Eventually that lapsed and people stopped running them altogether. Developers would argue that they don't have time, and so on. I want to reverse this.

    What I would like to do is possibly switch to maven and configure it so that only unit tests necessary run after a given change rather than EVERY test. So that if you have 1000 test, but only 5 depend on a given component (either directly or indirectly) then it only runs those 5, not all 1000. That way it is still fast, and useful.

    Is this possible?

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

    Basic Echo Implementation in Rust

    Posted: 20 Jan 2019 06:02 PM PST

    I'm looking for any possible help implementing the unix command echo in Rust. This is what I have so far but it's just basic functionality. I also need to implement the -n flag and -e flag that can handle the newline, tab, and backslash escapes. For all others it should panic.

    use std::env;

    fn main() {

    // starts command line arguments after name of program

    let mut input = env::args().skip(1);

    // check for next value in command line argument

    if let Some(arg) = input.next() {

    print!("{}", arg);

    // loops through remaining arguments, prints a preceding space

    for arg in input {

    print!(" {}", arg);

    }

    }

    println!();

    }

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

    Best way to track which random values in a series(1-1000) have been selected

    Posted: 20 Jan 2019 05:18 PM PST

    Say you have 1-1000 and want to o display each number randomly but also display every number with no repeats. What's the best way to do this?

    Should you store selected values in an array then loop through array each time before you select the next random number in the set (1-1000)

    Taking into account this is for a phone app with lists up to around 1500 so the sequence will happen each time a button in clicked so performance matters etc.

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

    atom vs eclipse?

    Posted: 20 Jan 2019 08:09 AM PST

    Somebody I know is getting into Java for the first time and was asking me for advice on IDEs. Somebody else suggested Atom to him. I don't know squat about Atom, as I used Eclipse back when I did java development. I don't want to suggest Eclipse merely because that is what I am used to. Is Atom good for Java? Does it have a debugger, code completion, and all of that stuff?

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

    Wrong Outputs And Confused On How To Restart Program In A Loop (C++)

    Posted: 20 Jan 2019 02:52 PM PST

    So here's the code. I'm not going to explain the program here since I wrote a brief description about it in the code itself.

    https://pastebin.com/9RhCn5NA

    So here are the two problems I'm trying to solve.

    1. The first problem is an outputting problem. At the very end, I ask the user if they'd like to restart the program. If I input Y, it goes down the Y if statement. However, when I input N, the cout statement in the if Y statement triggers. Why is that?
    2. The second problem is that I'm not sure how to restart the loop/the whole program. I thought if I reset the loop parameters back to the original value (stop = false), it would make the loop start again. However, that is not the case, and it just ends the program after I input something.

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

    Pc specs for coding

    Posted: 20 Jan 2019 01:25 PM PST

    It's almost time to replace our 6 year old dev computers. I've got some thoughts on what to replace them with, but wondered what other people felt was important.

    Currently we went with desktops, which are faster and cheaper than laptops. If we work from home we just remote desktop into our machines from our home PC's. This works for us, but what are people's thoughts on desktops vs laptops? Obviously with a dock at the office.

    We do windows development, visual studio, Sql server etc. We're also getting into mobile development so running mobile emulators is becoming more common.

    I don't really know what to suggest for a CPU, maybe something with integrated graphics so we don't need a video card.

    Memory I'm leaning towards mor is better, possibly up to 32gb, with 16 being the minimum.

    So anyway, anyone got some suggestions based on experience?

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

    [QUESTION] Scraping prices from several online stores

    Posted: 20 Jan 2019 12:05 PM PST

    So I'm developing an app in which you can add an item from an online store and it notifies you when it's on sale. This idea is based on Shoptagr.

    Basically, it scrapes its price, stores it, and rechecks everyday until the price is lower.

    Now this can be done quite easily using Python and BeautifulSoup. The problems is that different sites use different HTML class namings, so you need to add a line for every site, limiting the app.

    Is there any way to create an universal approach so it detects the price in every store?

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

    Displaying previously input data, I get a mysterious "35" instead

    Posted: 20 Jan 2019 11:58 AM PST

    I got a homework assignment to make a database of sorts with the user inputting the data into various arrays. I did it, all good and dandy, even passed the plushy cat test (don't have a rubber duck), but when I ran it, I encountered two problems.

    1. It skipped over an input line randomly. This was fixed by an unnecessary getline.
    2. When I want to display the data in a table, or any way really, instead of the data I asked for, it just writes 35. There's zero reference to 35 in my code.

    The code itself looks like this (relevant bits only):

    #define MAX 100 {...} int main() { {..} //Flag means something is wrong, like the ID being out of scope or the list already being maxed out. if (!flag) { id[row] = anna; cin.getline(comp[row], MAX); //This line has no purpose, but it doesn't work properly otherwise. cout << "Player name: "; cin.getline(player[row], MAX); cout << "Current team of player: "; cin.getline(team[row], MAX); cout << "Role the player currently assumes: "; cin.getline(role[row], MAX); } } while (flag); row++; cout << endl << "Entry addition complete. Please press any button to return to the main menu."; system("pause"); break; } }; {...} case 5: { cout << endl << "Listing all entries."; cout << printf(" %-4s| %-10s| %-7s| %-5s|\n", "ID", "PLAYER", "TEAM", "ROLE"); int i, j; for (i = 0; i < MAX; i++) { for (j = 1; j < row; j++) { if (id[j] == i) { printf(" %-4s| %-10s| %-7s| %-5s|\n", id[j], player[j], team[j], role[j]); } } } cout << "Listing entries complete. Returning to main menu."; system("pause"); break; }; 

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

    "Circle of best-fit" SAS Programming

    Posted: 20 Jan 2019 11:14 AM PST

    I am working on a project where I find the circle of best fit for my free-hand-drawn circle. The article https://blogs.sas.com/content/iml/2015/06/08/fit-circle.html#prettyPhoto is where I am taking the code from. Everything is working out great, except I'm not sure where I can find a measure of error for my circle. In the code, I'm thinking that it's the line "start ObjF(p)" which makes the variable F, a measure of error, the "objective function."

    The value for Objective function: https://imgur.com/a/S5lDdYb

    Is this a measure of the total sum of squares? Any help is appreciated. Thanks!

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

    [Question] How can I do this?

    Posted: 20 Jan 2019 11:08 AM PST

    Hello everyone!

    My teacher gave us homework about recursive methods and while I do understand that most if not all of them are static I was able to solve the first problem which was:

    Recursive static method called sumatoria, it returns an int and receives as parameter another int. It should start the operation from 0 until the parameter that received. Sumatoria(10) returns 55 and the code does that.

    The second one is a little bit tricky therefore my questions.

    Método recursivo estático llamado base10a2, el cual recibe un entero base 10 y regresa un String con la representación del entero pero en base 2. Por ejemplo, base10a( 123 ) debe regresar "1111011".

    TRANSLATION: Recursive method called base10a2. It receives an int base 10 (how do I define this?), it returns a String with the representation in base 2. (How do you use two different base in the same method?)

    Finally how do I translate a int to a String using the base10a2 method? Is there something already implemented in Eclipse?

    Thank you and Best regards!

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

    Image processing in C#.

    Posted: 20 Jan 2019 10:34 AM PST

    I am writing an image processing application in c# for my capstone and I was wondering if I'm allowed to use things like OpenCV or the c# equivalent libraries in my project. Would this be allowed since I'm using libraries of code that other people have written? I mean obviously I'm writing lots of my own code as well. I'm just not sure of the legal implications. Thanks.

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

    Javascript: Unknown Array Behaviour

    Posted: 20 Jan 2019 10:15 AM PST

    I am trying to copy an array into two others. The first is has a copy of each element added from the original. The second adds a copy from the original with the first element in each original sub-array incremented by 1.

    var original=[[1,2],[3,4],[4,5],[6,7]]; var newFirst=[]; var newSecond=[]; //Copies of original to avoid pass by reference. var array=original.slice(); var array2=original.slice(); for(i=0; i<original.length; i++){ newSecond.push(array[i]); } for(i=0; i<original.length; i++){ array2[i][0]=array2[i][0]+1; // Error could be here. newFirst.push(array2[i]); } console.log(JSON.stringify(newFirst)); console.log(JSON.stringify(newSecond)) 

    Whilst debugging I noticed that in the second for loop, newSecond was being changed by the increment assignment on line 13 (first statement in second for loop). I was under the impression newSecond was completely separate.

    When I go to console log the two arrays, I get the exact same array for each. Perhaps I'm missing something obvious and I'm just not seeing it or this is an interaction I am aware of. I tried to pass by value via the splice method.

    In case you are wondering I am pushing elements because the arrays may contain elements beforehand.

    Thanks for your time.

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

    Is there a way to find what type of comment the file uses given file type?

    Posted: 20 Jan 2019 09:40 AM PST

    I have hit a road block in the creation of a program to count lines of comments. The requirements of the program is that it has an input of any file type and an output of how many different comments there are in the inputted file.

    E.g.: Input: file.java Output: This file contains: 3 commented lines 

    I believe there is a way to find what character starts a comment in a file type but I'm having no luck finding anything online. Is there some sort of metadata accessible that I am unaware of?

    The reason I believe there is a way to do this is because of this line in a program available online called CLOC.

    Can read language comment definitions from a file and thus potentially work with computer languages that do not yet exist.

    I am working in java currently but not opposed to switching to another language that can solve this issue.

    submitted by /u/7chris71000
    [link] [comments]

    Making queued uploads continue even after page navigation in Angular

    Posted: 20 Jan 2019 03:27 AM PST

    Hello, and good day. Is it possible to make uploads continue even after page navigation? I am using ng2-file-upload and I want to make it possible to upload multiple files even after one has navigated away from the upload page. I have tried it, but only the most recent upload gets uploaded. I think the other web service calls get invalidated by the most recent one. I can't figure out how to make the calls asynchronous since I only provide the endpoint to the library. If anyone can point me in the right direction, it would be appreciated. Thanks!

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

    how would i go about making a panel of links?

    Posted: 19 Jan 2019 11:50 PM PST

    I'm not sure if that's the correct phrase, but if you visit ESPN.com, along the banner there are links labeled "NBA" "NFL" "MLB" where a click on them leads to that particular page. How would I go about programming something like that?

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

    Need help completing an assignment!

    Posted: 20 Jan 2019 06:45 AM PST

    No comments:

    Post a Comment