• Breaking News

    Friday, April 19, 2019

    If unit tests fail, the user's build should fail Ask Programming

    If unit tests fail, the user's build should fail Ask Programming


    If unit tests fail, the user's build should fail

    Posted: 19 Apr 2019 01:02 PM PDT

    I am not a developer myself, but am having an issue with some devs in my team that are pushing changes without making modifications to pass the unit tests. We use BitBucket as our repo; is there a way to make their build fail if their unit tests fail? Are there any free tools that would help with this?

    We also need to ensure that every feature has the cucumber code written with it (and a Ruby automation test). How can we effectively monitor this? Not sure what solutions/tools are available.

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

    Best location for C/C++ related jobs? DC vs. Triangle/Raleigh?

    Posted: 19 Apr 2019 11:48 AM PDT

    Family is moving to NC. Been longtime MD resident. Have very short commute to DC. I'm deciding between getting a job in DC or moving to be with family in Cary and getting a job there. I am proficient in C/C++ with comfort in Java, Python, and C#. Does anyone know which area is better for this?

    I am also looking for which place has better internet (hoping for fiber but no big deal) and which will escalate my career path further over time. I am looking into contracting software engineer positions (endgame software management or other leadership position). Hoping to land six figures within 7 years. Sorry if this is not right sub or if question dumb. I just wanted to ask actual programmers their experience in the areas.

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

    What programming language is this?

    Posted: 19 Apr 2019 09:15 PM PDT

    I'm trying to figure out what language some code is that I found in a game.

    As an example, the variable declarations are done like this:

    create ObjHandle gModelHandle

    create xyz gModelLoc

    and a ridiculous number of declarations later, they declare several arrays like this:

    make string stringArray6[6]

    and they declare functions like this

    FUNCTION fInitModelPlacement()

    I've never seen anything like this, and though it's pretty easy to decipher, I'm just wondering what it is. I'm thinking there's some headers they're calling from that were just not included (since this is just left over on a ps2 disc) but the includes don't have anything like that, just

    include "DTypes.ice" and I know what that does already, and it's certainly not a normal header.

    Hope someone can help, thanks!

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

    Need Help with C Program

    Posted: 19 Apr 2019 08:10 PM PDT

    My assignment is to create a menu to convert Fahrenheit to Celsius and vice-versa. It asks user to enter their option, temperature and then displays conversion, then go back to the main menu (supposed to use do...while to do this) however I can't figure out how to loop back to the menu using do...while. I also can't use any global functions or "goto". I'm very new to this and I'm having a tough time. Can anyone help?

    Source code:

    #include <stdio.h> #include <stdlib.h> int main() { float f,c; int choice; printf("\n1: convert temperature from Fahrenheit to Celsius."); printf("\n2: convert temperature from Celsius to Fahrenheit."); printf("\n3: exit menu."); printf("\nenter your choice (1, 2, 3): "); scanf("%d",&choice); do switch(choice) { case 1: printf("\nenter temperature in Fahrenheit: "); scanf("%f",&f); c= (5.0 / 9)*(f - 32); printf("temperature in Celsius: %.2f",c); break; case 2: printf("\nenter temperature in Celsius: "); scanf("%f",&c); f= (9.0/5) * c + 32; printf("temperature in Fahrenheit: %.2f",f); break; case 3: exit(0); break; return (0); } while(choice != '3'); } 
    submitted by /u/MooseLimit
    [link] [comments]

    C# input string to a formula that can be evaluated?

    Posted: 19 Apr 2019 04:23 PM PDT

    Hi, I was working on a personal project for learning purposes and ran into a problem. I making an equation solver whether it be an ODE or just regular set of equations eg/ x^2 and y = x. I started this in c++ but decided to move onto C# to make a GUI and later I'll translate the solver to C#. I have a WPF that I made with a rich textbox for people to write into, but can't figure out how to get the equations from string to a double from this. This is what I currently have in c++ to solve the equation :

    void Solver::E_Solver() { //Variables const double Tolerance = 0.001; double del_1 = 0; //the furthest left difference in y values double del_2 = 0; //the furthest right difference in y values double F1 = 0; //function 1 double F2 = 0; // function 2 double Initial_guess = 0; // the initial guesses that someone inputs double x = 0; //used to output the final x value and store incriments const int step_setter = 1000; //divides the count to set the incriments size int count = 0; //is a count of how far off you are from the guessed value bool break_out = false;// tells you to break out of the while loop bool reverse = false; // tell the program to start going in reverse std::cout << "Enter your guess : "; std::cin >> Initial_guess; while (break_out != true) { //go to the right from the initial guess if (reverse == false) { //set the value for x x = (Initial_guess) + (static_cast<double>(count) / static_cast<double>(step_setter)); //put in your functions here F1 = 3*x - 2 ; //y = 3*x - 2 F2 = x*x; //y = x^2 //calculate the change at the front del_2 = abs((F2) - (F1)); //check if it's parallel if (del_1 == del_2 && count != 0) { std::cout << "lines are parallel"; break_out = true; } //check if it should be going in reverse by comparing if the left gap is smaller than the right else if (del_2 > del_1 && count != 0) { //tell the program to go in reverse reverse = true; //set the value of count to 0 count = 1; //reset del1 and del 2 del_1 = 0; del_2 = 0; } //check if it's converged //going forward so you should compare del 2 else if (del_2 <= Tolerance) { //set the variable of the variables Solver::Set_x(x); Solver::Set_y(F1); //break out of the loop break_out = true; } else { //set the value of the one infront to the value of the one in the back del_1 = del_2; //increase the value of count count++; } }//end forward if //go in left from the initial guess else if (reverse == true) { //step backwards from the initial guess x = static_cast<double>(Initial_guess) - (static_cast<double>(count) / static_cast<double>(step_setter)); //enter your functions F1 = 3*x - 2; //y = 3*x - 2 F2 = x*x; //y = x^2 //del 1 will be smaller than del 2 since your stepping backwards so get del 1 del_1 = abs((F2) - (F1)); //check if you converged //Note* since going backwards you're using del 1 if (del_1 < Tolerance) { //set the output variables Solver::Set_x(x); Solver::Set_y(F1); //break out of the loop break_out = true; } //check if it's all imaginary roots by seeing else if (del_1 > del_2 && count != 1) { std::cout << "There is no non complex solution"; break_out = true; this->imaginary = true; } else { //store the current variable as the previous variable del_2 = del_1; //itterate the count count++; } }//end backward if }//end while loop }//end solver funciton 
    submitted by /u/_Spanish_Inquistion
    [link] [comments]

    Advice

    Posted: 19 Apr 2019 06:26 PM PDT

    I'm not a programmer and I'm not even sure I'm asking this in the right place – but hoping someone can help me.

    I want to create some code that will take example sentences from the dictionary (the ones that use a defined word in a sentence) and assemble a set number of these sentences into a paragraph. This would be a randomized selection generated by the program. This could then be repeated for different results each time.

    I'm a complete newbie, so I don't really know where to start (what program, how to define the variables etc) but I'm happy to put the effort in to learn – so any info about where to start would be greatly appreciated.

    Thank you for any help in advance!

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

    I'm new

    Posted: 19 Apr 2019 04:38 PM PDT

    Hi everyone

    I'm kinda new to programming and know a little but not much, and i would like to hear if any of you had some advice i could use

    Thanks

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

    Hows my pseudo code?

    Posted: 19 Apr 2019 09:42 AM PDT

    I'm learning python and lately I've been doing thought experiments to get better at thinking about problems like a programmer.

    ```

    Car Light Switch Pseudocode

    Define light Set light to false

    Define switch (0,1,2) Set switch 0

    Define door Set door to true

    If switch is 0 Then set light to false

    If switch is 1 Then set light to true

    If switch is 2 Then get door If door is true Set light to false If door is false Set light to true

    Ask user for input Go to line 12

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

    Which git GUI clients is most easy to use?

    Posted: 19 Apr 2019 01:40 PM PDT

    All functionality that is needed is to update local repo to the current state of the remote repo and push changes from the local repo to the remote repo.

    Edit1:

    I need software to support at least Windows and Mac.

    Edit2:

    Should work with self-hosted repos.

    Edit3

    The software should be free.

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

    Is HTTP the only network protocol that works automatically?

    Posted: 19 Apr 2019 12:50 PM PDT

    Heres some automatic HTTP code that works even in NAT addresses: https://github.com/bitletorg/weupnp

    If you claim some other general byte sending and receiving protocol, such as UDP, works automatically, show us the evidence as some code that uses it both directions automatically. Its not automatic if a user must log in to their router, since most users wont do that to try a new program.

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

    [HTML, Laravel] How to show and hide li elements?

    Posted: 19 Apr 2019 12:33 PM PDT

    Hi guys, I need your help. I am trying to show / hide the description of the tasks in my todolist when i click in the plus-circle icon and I'm not sure how to do it using laravel. And in a broader sense: Should I use laravel? Or some frontend library like jquery or vue? I know it's a small project but I'm a total newbie in laravel.

    This is my index.blade.php file:

    @extends('../layout') @section('content') <ul class="collection"> @foreach ($tasks as $task) <li class="collection-item">{{$task->title}} <a onclick="show" href="/tasks/{{$task->id}}/show"> <i class="right fas fa-plus-circle"></a></i> <i class="right fas fa-trash-alt"></i> </li> <li class="collection-item">Description: {{$task->body}} </li> @endforeach </ul> <a href="/tasks/create" class="btn btn-primary btn-lg m-1" role="button">Add task</a> @endsection 

    And this is my controller file:

    public function index() { $tasks = \App\Task::all(); return view("tasks.index", compact("tasks")); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view("tasks.create"); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Task::create(request(["title", "body"])); return redirect("/"); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Task $task) { return view("/tasks/{{$task->id}}/show", compact("task")); } 

    Thanks guys for all the help you could bring me. :)

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

    How many, and for how long and what bandwidth, simultaneous incoming HTTP connections will home internet connections normally allow without blocking you for "running a server without paying for business internet"?

    Posted: 19 Apr 2019 11:52 AM PDT

    First, its a net neutrality violation for any ISP to tell users what kind of messages to send to and receive from eachother, such as a contract which says no running servers which in technical terms means you cant receive messages except if you sent the first message to an address which would prevent any 2 of those addresses from contacting eachother since neither can send the first message without the other being a server. But since I have no control over that in my users ISP behaviors, I want to know what are their behaviors before I get much deeper into p2p network design.

    For example, using java weUPNP, each peer connecting to/from 100 other peers and sending many small messages between eachother many times per second. The messages are so small that the majority of the bandwidth would be http headers. Id prefer UDP but it seems to be blocked or unreliable or hard to get working or test. So Im asking what limits should I prepare for while designing?

    I know how to manually set up port forwarding for UDP using my routers password, but I only know how to automatically do HTTP (through NAT) using weUPNP. Since most people wont manually log in to their router to change settings to try a new program, that prevents most of my target audience, so I'm sticking to what can be done automatically.

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

    Best way to model a function that both writes and reads data?

    Posted: 19 Apr 2019 11:30 AM PDT

    Hey everyone,

    I have the following use case: I have to make queries to an API and cache the results in a local Mongo instance.

    The way I do this now is (pseudo-JS example for comprehensibility):

    function getStuff(key) { cached = getCached(key) if (cached) { return cached; } else { retrieved = queryAPI(key) doCache(key, retrieved) return retrieved; } } 

    This works, but seems kind of dirty, as the function is doing many things. Is there a better way to write this code?

    At some point, I may need to add yet another cache layer (Redis for the most frequently accessed items, Mongo for the rest and API for never-accessed). In this case it would get even more convoluted as it would have to hit each cache layer to look for the data, go deeper if not, and populate each cache layer on return.

    Thoughts?

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

    Why does increasing float precision decrease the precision in actual output ?

    Posted: 19 Apr 2019 02:29 AM PDT

    So I made a simple C program to calculate derivative of a function at a given point. It looks like this:

    #include<stdio.h>
    #include<math.h>
    double ln(float x){
    return log(x);
    }
    //This is our function f(x) = x^2
    float square(float x){
    return (x * x);
    }
    //Derivative takes a pointer to the function and a value
    //The function is whose derivative is to be calculated
    //The value x is the point at which derivative will be calculated
    float derivative(double (*function)(float), float x){
    double (*func)(float) = function;
    float dx = 0.001;
    float dy = func(x + dx) - func(x);
    return (dy / dx);
    }
    int main(){
    printf("%f\n", derivative(ln, 2.0));
    }

    So now my dx = 0.001 the output from the program comes out to be 0.49. This is decently close to the IRL expected value i.e. 0.5. However when I improve dx = 0.000001 the answer changes to 0.47 which deviates a wee bit further from the expected value.

    Normally if dx -> 0 we expect derivative to approach the IRL value but why did it diverge when I try to do it ?

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

    Getting a job in the US

    Posted: 19 Apr 2019 09:14 AM PDT

    Hi,

    I would love it if someone would have advice on how'd I get a a job in the US. I visited Seattle 6 months ago and I would really like to live there. I tried to get meeting with people in the industry. But no one was interested once they heard that I wasn't a green card holder.

    Anyone have any advice? What should my steps be? I'm a very productive web developer with 2+ years of experience with a bachelors in IT. Upper middle class European from a good country.

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

    I need a little help in printing out my hash table

    Posted: 19 Apr 2019 08:17 AM PDT

    • Code

    • Problem: My function prints out all the rows with every single word I have sent into the actual array. The problem is each linked list now points to NULL, landing me in seg fault land. How do I allleviate this problem?

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

    best way to extract fields from a line of text?

    Posted: 19 Apr 2019 06:43 AM PDT

    So I have this piece of text that I want to extract fields from:

    [Steam] Dead Island Franchise : Dead Island Retro Revenge $2.49, Dead Island: Riptide Definitive Edition $4.99, Dead Island Definitive Edition $4.99, Escape Dead Island $2.99 (Up to 80% off)

    Edit: More examples requested

    [Alllyouplay] Stellaris (75% off / £8.74 / €9.99 / $9.99)

    [GamersGate] South Park The Fractured But Whole (-80% | $10,80 / €10,80 / £9,00 w/ code), save 10% with the promocode BLOSSOM

    So I want to extract:

    • The text in the square brackets
    • The name of the game, very variable text here
    • The discount, could be multiple numbers
    • The prices, could be multiple prices
    • The url that this text links to

    What's the best way to approach this? I am trying to get some regex patterns going, but unsure if:

    • Regex is the best solution?
    • If i were to use regex, do you have a big regex string for to extract all the fields, or do you have smaller regex expressions for each field?
    • How do I approach the game's name, it's very variable text

    Any help would be appreciated

    submitted by /u/zinger-meal
    [link] [comments]

    How do you hard-quit a recursive function without goto?

    Posted: 19 Apr 2019 05:28 AM PDT

    I have a deep recursive function returning an int, where if there is user input, the result is not needed.

    I dereference and load an atomic boolean 'keep_going', which uses a goto that takes me outside the first function call directly to the bottom of the recursion stack. This prevents me checking the same flag thousands of times.

    I only call the recursive stack at one point in my code so it works great but it's so ugly.

    Goto is optimal and makes my intentions clear but lacks encapsulation. What are my options?

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

    Which tech stack to use for a physics formula/simulation software

    Posted: 19 Apr 2019 02:55 AM PDT

    I have a project idea for a physics formula/simulation software with an option to extend it with custom plugins. I'm currently thinking about the tech stack to use.

    Considering the users and their background, I'd say the main focus should be people in academia, who in my experience are quite familiar with Python, which means that the plugins could be written in Python. Since Python also has options to use GUI toolkits such as PyQt I though of using it as the main language for the Core, GUI and plugins.

    For the simulation part, I'm currently thinking 2d and 3d simulations. C++ could be used since it has various existing libraries in that field and is fast when it comes to large calculations of mathematical operations.

    A python library such as pybind11 could then be used to connect the two together.

    Does anyone have any experience with this type of software and has some input regarding the options of the tech stack that can be used?

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

    Should I use PHP to validate user logins or JavaScript?

    Posted: 19 Apr 2019 10:41 AM PDT

    Right now I have my PHP validating user logins/building the html and JavaScript altering the "feel" of the site, but I heard that it's better to use JavaScript for user validation because it's less load on the server?

    What are you opinions on this? Should I change my code now before I go any further?

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

    What you think about Dev.to as a developer community, I am planning to create something like with other features like meetups notifications, search on stackoverflow, give and ask for help in real-time, jobs, books, etc. Please let me know how valuable this would be for you guys, thanks!

    Posted: 19 Apr 2019 12:18 AM PDT

    Simple Python Question

    Posted: 18 Apr 2019 11:39 PM PDT

    Could someone please explain why the if condition will ever be satisfied after you set file to None?

    def_init_(self, file = None): if file: f = open(file, 'r') self.lines = f.readlines() f.close() 
    submitted by /u/salt_schedule
    [link] [comments]

    I'm getting a little error about assigning an expression to an array type

    Posted: 18 Apr 2019 11:29 PM PDT

    • Code Line 7 is what I want to look at.

    • How come I can't assign the Array in my parameter to the array in my function? They're of the same struct type, both pointers, and even the same size. Like why?

    Extra Details

    • Background: I've built an array of pointers (struct boxtype *Array[10])with each index acting as a "first node for a linked list.

    • I want to print this list.

    • In order to traverse it, I wanted to create this "dummy array" of pointers(struct boxtpye *b), copy the contents of my pointer array, and just traverse the list.

    • I've tried just using my *Array[10], but I end up segfaulting because all rows reach NULL.

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

    No comments:

    Post a Comment