• Breaking News

    Monday, September 27, 2021

    What's your favourite linux command that saves you the most time? Ask Programming

    What's your favourite linux command that saves you the most time? Ask Programming


    What's your favourite linux command that saves you the most time?

    Posted: 27 Sep 2021 02:48 PM PDT

    Mine is SCP which allows me to copy files via SSH 🔥🔥

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

    gdb: How to stepi right through the end of main

    Posted: 27 Sep 2021 12:26 PM PDT

    I'm trying to debug a C program. So far I have a script:

    starti while 1 x/i $pc stepi end 

    It starts stepping before main, but it stops stepping at the end of main. How can I step right through the main function? Is there any builtin capacity for gdb to do this?

    submitted by /u/blood-pressure-gauge
    [link] [comments]

    More efficient/mathematical branching probability trees for random game events?

    Posted: 27 Sep 2021 02:12 PM PDT

    I'm making a text-based game and want to have branching probabilities to determine random actions that should occur in response to events.

    I want to set it up so I can write them in both the most concise/developer-friendly and most efficient way possible.

    For example, let's say there's a rare event with 1/20 probability, and if this happens, one of two events may occur. In pseudocode, where rand(n) returns a random integer between 0 and n, non-inclusive, and prob(n) returns true 1/n of the time (basically rand(n) == 0):

    if prob(20) { if prob(2) { X() } else { Y() } }

    This would be a rare event that has a 1/20 probability of occurring, and if it occurs, half the time X will happen and half the time Y will happen.

    However, one problem is this requires two calls to the random number generator. This would be equivalent and requires only one call, but is less simple and concise:

    ``` randNum = prob(40)

    if randNum == 0 { X() } else if randNum == 1 { Y() } ```

    I understand in the scheme of things this is a micro-optimization that would make no real difference, but imagine if there are hundreds of these that ran for every step of the game, for example.

    Also, the first example doesn't allow for an easy way to do sub-branches that check for anything lower than 1/2 probability. For example, if I want to have a 1/20 probability event which leads to 1 of 3 different possible things with equal probability, I'd have to do:

    ``` if prob(20) { randNum = rand(3)

    if randNum == 0 { X() } else if randNum == 1 { Y() } else { Z() } 

    } ```

    Or if I wanted to have a 3/4 chance that one of two things with equal probability will happen with a 1/4 chance one of four things with equal probability will happen, it starts to get especially unwieldy:

    ``` randNum = rand(16)

    if randNum < 6 { // 0, 1, 2, 3, 4, 5 X1() } else if randNum < 12 { // 6, 7, 8, 9, 10, 11 Y1() } else if randNum == 12 { X2() } else if randNum == 13 { Y2() } else if randNum == 14 { Z2() } else { Q2() } ```

    This requires only one RNG call, but is pretty ugly and requires some extra thinking, especially if there are a lot of different branches and sub-branches. And If I decided I want to make it a 2/3 chance, I'd have to manually adjust all of those numbers.

    Ideally, I'd have some kind of DSL which compiles to the above. Something like:

    ``` { 3/4 { 1/2 { X1() } 1/2 { Y1() } }

    1/4 { 1/4 { X2() } 1/4 { Y2() } 1/4 { Z2() } 1/4 { Q2() } } 

    } ```

    And it could also do some compile-time checking to make sure each branch either adds up to 1 or has a default fallback if none of the other sub-branches are reached.

    Does anything like this exist out there? Or is there at least some better way I could do this? Thanks.

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

    I cant memorize python (first language)

    Posted: 27 Sep 2021 11:09 PM PDT

    so i have been learning python for 3 weeks and i cant memorize the i know what can be done but my mind goes blank when i look at pratice set

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

    Questions for perfectionists - is there any subfield of programming where you find that you feel easier, and can easily let go of the project/task.

    Posted: 27 Sep 2021 11:04 PM PDT

    Trying to perfect one tiny detail into oblivion with no desire to stop is limiting. Is there anything where this isn't much of a problem?

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

    [SQL][WebApp] Having a hard time managing administrative key decisions in database structure. / integrity of historical data

    Posted: 27 Sep 2021 10:50 PM PDT

    Without further ado, I've been commissioned with creating a mini-CRM module in the form of a web app/ portal (PHP/MySQL). Nothing out of the ordinary, and I expect it to be learning experience. The requested module should enable creation of quotations and converting said quotations to contracts once finalized. I have yet to give the final confirmation and I remain non-committal given few problems:

    Given the table [company] with rows (ID, company name, address, vendor ID, location...etc).

    When I issue a quotation I would most defiantly be using the [company][ID] as a foreign key defined in [quotation] table.

    Since I'm linking to a foreign key, I expect to always have a smart-link between the quotation and the selected company. Meaning that at any point in the future, if I update the company name/ address and re-export the old quotation for printing, I will have a newer quotation print with the recently-modified address that does not match the previously printed document.

    Now...is this a problem at all? What is the industry standard when it comes to maintaining the integrity of documents.

    Should I maintain a copy of the selected [company] row in a different table each time a quotation is issued in order to maintain the original data. I would then have to link the quotation to the original [company][ID] as well as the new copied [company-2][ID].

    Maybe I could duplicate the selected [company] row in the same table and make it inaccessible directly...but then this brings in a new issue. Every time you issue a quotation, the auto-increment primary key in [company] would go up by one. Making for one hell of scene in the [Company] view.

    Am I overthinking the issue and there is a simple solution that I'm overlooking. Also...the same question applies for pretty much everything I'm assigning and linking to the quotation....including the line items themselves.

    Any help in this topic is highly appreciated.

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

    Is it possible for a computer to support both RISC and CISC?

    Posted: 27 Sep 2021 10:20 PM PDT

    Just out of curiosity, is it possible for a computer to support both RISC and CISC? Though I'm not sure what the advantages would be lol.

    But why I am asking this is, let's say you have some sort of distributed system where there is a critical section. You would need to use locks, which is relatively expensive in terms of speed.

    Now, what if, you can have 1 CISC command that can do the critical section computation, and make the command atomic. Even though CISC commands are slower than RISC (in terms of doing the same work), but having it run atomically (somehow) would mean we do not need a lock.

    Would this even be a correct statement, or this is not how any of it works?

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

    Coding with a broken hand

    Posted: 27 Sep 2021 02:36 PM PDT

    Hi everyone, can anyone give me some tips on one handed coding?

    Am in a full cast for a week and then will have a finger splint for a few weeks but the show must go on!

    Thinking a new mouse and some text to speech software could be useful at the least.

    Any tips appreciated, thanks

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

    In C++, how to create a simple function that’s impossible to logically solve and it goes past the compilers detection?

    Posted: 27 Sep 2021 09:21 PM PDT

    Essentially dead code

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

    Why is it a benefit for a cache and a database to be able to have different models?

    Posted: 27 Sep 2021 08:33 PM PDT

    I'm reading an article on caching strategies and looking specifically at Cache-Aside pros and cons.

    Another benefit is that the data model in cache can be different than the data model in database. E.g. the response generated as a result of multiple queries can be stored against some request id.

    Why is it a benefit for you to be able to have different data models? I'm also not clear on what kind of use case might benefit from storing multiple queries against a request ID.

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

    Would it be a good idea to take a job to design an app for someone who doesn't know how to code with upfront pay and a possible career if it takes off?

    Posted: 27 Sep 2021 08:29 PM PDT

    I saw a freelance gig to design an app for someone with an idea but doesn't know how to code themselves for a good pay where they keep the rights, and if it takes off they would offer full time position keeping it going with paycheck plus profit share.

    I kinda wanna take it (cuz like the freelance price is good and then a chance of job security) but I wanna know what you guys think first, any tips?

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

    I understand what a web app’s backend server is, and how it connects to a database; but what is a “mine craft server”, or a game server in general?

    Posted: 27 Sep 2021 01:23 PM PDT

    Hi everyone, this is a question that's been on my mind for quite some time. I know what a server is when it comes to websites/web apps/mobile apps: it basically connects to a database and serves data to the client (a browser, a front end, etc) via REST (or SOAP or other) API.

    I used to game a lot in my childhood but I mostly stopped now, and I hear people talking about "minecraft servers" and "gaming servers".

    This may be a weird question, but what do these servers do? What sort of data do they serve, and how are they comparable with (or different from) web app servers? If they work over HTTP to connect with the clients, then what other architecture/protocol do they use (I am guessing it is not REST)?

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

    For Loop/ if statement trouble?

    Posted: 27 Sep 2021 07:16 PM PDT

    Hi everyone, I'm trying to get my program to check whether or not the appointments created in my array are true or not. However, regardless of whether or not I input dates in the array or not, the program spits out whatever date I put in instead of checking, and says I have a OneTime@(a bunch of random numbers) appointment on *inserted dated*.

    The "if (appointment[i].occursOn(day, month, year)==false)" line doesn't work at all. If I check an incorrect appointment date it says I have a "OneTime@4e710869" appointment on *insert wrong date* instead of "You do not have an appointment on *insert wrong date*" (yes, with those random numbers after the random @)

    Where did I go wrong?

    public static void main(String[] args) { Appointment[] appointment = new Appointment [5]; appointment[0] = new OneTime(25,12,2017, "Root Canal"); appointment[1] = new Monthly(20,9,2017, "Teeth Cleaning"); appointment[2] = new Daily(25,12,2017, "Filling"); appointment[3] = new OneTime(13,12,2017, "Crown"); appointment[4] = new Monthly(20,9,2017, "Dentures"); Scanner keyboard = new Scanner(System.in); System.out.println("Please input the day of the appointment (1-31): "); int day = keyboard.nextInt(); System.out.println("Please input the month of the appointment (1-12): "); int month = keyboard.nextInt(); System.out.println("Please input the year of the appointment: "); int year = keyboard.nextInt(); System.out.println(day +" "+ month + " " +year); for (int i=0; i<5; i++) { if (appointment[i].occursOn(day, month, year)==true) { Scanner keyboard1 = new Scanner(System.in); System.out.println("You have a " + appointment[i] + " appointment on: " + day + " " + month + " " + year); break; } else { if (appointment[i].occursOn(day, month, year)==false) { System.out.println("You do not have a " + appointment[i] + " appointment on: " + day + " " + month + " " + year); break; } } } 
    submitted by /u/josukehair
    [link] [comments]

    Building a website to display raster data

    Posted: 27 Sep 2021 06:06 PM PDT

    Hi, I'm looking to make a website for some of my raster datasets.

    The rasters show data for the western US. Each raster is different based on the time period and variable. I would like to have a dropdown to select what variable to look at and one for the time period. I would also like to have a method to import a polygon and drag it over the area they want for or draw one out a shape on the map using the tool to isolate data. Then a button to download a custom raster file for the user.

    I'm thinking of using Google Earth Engine or building an RShiny app using GEE and raster packages (I am familiar with both javascript and R). Can someone point me in the right direction (tutorials they know of)?

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

    Almost 40 year old healthcare worker considering bootcamp, am I crazy to switch careers?

    Posted: 27 Sep 2021 05:51 PM PDT

    I'm currently a healthcare worker based in Los Angeles and decided this is what I wanted to do from a young age. For the last ten years I've always been curious about a programming career but always thought it was silly since I'm already so invested in my career now, I've spent so much time going to school, honing my skills and employment history. I currently like what I do but I because I made my career decision so young I never really considered other careers. But now I'm stable in my career The thought of switching careers and learning something new seems more and more exciting. And coding bootcamp seems to make it even more achievable. But I would have to make some real sacrifices at work to be able to attend classes, it would be almost a double investment since I would be paying for bootcamp and a pay cut at work to make it happen.

    Would I be too old to get jobs in programming at this point? Am I silly to throw away a 120k career for a lower starting salary. I'm sort of maxed out of my income potential at this point in my career, would programming afford more income potential?

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

    In C, how do I print the value being pointed to by a void* variable within a struct?

    Posted: 27 Sep 2021 04:35 PM PDT

    I'm new to both C and the concept of pointers, so forgive me if I've got some of the terminology wrong.

    I am trying to define a struct Node with a member variable void* Data, initialize one of these nodes, assign an int* as its data, and then print the actual int that data is pointing to. So the goal is to get my printf() to print "5."

    I think I've got all of that working except accessing the int and printing it. Here's my code, which currently gives the error "invalid use of void expression." What is the correct way to do this?

    #include <stdio.h> struct Node { void* data; struct Node *next; }; int main() { struct Node N1; int x = 5; int *xp = &x; N1.data = xp; printf("%d \n",*N1.data); return 0; } 
    submitted by /u/Fuck_TikTok
    [link] [comments]

    Is there a way I can design a script to plug into a weather api or something and tell me if at 04:20 if it's 69° F somewhere in the world?

    Posted: 27 Sep 2021 12:15 AM PDT

    My friends and I are kinda sad and could use a fun little project.

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

    Any good resources for how to set up your programming Environment?

    Posted: 27 Sep 2021 05:24 AM PDT

    I am from what I have heard from others a pretty solid programmer, but I have no idea about all the things that make it easier, like Plugins for code completion etc.

    Is there a Guide for experienced developers, but just around tools and such?

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

    I’m using Amazon Lightsail for a dedicated Halo 2 server - Should I use Windows Server 2012 or 2019?

    Posted: 27 Sep 2021 02:45 PM PDT

    I figured that it would be better to use Windows Server 2012 instead of 2019 in terms of compatibility since it's closer to the release of Halo 2 (2007). Is there any merit to this or would I be completely fine with 2019? I kind of hate the 2008'ish layout of Windows Server 2012, but if it might have better compatibility with the Halo server application I'm fine with using it.

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

    easywsclient issue

    Posted: 27 Sep 2021 10:03 AM PDT

    I am using https://github.com/dhbaird/easywsclient The following code returns WS always as NULL and I cannot figure out why. Any help is appreciated!

    std::string url = "ws://mysite.net:443/path";

    ws = WebSocket::from_url(url);
    assert(ws);

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

    I wanna make something similar to this but only thing i could think about was buying a 100$ book in hopes of finding a Python alternative

    Posted: 26 Sep 2021 11:01 PM PDT

    Doesnt even have to be python but i wanna remake this

    https://www.leshylabs.com/apps/sfMaker/

    Thats not just the a windows beep with a bunch of math is it?

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

    Programming and Macbook Air m1

    Posted: 27 Sep 2021 12:33 PM PDT

    Hi all,

    I currently learn/code c/c++, python javascript. I use vscode, pycharm. People who own the Macbook Air M1

    Please can you share early adoption issues eg software compaitability, crashes, restarts.

    I am aware gcc, docker, homebrew are not supported. What are other issues did you face during development on the M1?

    I have a desktop(ubuntu) for coding and other stuff the mac/lappy will be for power cuts or when I am on the go or just wanna do something when in bed... :P

    The reason for me even considering a Mac is just bad/poor quality windows laptops with alot of flex not so great battery life, and ton of other hardware issues.

    I am not sure if its worth spending a lot of money on a hp or dell with good build compared to a Mac.

    So to all the devs here does the Macbook M1 make sense?

    Is it a device which will last me for 5-6 years usage is learning new stuff, web dev, following tutorials, browsing, movies, youtube

    I dont want to end up withan expensive lappy that will crash application most of the time cause the apps are not native....

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

    I need to build searchable workers database website

    Posted: 27 Sep 2021 10:16 AM PDT

    Hello,

    For college I need to build a simple prototype website in which I can search for workers on a dummy database, based on things like age, job, licences, hometown, association, etc. But I have no knowledge of coding or database software

    Any suggestions on how to start and how to build such dummy database?

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

    What are the things to learn apart from coding for a front end web developer

    Posted: 27 Sep 2021 06:20 AM PDT

    What concepts shoul i start learning as a front end web developer apart from coding?

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

    What's the point of linters in golang?

    Posted: 27 Sep 2021 09:49 AM PDT

    Is it for performance or something?

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

    No comments:

    Post a Comment