• Breaking News

    Saturday, May 22, 2021

    is there a name for a program that was written in multiple programming languages? Ask Programming

    is there a name for a program that was written in multiple programming languages? Ask Programming


    is there a name for a program that was written in multiple programming languages?

    Posted: 22 May 2021 05:36 PM PDT

    lets say I wrote a programm in c, rust and python. is there a special name for this program?

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

    Been trying to solve this problem for the last couple of days but it seems impossible to solve

    Posted: 22 May 2021 11:08 AM PDT

    Hey all, last couple of days have been nothing but pure annoyance and rage for me. Decided to ask here for help maybe an experienced developer can help me out with this...

    Basically, the problem is that I have a NodeJS server(NextJS to be exact) and when a user makes a request to a specific endpoint, I want to generate a bunch od PDF files(around 20-30kb in size each, in total even up to a few thousand files in some cases, but in some cases only a few), then I want to put them inside a .zip file(just for the convenience really) and serve them to the user somehow..

    My initial solution was to just do all that in memory and in sync. I knew before even implementing it that this won't hold for long. Sure enough, even with 30-50 pdf files it was timing out the requests and extremely slow. But I wanted to implement it just to see if it's even possible to do what I want to do, and it was. Good start.

    Next, I decided that it would be great if I made the zip in memory, but instead of sending it straight to the user, I would upload it to Azure and then send the user a link to the file. This.. didn't really work.. It was still working in a synchronous manner, so the server would just hang when you wanted to export the file and be completely unusable until it uploaded the file to Azure.

    Fair enough, it's time to put this in a background task. I installed the agenda library thinking that this would be the final thing I needed to do.. The problem with this was, the app was being hosted on Vercel and even though the job ran in the background, the request still timed out. Even though I returned a response to the user right after clicking the export button, Vercel was giving me a "request timed out" error every time I tried this. I am really not sure why that was the case, it seems like that shouldn't happen..

    My next idea was to have a separate server running on Azure App Service whos only task would be to zip and upload these files. But this idea soon fell in the water when I noticed that I would have to copy a lot of the code over, and some of it, like my database models, would not be easy to maintain and update, since I would have to do it in 2 places every time I make any changes...

    Anyways, the last 2 days I've been trying to migrate my entire app to Azure App Service, and since NextJS wasn't really made to be hosted there, it's been painful. Constant crashes, errors and issues that I have no idea what to do with. And I honestly don't want to waste any more time on this since I am not sure if that is even going to work... So that's why I'm here. I would love for someone to tell me how the hell should I solve this because I'm just sick of it.. Thanks for any comments and/or suggestions... I feel like this kind of problem would not be a first for many people, and having some professional experience with software development would really help out a lot, but as a mere student, I hope that you understand that I don't really know what I'm doing lol.. Thanks again!

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

    Docker vs Terminal Multiplexer (like tmux) vs Terminal Emulators vs Remote Machines. Can anyone simply explain the differences between these?

    Posted: 22 May 2021 04:59 PM PDT

    I have somewhat of an understanding of what all four of those are, but I'm a bit confused about the differences between some of them?

    Could someone ELI5 the difference between Docker and Terminal Multiplexers (like tmux)?

    Furthermore, what's the difference between Remote Machines, Terminal Emulators and Docker?

    Noob level question but this seems like the place to ask. Thanks!

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

    some question about JWT and Oauth

    Posted: 22 May 2021 09:47 PM PDT

    I searched for JWT to use it in my mini project. when I googled many blog, stackoverflow... etc said

    one of the disadvantages of JWT is hard to logout immediately.

    I don't understand this. I think when a user requests logout, a server can change the user's jwt token's expire time to 0. then doesn't it mean logout immediately??

    they say if we need to implement logout immediately, we need OAuth with JWT.

    why??

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

    How to use “proton-python-client” to write auto reply script?

    Posted: 22 May 2021 09:42 PM PDT

    Can we use this repo from github to write an auto reply script for an unpaid protonmail account?

    https://github.com/ProtonMail/proton-python-client

    if so, please share any more detail pointer. Thank you.

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

    I'm having trouble with the PDFminer library in Python. Whenever I try to call a certain function it says that something is missing in the library itself

    Posted: 22 May 2021 09:27 PM PDT

    Hi there, I'm trying to work with the pdfminer library (I installed both pdfminer and pdfminer.six) and I'm having a problem when I run the PDFPage.create_pages() function.

    It gives me back an error that reads:

    File "C:\Users\Peterback\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pdfminer\pdfpage.py", line 103, in create_pages

    if 'Pages' in document.catalog:

    AttributeError: '_io.BytesIO' object has no attribute 'catalog'

    I tried uninstalling the packages and installing them again but it didn't help. My problem is that for the first time its not my crappy programming thats causing the issue so I don't know what to do lol. Thanks in advanced!

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

    How do I install Allegro (for C), WIHOUT using Visual Studio?

    Posted: 22 May 2021 09:15 PM PDT

    Basically the title, spend last 2 ******* hours trying to ******* install this ******* ****. I tried:

    1. downloading the folder from their website, and putting it in my project
    2. Installing it through nuget
    3. Installing it through vcpkg
    4. I tried exposing it to system32
    5. I tried moving all the files and libraries into my project folder
    6. I tried renaming them to allegro5, instead of allegro
    7. I tried installing from source with all dependences
    8. I tried throwing my keyboard across the room

    I am out of ideas. I NEED HELP

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

    Does realistic ANTS colony simulations exist ? Is possible ?

    Posted: 22 May 2021 05:47 AM PDT

    I really love reading about ants, and i wonder,

    Is a realistic ants colony simulation feasable ? Because ants colony are about "emergent behavior", when a lot of simple things/rules can make really complex and amazing things

    So, if you code some ants, with simple rules, a simple world, etc... And make a lot of them, can we get something somewhat close to the reality ? Maybe with complex AI things like simple neural network in each ants, giving them a "brain". Or doing a single "mega-brain" for the whole ant-colony ?

    I would love to do my end-study thesis on ants, and try to simulate them, but if it doesn't exist yet, maybe it's because it's impossible ?

    I'd love too know what you think !

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

    Concurrent users accessing same resource | java

    Posted: 22 May 2021 08:44 PM PDT

    I was asked in an interview to design a movie ticket booking system for concurrent users.My code was not accepted. I have never used multithreading. The requirement was if 2 concurrent users try to use the system.

    Say U1 and U2 select same show.
    U1 requests for and gets all Available Seats for this show.
    U1 selects group of seats and proceeds to pay.
    U2 requests for and gets all Available Seats for this show. U2 should not see the seats selected by U1 as AVAILABLE. Payment succeeded for U1.
    U1 receives Ticket with Seats confirmed.

    I couldn't wrap around how to call functions on each thread from main thread, with pauses (while I gave command to book seats to U1, I gave another command to look for available seats to U2)

    There are other scenarios as well but If I can make one, probably I can do others too. ``` public class Show {

     private String movieName; private String startTime; private String duration; private String screenNumber; private List<Integer> seats; // getter and setters here... public Show() { seats = new ArrayList<>(); for (int i = 1; i <= 10; i++) { seats.add(i); } } //books the seats selected for a user and a show public synchronized boolean bookSeats(String userName, int userId, List<Integer> chosenSeats) { for (int chosenSeat : chosenSeats) { if (seats.get(chosenSeat) > 10) { System.out.println("seats already taken"); return false; } seats.set(chosenSeat, userId); } return true; } //checks for the available seats. public synchronized List<Integer> getBookedSeats() { List<Integer> bookedSeats = new ArrayList<>(); for (int i = 0; i < seats.size(); i++) { if (seats.get(i) > 10) { bookedSeats.add(i); } } return bookedSeats; } } 

    User Class public class User implements Runnable { private String userName; private int userId; private ReentrantLock lock = new ReentrantLock(); private Show show; private List<Integer> seats;

     // getter and setters here... @Override public void run() { lock.lock(); try { System.out.println(this.userName + "seleting the shows"); Show show = this.show; System.out.println(this.userName + "Select the seats"); List<Integer> bookingSeats = this.seats; boolean isBooked = show.bookSeats(this.userName, this.userId, bookingSeats); if (isBooked) { System.out.println(this.userName + "seats booked Successfully"); } else { System.out.println(this.userName + "Please select other seats"); } } finally { lock.unlock(); } } } 

    ``` driver class:

    ``` public static void main(String[] args) { Theater theater = new Theater(); List<Show> shows = new ArrayList<>(); Show show1 = new Show(); show1.setDuration("2"); show1.setMovieName("Movie1"); show1.setScreenNumber("1"); show1.setStartTime("1100");

     shows.add(show1); theater.setShow(shows); User user1 = new User(); user1.setUserName("user1"); user1.setUserId(15); User user2 = new User(); user2.setUserName("user2"); user2.setUserId(18); user1.setShow(show1); user2.setShow(show1); user1.setSelectedSeats(Arrays.asList(2, 4)); user2.setSelectedSeats(Arrays.asList(2, 4)); new Thread(user1).start(); new Thread(user2).start(); } 

    } ``` a. If anyone can please explain me how to decouple this more?
    b. I feel everything is tied to user. Means if I want to do separate activities for example whatever I am doing in run function I could do in driver class sequentially by my input: U1 checks for tickets... U2 books ticket, etc etc. or is my assumption wrong?
    c. is it a thread safe code?How can I run this as multiple users are trying to book the ticket?
    d. Do i need to use Threadsafe Array List?
    e. How Can I implement a global session counter which can expire if a user takes long waiting time? If I sleep the thread in run function (for thread to exceed global session counter) wouldn't it make all the threads sleep?

    Thanks in advance.

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

    How to handle a class sometimes having a property and sometimes not having that property?

    Posted: 22 May 2021 02:37 PM PDT

    Hey I'm trying to learn object oriented programming by myself and have a question. I'm writing in C# using visual studio if that matters, but I think language doesn't matter for this question.

    Let's say I'm programming a chess-like game. I'll define a class Board to represent the chess board. It'll have a length and width and number of tiles based on length*width. Then I'll define a Tile class to represent the state of each tile, and I'll have the Board constructor ask for an array of Tile objects equal to the number of tiles on the board. Then I'll create a Piece class that defines how each piece works, its color, etc. I've got all that down and it's working so far.

    Here's the question: How do I handle a Tile sometimes having a Piece and sometimes not? Right now Tile has a property Piece PieceType that contains the piece currently on the tile, but there's not always a piece on all tiles. Do I make a Piece that represents the absence of a Piece? Or is there some other way to tell the Board class "sometimes this property will be here but sometimes it wont"? I imagine this is an extremely common situation but I couldn't figure out what to search for on google to find the answer so any help would be appreciated, even if it's just the name of the right concept to search for on google.

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

    Is There A Way To Stop Youtube Videos From Playing On My Computer?

    Posted: 22 May 2021 07:24 PM PDT

    Hope this question is ok to ask here.

    I've a problem with watching too many youtube videos and not focusing on studying. I keep watching one video after another.

    I want to stop this by somehow disabling youtube videos from playing and instead have to go through the motions of downloading a video if I need to watch it because I do still watch good programming tutorials on youtube.

    So I'm just trying to break my habbit.

    I had a friend years ago who did this, he made it so he could only download videos if he needed to watch them, unfortunately I'm not in touch with him anymore.

    I've put this question to Google but the only solution it gives is how to stop automatic videos from playing, not stopping them entirely.

    Thanks for your help.

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

    Ethers.js vs Web3.js

    Posted: 22 May 2021 07:00 PM PDT

    Is "Web3" a buzzword for BOTH Web3.js and ethers.js?

    Why do I see so many applications using Web3 as a buzzword and also have info on ethers.js?

    Are Web3.js and ethers.js essentially different JavaScript libraries for the same thing? How does ethers.js differ from Web3.js?

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

    Help identifying what this source code does

    Posted: 22 May 2021 05:46 PM PDT

    Hello, if anyone could please give me a tip or help on this.

    Source code and output. https://prnt.sc/13a8fxm

    I really can't find the logic of what this code is supposed to do.

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

    Don't know if I am heading towards correct path or not

    Posted: 22 May 2021 05:44 PM PDT

    Hi, I am a 2nd year student at a tier 2 college. My aim is to get into Amazon or the big N. I am good in ds and algo and currently doing leetcode, solved around 80 questions mostly mediums. But is it the right path for me , as for 3rd year, I have planned to do The Odin project and develop some skills. In my college, for 3rd year there were options for electives, I took ooad.

    Please suggest me the correct path.

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

    Getting experience as a programmer on real projects

    Posted: 22 May 2021 07:35 AM PDT

    Hi everyone, I am a high school student who would like to get some experience by working on some real projects.

    I started learning to code like one and a half year ago, made some projects for myself to get out of the "tutorial hell" and now I would like to get experience by working on real projects to see if I can actually use the stuff I learned. I am willing to work for free, I just want to gain some experience.

    Can someone please recommend me any online communities / companies who are looking for an intern front end web developer?

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

    C++ - Is there an efficient dynamic data structure that doesn't move it's memory around?

    Posted: 22 May 2021 03:08 PM PDT

    What I mean is std::vector moves around when it resizes itself, but I've written a node-tree system that uses pointers to random memory locations (thanks std::list), and I'd like to allocate memory that won't move and invalidate all of the pointers.

    My idea for writing something like this would be a linked list of arrays - each array would track which elements were in use and which were deleted. They could tombstone deleted areas or simply reuse cleared areas.

    I'm thinking about this because ultimately, I'd like to have my dinky little game engine running on the Nintendo Switch, and I'm guessing memory and performance is at a premium.

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

    [Python sockets client/server]: Why is my server not printing?

    Posted: 22 May 2021 02:09 PM PDT

    I have constructed this simple example in order to complete a much bigger project using python sockets.

    I have a simple client and server setup, and they look like this:

    client:

    import socket, time class MySocket: def __init__(self): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def connect(self, host, port): self.sock.connect((host, port)) self.sock.send(str.encode("Hello", "utf-8")) return self.sock.recv(64).decode("utf-8") def send(self, msg): self.sock.send(str.encode(msg, "utf-8")) return self.sock.recv(64).decode("utf-8") s = MySocket() print(s.connect('127.0.0.1', 1237)) print(s.send("Helloooooooooo")) 

    server:

    import socket, threading serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.bind(('127.0.0.1', 1237)) serversocket.listen() def client_thread(clientsocket): clientsocket.send(str.encode("Connected to server", "utf-8")) reply = "" while True: try: data = clientsocket.recv(64).decode("utf-8") reply = "Length of sent message is " + str(len(data)) except: break print("Received: ", data) print("Sending : ", reply) clientsocket.send(str.encode(reply, "utf-8")) clientsocket.close() while True: (clientsocket, address) = serversocket.accept() t = threading.Thread(target=client_thread, args=(clientsocket,)) t.start() 

    I run server from one terminal and client from anther. The terminal running the server does not print out any text but my client prints out:

    $ py client.py Connected to server Length of sent message is 5 

    Why is it not printing out the recieved data and what it will transmit?
    Help would be MUCH appreciated.

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

    Sha256 question

    Posted: 22 May 2021 01:45 PM PDT

    Hi guys,

    So with many cryptocurrencies in order to successfully mine a block, you will need to hash the block with a nonce(4 byte number) if the resulting value of this hash is less than or equal to the target value(2^(256 - difficulty)) then the miner will have created a block.

    I'm following this video - https://www.youtube.com/watch?v=b81Ib_oYbFk timestamp 05:34 the target value is 2^(256 - difficulty) but how can Python allow an integer of 2^256??? 2^32 is a 4 byte number, 2^64 is an 8 byte number, Python allows/has 2^256 integers?

    thanks

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

    How to pass a lambda as a parameter to a function (C++)

    Posted: 22 May 2021 01:11 PM PDT

    #include <stdio.h> float call_func(float (*f)(int)) { f(1); } float temp(int i) { return i * 0.1f; } int main() { float output = call_func(&temp); printf("%f", output); } 

    The idea is to pass a function to another function, which then calls that function, and gives you the result.

    The above works, but I must not fully understand it because it also works even if I omit the * in call_func's defintion, or the & in &temp when I call call_func. So I don't really get why that is...

    But anyway, what I really want to be able to do is something like this:

    float output = call_func([=](int i) { return i * 0.2f; }); 

    The compiler seems to think the lambda has a type of main::. How do I persuade the compiler that the lambda is the right type?

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

    Web3 and bitcoin

    Posted: 22 May 2021 12:13 PM PDT

    I see a ton of info out there about Ethereum and web3, but is web3 exclusive to Ethereum network or is this something relating to blockchain technology in general?

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

    WPF C# || How should I best simplify these events?

    Posted: 22 May 2021 11:16 AM PDT

    Hey there!

    I'm just looking for thoughts on a smaller part of a project I'm working on.

    Basically I want to be able to select multiple checkboxes, and I have them (currently) also set to private strings on each View. So when CheckBox1 is checked, it will pass "TWC.TNON" through to the "ThreeWay" private string. This is being passed to a text output in another part of the project. However I'm basically just looking for an easy way to be able to have it do the same thing and check the state of EVERY checkbox on a StackPanel, and pass the Private String associated if the Checkbox state is TRUE. Otherwise if not, I want it to pass nothing to the text field.

    I'm assuming I can omit the text field part of all of this - and just want to be able to create a better method of handling this process to check the TRUE/FALSE states of the Checkbox and pass through what I need. I'd like to be able to have the felixibily of adding MORE checkboxes as well in the future.

    The reason I'm passing a specific text through to a private string right now is because I also need the display text of the Checkbox to be different than the actual text that's output later on.

    For example.. if I have 3 Checkboxes of [ ] Cat [ ] Dog [ ] Fish - whichever is checked will actually supply "Meow" "Woof" "Gulp" to the text box.

    I'm rather new to WPF and C#. My skill set is more related to Telecom/Network related programming.

    private void CheckBox1_Checked(object sender, RoutedEventArgs e)

    {

    CheckBox1.IsChecked = true;

    {

    ThreeWay = "TWC.TNON";

    }

    }

    private void CheckBox1_Unchecked(object sender, RoutedEventArgs e)

    {

    CheckBox1.IsChecked = false;

    {

    ThreeWay = "";

    }

    }

    private void CheckBox2_Checked(object sender, RoutedEventArgs e)

    {

    CheckBox2.IsChecked = true;

    {

    ItemValue = "CLND CNDE";

    }

    }

    private void CheckBox2_Unchecked(object sender, RoutedEventArgs e)

    {

    CheckBox2.IsChecked = false;

    {

    ItemValue = "";

    }

    }

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

    JSON ~ pattern regex not working properly

    Posted: 22 May 2021 11:08 AM PDT

    Currently creating a JSON schema for a course code.

    The course code format should be: ZZZZ-1111, four letters, a dash, four numbers

    I have: "pattern": "[A-Z]{4}-[0-9]{4}" 

    but for some reason I can add more than 4 digits or 4 letters on each side. Any ideas?

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

    Getting confused before I even start (Question)

    Posted: 22 May 2021 10:48 AM PDT

    Hey all, I have some basic experience with programming and am familiar with some of the fundamental concepts, such as looping and what not. Each time I start a new tutorial however, the tutor often talks about compilers, directories and other things. Eventually, the code that I am writing, or the way that I am executing the code, all ties in with computing in general.

    I want to learn about all the things that are related to programming that don't involve actual programming. I get confused with all the terminology, knowing the difference between SDK and IDE, etc. Knowing the difference between the shell, the terminal and the command line and then understanding how they are actually used. Knowing about the operating system and so on.

    This is probably the wrong sub to post in so apologies in advance, however if anyone has any resources to start learning about all these different concepts would be appreciated.

    I just feel like at this moment I am going around in circles! Thanks

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

    Having Issue with CORS on .NET Web API Project

    Posted: 22 May 2021 10:38 AM PDT

    Hi all,

    I made a stack overflow post but thought I'd try here as well: https://stackoverflow.com/questions/67652119/getting-cors-error-in-net-web-api-project-even-while-following-documentation

    I'm having an issue with still getting CORs issues even though I've tried enabling CORs according to the documentation.

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

    No comments:

    Post a Comment