• Breaking News

    Saturday, February 20, 2021

    how do operating systems "assign" more memory for a program? (e.g if your program starts using over a gigabyte of ram) Ask Programming

    how do operating systems "assign" more memory for a program? (e.g if your program starts using over a gigabyte of ram) Ask Programming


    how do operating systems "assign" more memory for a program? (e.g if your program starts using over a gigabyte of ram)

    Posted: 20 Feb 2021 07:05 AM PST

    ive watched videos and also read online that an os (like windows), when you run an app, it will basically just load the instructions (if its a c app for example) into ram and then it will call the main function (which could be at address 1297446 for example)

    and i've also read that windows will allocate a region of memory after the instructions; and at the very end is the stack, then behind that is the heap, then behind the heap is the free memory for the heap to use if needed, then its the actual program instructions (it might be global variables then the instructions im not sure).

    but i dont really understand that, because what if the heap gets very large (such as in a big game, there could be nearly a gigabyte of data in the heap, such as colliders, GameObjects, etc), so would windows just automatically resize the heap by taking the stack and moving it further down in memory? or is it a bit more complex than that...

    submitted by /u/tea-vs-coffee
    [link] [comments]

    Struts 2 Parameters after the action name no longer working/ possible alternatives?

    Posted: 20 Feb 2021 08:41 PM PST

    Been working with Struts2 since there is a decent amount of demand around me to maintain aging systems developed using struts. Recently updated to struts 2.5.26 and noticed a large portions of my actions broke as a result. Narrowed it down to parameters after action names no longer leading to variables populating in the action classes. I.e something like ... action/{user}/records/{class} used to populate the {user} and {class} variables, but no longer does.

    Just curios if anyone has experienced the same as well as if you found a solution or have a good alternative solution for populating parameters based on the url without using url parameters i.e ?a=b&c=d

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

    Which language to fit my project

    Posted: 20 Feb 2021 09:27 AM PST

    Hello everyone,

    I work in the design of industrial machinery in a small company and my role is the realization of electrical, pneumatic, automation, etc..

    I would like in my spare time to develop my own tools because the others are either paying (sometimes too expensive) or not suitable for me (missing feature or other).

    It would be mainly drag and drop of a symbol in a grid, with the link between the elements, automatic numbering according to the type of element and the page. A symbol creation/modification tool. As a bonus (and it would be great) to be able to simulate the passage of the current, air and other.

    I would like the application to be cross platform (at least Windows and Linux).

    I was thinking about Electron or Python, what do you think?

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

    Efficiently compute the sum of rows and columns of a matrix being within a range (In Python)

    Posted: 20 Feb 2021 08:59 PM PST

    Problem:

    Given a 2d matrix , we need to find out how many rows and columns have sum between a given range(inclusive) in that matrix . All these ranges will be given in form of some queries.

    Sample Input -> matrix - [[2,3],[5,9]], range queries - [[1,7],[6,14]] Output - [2,3]

    Explanation -> for first range query i.e. [1,7] , we have first row(2+3=5) and first column(2+5=7) with sum between range. So output will be 2. for second query i.e. [6,14] , we have first column(2+5=7), second column (3+9 = 12), second row(5+9=14), so output will be 3.

    I need help with optimizing this solution so that it pass test case because for now It is giving it shows Memory Limit exceeded(above 256MB in python) error for following constraints: 1<=nxm<=4x10^6 (size of matrix), 1<=q<=5x10^5(number of queries), 1<=Aij<=10^9(element in matrix), 1<=L<=R<=10^14 (range)".

    Code:

    import numpy as np

    def solve (a, queries):

    # Write your code here

    #print('y')

    rows = np.sum(a, axis=0)

    cols = np.sum(a, axis=1)

    for query in queries:

    low = query[0]

    high = query[1]

    r = np.sum((low<=rows) * (rows<=high))

    c = np.sum((low<=cols) * (cols<=high))

    yield r+c

    N = int(input())

    M = int(input())

    a = [list(map(int, input().split())) for i in range(N)]

    Q = int(input())

    S = int(input())

    query = [list(map(int, input().split())) for i in range(Q)]

    out_ = solve(a, query)

    print (' '.join(map(str, out_)))

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

    Help JS: Having problem with my HackerRank solution

    Posted: 20 Feb 2021 08:42 PM PST

    The problem can be found here:

    https://www.hackerrank.com/challenges/special-palindrome-again/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=strings

    After submitting my solution I am failing the test cases, I do not know what the problem is in my code. Can someone help me debug it? Thanks!

    My solution is below:

    function substrCount(n, s) {
    let charArray = s.split('');
    let totalSpecialSubStirngs = charArray.length;
    let sameCharOcc = new Array(charArray.length).fill(0);
    for (let i = 0; i < charArray.length; i++) {
    let j = i + 1;
    let count = 1;
    while (j < charArray.length && charArray[i] == charArray[j]) {
    j++;
    count++;
    }
    if (count > 1) {
    totalSpecialSubStirngs += count * (count + 1) / 2;
    sameCharOcc[i] = count;
    }
    i = j;
    }
    if (totalSpecialSubStirngs !== 0) {
    let total = sameCharOcc.reduce((acc, currentVal) => acc + currentVal);
    totalSpecialSubStirngs -= total;
    }
    for (let i = 1; i < charArray.length; i++) {
    let left = i - 1;
    let right = i + 1;
    if (charArray[right] === charArray[i] || charArray[left] === charArray[i]) {
    continue;
    }
    let char = charArray[left];
    while (charArray[left] === char && charArray[right] === char && left >= 0 && right < s.length) {
    totalSpecialSubStirngs++;
    left--;
    right++;
    }
    }
    console.log(totalSpecialSubStirngs) ;
    return totalSpecialSubStirngs;
    }

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

    linux commands c++

    Posted: 20 Feb 2021 02:26 PM PST

    original code

     /** * Figure 3.33 */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> int main() { pid_t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ execlp("/bin/ls","ls",NULL); printf("LINE J"); } else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; } 

    So they want me to change

    execlp("/bin/ls","ls",NULL); to work using execvp instead. So I tried

    /** * Figure 3.33 */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> int main(int argc, char *argv[]) { pid_t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ execvp(argv[0], argv); printf("LINE J"); } else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; } 

    so I run ./a.out ls

    but it just gives me "child CompleteChild CompleteChild CompleteChild CompleteChild CompleteChild CompleteChild CompleteChild" over and over and I can't really figure out why

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

    Real time chat like ClubHouse - how does it work, technically?

    Posted: 20 Feb 2021 07:47 PM PST

    Hi I'm struggling as I try to think about how something like Clubhouse works with RTC and how "peers" actually communicate - what are they communicating?

    I have a seed of an idae that if you have an app that supports real time voice chat (maybe Video too) it might not need to have that voice travel through to a central backend, but I'm not clear on if that's accurate and I'm fuzzy on the details.

    When somebody joins an app to create a new "room" are they creating a specific new stream URL or "frequency", something that tells other people where to find them? And that might be stored in a database somewhere?

    Then when others retrieve that URL, are you then just telling a client device where to look for the other people? And is every device connecting to every other device at that point? Sorry if this is a ridiculously terrible stab at how this might work, I just don't get it at all yet!

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

    I'm trying to make a VM in azure with 128 cores in a single processing group. However, it keeps splitting them into two groups of 64. Is this possible?

    Posted: 20 Feb 2021 01:25 PM PST

    C++ How do i make an array double its size when needed with out using vector or dynamic arrays ?

    Posted: 20 Feb 2021 07:08 PM PST

    I have an assignment where i am supposed to make 3 classes, where the first class manages the second and the second manages the third.

    One Attribute of the second class should be an array who holds the Objects of the third class.

    That array should double its size when it is half full (like a vector) but i cant use a vector or a dynamic array. Can someone Help ?

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

    What's the best approach to establish connection to multiple imap accounts at the same time and listen for incoming messages on each of them?

    Posted: 20 Feb 2021 05:22 PM PST

    I want to write a tool that connects to all my imap accounts and sends me a notification whenever a newly received message (in any of said accounts) matches a certain keyword . I want this tool to be scalable.

    What i currently have in mind: Writing a C/C++ program that lets me input the list of imap accounts. Once started, the program will open a thread for each imap account and connect to it using TCP sockets. Each thread will be listening for incoming messages and then notifiy me if the incoming message contains a keyword that i set.

    Questions:

    1. Is C/C++ too overkill for this? I'm looking at this language(s) because i want this tool to be as scalable as possible without overloading the machine i will be running this in.
    2. Is there any better solution other than using a thread per imap account?
    3. Is implementing the imap client with TCP sockets way too overkill? What alternatives do i have?

    Much appreciated.

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

    Turning png to ascii - c# console app

    Posted: 20 Feb 2021 05:17 PM PST

    I recently saw some yt videos about turning some pictures (homer simpson for example) from original pic to shaded ascii "picture" in console.

    So now I wonder is there any way to get brightness of every pixel from image and to just turn it to ascii symbol that represent it in the best way, the brightest ones as "@", and the darkest as "." for example...

    If you have an idea it would be best to write it in a c#, thank you.

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

    Is it good to include academic and intellectual competition medals on your resume?

    Posted: 20 Feb 2021 01:26 PM PST

    I heard it would be viewed as pretentious unless in the context of a technical field. However, this is a technical field and I can show the medals during interviews to prove it so should I go for it?

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

    How to go about cross compiling with dependencies

    Posted: 20 Feb 2021 04:44 PM PST

    I have a library which I need to cross compile, however it has several dependencies that also need to be cross compiled.

    While I have successfully cross compiled a couple of the dependencies, I'm unable to get the original project to compile against it.

    Here's a line from my makefile to show how I've been trying to do it:

    cmake -D CMAKE_C_COMPILER=$(FRC_GCC) -D CMAKE_CXX_COMPILER=$(FRC_GXX) -DCMAKE_C_FLAGS=-isystem\$(shell pwd)/lapack/LAPACKE/include:$(shell pwd)/lapack/CBLAS/include .. && \ cmake -D CMAKE_C_COMPILER=$(FRC_GCC) -D CMAKE_CXX_COMPILER=$(FRC_GXX) -DCMAKE_C_FLAGS=-isystem\$(shell pwd)/lapack/LAPACKE/include:$(shell pwd)/lapack/CBLAS/include --build . 

    The build process fails trying to resolve an import for cblas.h - which is in /lapack/CBLAS/include. If possible, I would like to avoid modifying the cmake build files themselves, as I'm using git submodules to handle the dependencies currently.

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

    heroku and postgrator-cli issues

    Posted: 20 Feb 2021 04:32 PM PST

    I'm trying to deploy my database to heroku and everything was working fine until fully deployed. My fetch requests were all throwing server errors and I figured out that postgrator-cli keeps automatically saving as a dev dependency even without the "-D" or " --save -dev" flag at the end. How do I force it to install as a regular dependency so i can run my migrations?

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

    [Java]Tring to find a generic way to traverse XML document and conditionally build maps

    Posted: 20 Feb 2021 12:24 PM PST

    Trying to build hashmaps using values from XML for the purpose of sending the list of maps off through an API call to build a table in another app. I need to find the most efficient way, whether library, pattern, or even another language, to find the values in the XML and build this structure.

    As of now, I am building a class for each table type. I am doing this because there are dozens of types of tables and they are all looking for different values. For example, imagine I am working for a supermarket and there is an XML document holding all the items in the store along with various details about each item. I need to build a table of items from the XML for each section in the supermarket. I would have a GroceryBuilder class, a ClothingBuilder class, and so on. So in the GrocerBuilder class, I would traverse the XML, find all the grocery items, and add the items, along with other data related to those items, to a hashmap, looking like this, where [n] equals a row:

    ("Grocery[1].Item", "Apple"), ("Grocery[1].Description", "Granny Smith"), ("Grocery[1].Color", "Green"), ("Grocery[2].Item", "Paper Plates"), ("Grocery[2].PricePerEach", ".03"), ("Grocery[2].Purpose", "Eating"), ("Grocery[3].Item", "Bologna"), ("Grocery[3].Description", "Meat-like"), ("Grocery[3].Purpose", "Sustainence"), 

    As you can see above, each row can have different column values because not every cell in the table is populated.

    Here is an example of what the XML could look like:

    <grocery> <food> <produce> <apple> <description>Granny Smith</description> <itemCd>93jfu4n</itemCd> <color>Green</color> </apple> <pear> <description>Concorde</description> <itemCd>0272ve6dg3</itemCd> <color>Yellow</color> </pear> <banana> <description>Regular</description> <itemCd>2je7c3</itemCd> <color>Yellow</color> </pear> ... <insert 50 types of produce here/> ... </produce> <meat> <bologna> <description>Meat-like</description> <itemCd>9dmd623</itemCd> <purpose>Sustainence</purpose> </bologna> ... <insert 50 types of meat here/> ... </meat> </food> <sporting goods> ... <insert 50 types of sporting goods here/> ... </sporting goods> <clothing> ... <insert 50 types of clothing here/> ... </clothing> </grocery> 

    The problem I am facing is that there are potentially 100+ table types (using the example above, imagine a table for every section in the store), each looking for specific values, so I would potentially have to build 100+ different classes. I am looking for a more generic way to build these structures.

    The challenge is that there are many conditions on the values I am getting from the XML. For instance, insert the value into the XML only if the ItemCd is a certain value. Or if the Apple Description equals whatever value, insert this value instead.

    So far, I've been building these maps manually, looping over each item in a section (i.e. "produce"), checking conditions, and inserting the values based on those conditions. But this is going to be a ton of effort if I must do this for 100+ tables. Is there an established pattern or library that could handle this better? Or even a language other than Java?

    TLDR: Need a more efficient way to conditionally build hashmaps from XML data

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

    What are some good resources for learning kubernetes?

    Posted: 20 Feb 2021 03:58 PM PST

    The official k8s tutorial doesn't really work for me. I don't know if it's just how it's being presented or what, but it doesn't really "click" with me.

    I know that k8s has a lot of pieces to it and it's not feasible to have a solid understanding after your first go. But I've never had quite as much difficulty trying to learn something as I have with k8s.

    26 y/o SE working in DevOps for the curious

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

    CCC trouble - j4/s2 2018

    Posted: 20 Feb 2021 03:57 PM PST

    I started coding again like a month ago after taking a bit of a break, and I was practicing the ccc. I tried question s2/j4 2018 and I thought I got the answer right, but on dmoj i only got 3/15 marks.

    Here's the link to the submission, and the code below it:

    https://dmoj.ca/submission/3438561

    lowest_val = [] flower=[] n = int(input()) for i in range(0,n): flower.append(input().split(" ")) lowest_val.append(flower[0][0]) lowest_val.append(flower[0][n-1]) lowest_val.append(flower[n-1][0]) lowest_val.append(flower[n-1][n-1]) while True: if flower[0][0] == min(lowest_val): for row in flower: for i in row: print(i, end=" ") print() break flower = list(zip(*flower[::-1])) 
    submitted by /u/apex_redstone
    [link] [comments]

    Advice request: Tool choice for desktop app with MongoDB storage for Linux and Windows

    Posted: 20 Feb 2021 03:21 PM PST

    Hello, thank you for reading.

    I'm aiming to build a database-driven app that I can use on Linux and Windows. Ideally it will result in a small MongoDB database residing on a server and accessible from a few computers on the same network. I've written some C# on .NET in windows, but I'd rather a bit more general, especially since my development will be mostly in a Linux environment.

    I read that Electron produces very large and heavy apps, and I'd prefer to avoid that.

    Can I use VSCode with Typescript and Node.Js to produce a lighter app? I assume there will be more work involved and that's ok. This version would be run in a browser.

    Should I just build a desktop app with Java and deal with the annoyance of installing/maintaining the JVM on the client computers?

    Any other ideas? I'm a novice kinda drowning in terminology but I've gotten as far as reaching this fork in the road.

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

    How do I reduce memory/energy usage during continuous console output?

    Posted: 20 Feb 2021 11:09 AM PST

    Hey, noob programmer here.

    So, I decided to run the following loop for 5-10 minutes and observed the following things:

    include <iostream> int main() { while(true) { std::cout << "Hello World\n"; } return 0; } 
    1. After 5-6 minutes, my laptop's cpu temperature reached about 74°C (and kept rising)
    2. After about 10 minutes, the laptop became totally unresponsive and had to be powered off

    My question: Why does this happen? After all, the code isn't computationally heavy or anything, it's simply printing to the console over and over again. Most games that I play on this laptop only make the temperature reach about 60°C and needless to say, games have very complex loops where lots of things are calculated and processed. This however, is a simple hello world loop, yet it appears to be more resource hungry than a AAA game. Can anyone tell me whats happening under the hood?

    The reason behind my asking this is that I am trying to create one of those ASCII console games as a beginner project. Now those involve a lot of console printing in a loop as well. So, if a hello world loop is this bad, I am not sure as to how to go about this project.

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

    Creating a fake operating system.

    Posted: 20 Feb 2021 02:54 PM PST

    Alright so i'm really fascinated with fantasy consoles, since they are an actual console that is just emulated, but imaginary. Also a big part of my childhood was flash games, and time after time i came across these windows parody flash games. There's also Windows 93 which is more of an art project than an actual OS.

    I'm interested in developing my own operating system, but not as in an actual operating system, but more a fake one. More like a platform disguised as an operating system. A platform on which you could develop stuff yourself or download other peoples tools or "software" or games.

    The thing is i'd really want to write my own operating system, but i know it would be an absolute hellhole of a project to embark on. I would just like to program a platform on which you can launch software written for it and share the software for others, and disguise it as an operating system, so where could i start? What should i do?

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

    Help adding a visible scrollbar to a Wordpress Theme

    Posted: 20 Feb 2021 02:36 PM PST

    I have a Wordpress Theme that doesn't have a visible scrollbar (https://demo.yosoftware.com/wp/veso/imersive/#Speed). I have looked through the coding and cannot figure out how to make the scrollbar visible again. Any help would be appreciated.

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

    How does RPC solve endianess, pass by reference and coding in general?

    Posted: 20 Feb 2021 10:13 AM PST

    Hello, I can't seem to find anything regarding this.. are there multiple solutions or just one?

    How does RPC solve issues like, pass by reference doesnt work since klient / server dont share memory area.. and endianess?

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

    How the heck can a junior improve its seniority if everyone hires only seniors or semi-seniors?

    Posted: 20 Feb 2021 06:22 AM PST

    I'm a junior developer who wants to get a job... Because of the quarantine I'm looking for remotes ones. I have been in this search for many months right now and the interviews always end like "nice profile, but I need higher seniority, bye" It's frustrating.

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

    I am building a Flask app. Is running 'create-react-app' overkill if I plan to use a few components?

    Posted: 20 Feb 2021 10:04 AM PST

    I would like to be able to use React in the most lightweight way possible. I have a Flask app and I considered:

    1) having an index.html file and adding the React <script> tag.

    2) using create-react-app.

    I tried the first and, despite having CORS enabled, I couldn't fetch info from my API. If I, on the other hand, start a separate create-react-app (in a different repository) I can seamlessly fetch from the API.

    What would you do in this situation? This is a project for a job interview so I don't wanna complicate things too much.

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

    No comments:

    Post a Comment