• Breaking News

    Sunday, December 13, 2020

    I'm in a secret santa, all I know about my person is that they're a hard core programmer. What's a good practical Christmas gift? What would you ask for? Ask Programming

    I'm in a secret santa, all I know about my person is that they're a hard core programmer. What's a good practical Christmas gift? What would you ask for? Ask Programming


    I'm in a secret santa, all I know about my person is that they're a hard core programmer. What's a good practical Christmas gift? What would you ask for?

    Posted: 13 Dec 2020 11:50 AM PST

    I know this isn't your usual question but I appreciate your help and I'm also genuinely curious now that I think about it.

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

    Windows CMD not displaying extended ASCII characters correctly.

    Posted: 13 Dec 2020 10:22 AM PST

    I was watching this tutorial on how to make a game engine in a C++ console application because I thought it was neat, and I've ran into this problem that I've never had before. The video uses ASCII codes 176, 177, 178, and 219 to do shading. In the video, and for most people these seem to display flawlessly, but for me I get an invalid character box.

    Here's the full source code at the point I got stuck.

    #include <iostream> #include <Windows.h> #include <chrono> int screenWidth = 120; int screenHeight = 40; float xPos = 8.0f; float yPos = 8.0f; float playerA = 0.0f; int mapHeight = 16; int mapWidth = 16; float FOV = 3.14159 / 4; float maxDepth = 16; int main() { wchar_t* screen = new wchar_t[screenWidth * screenHeight]; HANDLE hconsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); SetConsoleActiveScreenBuffer(hconsole); DWORD dwBytesWritten = 0; std::wstring map; map += L"################"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"# #"; map += L"################"; auto tp1 = std::chrono::system_clock::now(); auto tp2 = std::chrono::system_clock::now(); while (true) { tp2 = std::chrono::system_clock::now(); std::chrono::duration<float> elapsedTime = tp2 - tp1; tp1 = tp2; float elapsedTimeFull = elapsedTime.count(); if (GetAsyncKeyState((unsigned short)'A') & 0x8000) playerA -= (0.1) * elapsedTimeFull; if (GetAsyncKeyState((unsigned short)'D') & 0x8000) playerA += (0.1) * elapsedTimeFull; for (int x = 0; x < screenWidth; x++) { float rayAngle = (playerA - FOV / 2.0f) + ((float)x / (float)screenWidth) * FOV; float distanceToWall = 0; bool hitWall = false; float eyeX = sinf(rayAngle); float eyeY = cosf(rayAngle); while (!hitWall && distanceToWall < maxDepth) { distanceToWall += 0.1f; int testX = (int)(xPos + eyeX * distanceToWall); int testY = (int)(yPos + eyeY * distanceToWall); if (testX < 0 || testX >= mapWidth || testY < 0 || testY < mapHeight) { hitWall = true; distanceToWall = maxDepth; } else { if (map[testY * mapWidth + testX] == '#') { hitWall = true; } } int ceiling = (float)(screenHeight / 2.0) - screenHeight / ((float)distanceToWall); int floor = screenHeight - ceiling; short nShade = ' '; if(distanceToWall <= maxDepth / 4.0f) nShade = 0x2588; else if(distanceToWall < maxDepth / 3.0f) nShade = 0x2593; else if(distanceToWall < maxDepth / 2.0f) nShade = 0x2592; else if(distanceToWall < maxDepth) nShade = 0x2591; else nShade = ' '; for (int y = 0; y < screenHeight - 1; y++) { if (y < ceiling) screen[y * screenWidth + x] = ' '; else if (y > ceiling && y < floor) screen[y * screenWidth + x] = nShade; else screen[y * screenWidth + x] = ' '; } } } screen[screenWidth * screenHeight - 1] = '\0'; WriteConsoleOutputCharacter(hconsole, screen, screenWidth * screenHeight, { 0,0 }, &dwBytesWritten); } return 0; } 

    The most relevant bit is probably the bit near the bottom that looks like

    short nShade = ' '; if(distanceToWall <= maxDepth / 4.0f) nShade = 0x2588; else if(distanceToWall < maxDepth / 3.0f) nShade = 0x2593; else if(distanceToWall < maxDepth / 2.0f) nShade = 0x2592; else if(distanceToWall < maxDepth) nShade = 0x2591; else nShade = ' '; for (int y = 0; y < screenHeight - 1; y++) { if (y < ceiling) screen[y * screenWidth + x] = ' '; else if (y > ceiling && y < floor) screen[y * screenWidth + x] = nShade; else screen[y * screenWidth + x] = ' '; } 

    Sorry if this is the wrong place for something like this.

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

    I am about to publish a chrome extension. What are the things that I should focus more?

    Posted: 13 Dec 2020 07:17 PM PST

    I am about to publish my first Chrome Extension.What are the things that I should consider to get a good reach.

    Are there any Subreddit where I can promote my extension? If yes, what are those?

    Is it worth Opensourcing?

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

    Creating randomized groups with multiple restrictions

    Posted: 13 Dec 2020 05:35 AM PST

    I tried to find an online group randomizer that meets my needs for a group/team randomizer, but I can't find one that covers all the restrictions, so I want to attempt building my own. I'm not sure where to start, here is the situation:

    I have a group of 65 people that is divided into 10 subgroups. From the group of 65 I want to generate 17 teams. 14 teams of 4 people, 3 teams of 3.

    - First restriction: Each team must contain no more than 1 person from one of the subgroups. For example, a correct team would be {1, 2, 3, 4}, {2, 5, 6, 3}, and an incorrect team {2, 2, 5, 8} or {10, 2, 5, 2}. (the numbers 1-10 standing for the 10 subgroups)

    - Second restriction: I have to generate team combinations for multiple weeks, whereby people cannot be matched to a person they have been on a team with in the past. So if person A and B where in the same team in week 1, they cannot be matched up in any of the following weeks

    - Third (optional) restriction: The group contains of 22 males and 43 females. Besides the first two restrictions, it would be ideal to keep the male/female ration the same across all the teams. However, this might be hard to sustain after a few rounds, so it's not a priority. It would just be nice if the program maximised this.

    Any tips on where to start? I'm a beginning programmer, so I might be in a little bit over my head. I would love some feedback!

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

    Please help me assess how to move my Fantasy F1 league to a website (approach, budgeting and other factors)

    Posted: 13 Dec 2020 05:21 PM PST

    I run a fantasy F1 league for myself and three other people. I would like to get an idea of approach and budget together for getting the picks and championship tabulation on a website, and to automatically tabulate points for each participant throughout the year after each race.

    Here is how it works today: -I create and email Google Forms for each race for each participant to enter picks -After the race, I tabulate the points scored (more below) -For each race, based on points scored, we then assign first, second, third and fourth place assigning 25, 18, 15 and 12 points, respectively -Those points go toward the Championship points for the year and are entered into a Google Sheet

    I'd like: -Race pick forms available on a website -Reminders for each race -The ability to see the other participants race picks only after a race has started -Race pick points to be automatically tabulated after a race -Championship standings updated and displayed

    How should I approach finding someone to build this? What is a reasonable budget? What else should I consider?

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

    What software can I expect to use in the workplace? (python / C++ development)

    Posted: 13 Dec 2020 11:54 AM PST

    I have a couple more esoteric questions about programming, as someone in the process of switching careers to coding:

    1) What IDEs do you use in the workplace?

    2) Does everyone typically use the same IDEs / text editors or are do you get leeway to use what works for you?

    3) Other than GIT & IDE/text editors, what software should I be expected to know?

    (Obivously your answers will vary with workplaces)

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

    What's wrong with my quicksort?

    Posted: 13 Dec 2020 06:50 PM PST

    a sorted version wasn't printed out

    #include<stdio.h> #define swap(x,y){int t=x;x=y;y=t;} int i,j; void quicksort(int arr[],int begi,int endi){ if(begi>=endi){ return; } int midi=(begi+endi)/2; i=begi-1; j=endi+1; while(1){ while(arr[++i]<arr[midi]);//find the bigger while(arr[--j]>arr[midi]);//find the smaller if(i==j){ break; } swap(arr[i],arr[j]); } quicksort(arr,begi,midi-1); quicksort(arr,midi+1,endi); return; } int main(){ int arr[20]; for(i=0;i<20;i++){ arr[i]=rand()%100; printf("%d ",arr[i]); } printf("\n"); quicksort(arr,0,19); for(i=0;i<20;i++){ printf("%d ",arr[i]); } } 
    submitted by /u/JacksonSteel
    [link] [comments]

    Settext() not updating JavaFX label on click

    Posted: 13 Dec 2020 03:00 PM PST

    I am trying to make a management system where a user must login however I want a certain fxml label to update if incorrect login information is given. Below is my GUI:GUI

    I would like the label that reads "text" to update to "Login is wrong" if incorrect credentials are given however nothing is happening on click. Below is my controller:

     public class Controller implements Initializable { Loginmodel loginmodel = new Loginmodel(); @FXML private Label dbStatus; @FXML private Button loginButton; @FXML private TextField username; @FXML private PasswordField password; @FXML ComboBox<Option> combobox; @FXML private Label loginStatus; // this method will check if db is connected and update the db label @FXML public void initialize(URL url, ResourceBundle RB){ if (this.loginmodel.isDBconnected()){ this.dbStatus.setText("connected"); } else{ this.dbStatus.setText("Not connected"); } this.combobox.setItems(FXCollections.observableArrayList(Option.values())); //this piece sets the options of the combo box //final ComboBox combobox = new ComboBox(options); } public void setTopText(String text){ loginStatus.setText(text); } //method for the login functionality @FXML public void Login(ActionEvent event){ //checks if correct credentials based on data that was input try{ if(this.loginmodel.isLogin(this.username.getText(),this.password.getText(),((Option)this.combobox.getValue()).toString())){ Stage stage = (Stage) this.loginButton.getScene().getWindow(); stage.close(); switch(((Option)this.combobox.getValue()).toString()){ case "Manager": managerLogin(); break; case "Employee": employeeLogin(); break; } } else{ this.loginStatus.setText("Login is wrong"); } } catch (Exception exception){ } } //login process for an employee public void employeeLogin(){ try{ Stage userstage = new Stage(); FXMLLoader loader = new FXMLLoader(); Pane root = (Pane)loader.load(getClass().getResource("/employee/employeeFXML.fxml").openStream()); EmployeeController employeeController = (EmployeeController)loader.getController(); //attatches the controller file to its respective fxml file Scene scene = new Scene(root); userstage.setScene(scene); userstage.setTitle("employee time"); userstage.show(); } 

    Below is my Login class:

    public class Login extends Application{ Controller controller = new Controller(); public void start (Stage stage) throws Exception{ Parent root = (Parent)FXMLLoader.load(getClass().getResource("login.fxml"));//was /loginapp/login.fxml Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Employee management system"); stage.show(); //showing the window } public static void main (String [] args){ launch(args); } } 

    Below is my loginmodel class dealing with Db stuff:

    public class Loginmodel { Connection connection; public Loginmodel(){ //this here will check if code is connected to my dbUtil.database try{ this.connection = database.Connect(); } catch(SQLException exception){ exception.printStackTrace(); } if(this.connection == null){ System.exit(1); } } // Will return true if the DB is properly connected public boolean isDBconnected(){ return this.connection != null; } //Will see if login process is working fine public boolean isLogin(String user, String pass, String opt) throws Exception{ PreparedStatement pr = null; ResultSet rs = null; String sqlquery = "SELECT * FROM login where username = ? and password = ? and division = ?"; // this try statement checks if the login works fine by passing user string as the username try{ pr = this.connection.prepareStatement(sqlquery); //will pass the query through pr.setString(1,user); pr.setString(2,pass); pr.setString(3,opt); rs = pr.executeQuery(); // executers the sqlquery boolean bool1; if(rs.next()){ return true; } return false; } catch(SQLException exception){ return false; } // anytime a connection to a db is opened, it must be closed after finally{ { pr.close(); rs.close(); } } } 

    Below is my FXML:

     <AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="loginapp.Controller"> <children> <Label layoutX="30.0" layoutY="14.0" text="Database status " /> <TextField fx:id="username" layoutX="30.0" layoutY="125.0" /> <Label layoutX="30.0" layoutY="99.0" text="Username" /> <Label layoutX="30.0" layoutY="174.0" text="Password" /> <PasswordField fx:id="password" layoutX="30.0" layoutY="200.0" /> <ComboBox fx:id="combobox" layoutX="30.0" layoutY="268.0" prefWidth="150.0" promptText="Manager/Employee" /> <Button fx:id="loginButton" layoutX="61.0" layoutY="338.0" mnemonicParsing="false" onAction="#Login" text="Login" /> <Label fx:id="dbStatus" layoutX="186.0" layoutY="14.0" text="Label" /> <Label fx:id="loginStatus" layoutX="146.0" layoutY="343.0" prefHeight="17.0" prefWidth="79.0" text="text" /> </children> </AnchorPane> 

    I am not sure what is going wrong. I would assume that when the login button is clicked, the login status label should update to "Login is wrong". What am I missing?

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

    Best coding practice for running a web server?

    Posted: 13 Dec 2020 02:11 PM PST

    Hello all,

    I have been given an extremely rare opportunity to write code for my tech company despite being in a non-software position, and I'd like to impress.

    I have a background in Python and a bit of C++, but for this project I'm using Node.js. In an effort to make my code as clean as possible, I'm trying to create a class that handles and abstracts all my API interactions.

    However, every single tutorial I read/watch and every example source code has a much more freeform structure.

    What is the typical, recommended approach here? Any good source code examples?

    Any help at all is much appreciated, thank you.

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

    How do i color a b text between ` ` to for example red on discord?

    Posted: 13 Dec 2020 01:33 PM PST

    Csv data needs to be parsed, manually added to, and used in an online calculator. What database and how would you recommend interfacing with it?

    Posted: 13 Dec 2020 09:43 AM PST

    This is not a personal project, this will be used in both web and native apps. At most 500 users when viral, more often 1 or 2 users. I'm considering MySQL

    The first step is to parse a bunch of CSV files. I'm considering python because I have professional experience with it. However the app will be in JavaScript. For this parsing step, I'm considering pandas dataframes, then back to CSV, then to mysql. However this seems like unnecessary steps, even if trivial.

    Next step is to add new data corresponding to the parsed data. I will collect prices and add to this table. Interfacing here gets a bit more complex. Python would require connecting to my server. I already have something similar working in PHP. Or now might be a good time to begin working in JavaScript because the end user will be able to manipulate the prices from default.

    And that's basically my decision. I have a plan for the calculations, I'm just not committed on how to store and manipulate the data.

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

    OpenCV Python Window scrollbar

    Posted: 13 Dec 2020 01:27 PM PST

    I'm currently working with OPENCV to draw a ROI on an image:

     # Read image im = cv2.imread(input_img) # Select ROI fromCenter = False #Used to allow us to resize the windows. cv2.namedWindow('PDF Scanner', cv2.WINDOW_NORMAL) r = cv2.selectROI('PDF Scanner', im, fromCenter) #Old version. doesnt allow window resizing #r = cv2.selectROI(im, fromCenter) # Crop image. parameters are also the locations of the ROI imCrop = im[int(r[1]):int(r[1] + r[3]), int(r[0]):int(r[0] + r[2])] 

    https://i.imgur.com/E74r6zS.png - As you can see images with high vertical resolutions get squished.

    The problem I have is that large images do not display very well (they either get squished, or they are too big to show on the screen). Is there anyway that I can get a scrollbar on the window through use of OPENCV or other GUIs such as tkinter?

    Thanks

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

    What would be the easiest programming language to switch to if I have experience with Siemens PLC ?

    Posted: 13 Dec 2020 11:50 AM PST

    Hello, if I work with Siemens PLC and other similar PLC building GUI what would be the easiest way to transition to general programming i.e. break away from PLC and find a job maybe in web programming or app development or etc ?

    Sorry I understand this is a very open ended question I'm just trying to get my bearings.

    I am not interested in C that at least I know.

    Thank you for reading.

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

    Which language for small web application

    Posted: 13 Dec 2020 10:09 AM PST

    I would like to set up a website that people can use to solve small instance of network problems (e.g. find shortest path in a graph of 100 nodes).

    What would be an appropriate programming language (or combination of languages) to implement such a project?

    Also, would it be possible to let the user's computer do the computations (for reasons of privacy and server costs)?

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

    how in quick sort the array gets updated?

    Posted: 13 Dec 2020 01:50 AM PST

    so im looking at the quick sort rec algorithm (opened in eclipse), and i just dont get it.

    i get the partition function that give the sort function the index of the pivot after partition is done, but i just return an int! how does the array gets updated inside sort if i dont return the updated one?

    i did this for example:

    public static int doit (int a, int b) { a = a + 5; b = b + 5; return b; } public static int doitn (int a, int b, int c) { int d = doit(a,b); System.out.println(d); return a; } 

    and i checked - doit does not change a and b inside doitn - in doitn it stays the same.

    what am i missing here?

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

    How are events and eventListeners not super taxing on a computer, especially in 3D games?

    Posted: 12 Dec 2020 11:57 PM PST

    Starting with the basics of event listeners, I've used them, but I guess I don't understand them.

    For example, if you have multiple, non-overlapping squares on the screen with onClick events, when the mouse is clicked does each square have to perform a check for overlap with the mouse cursor? Or is the action somehow able to only fire onClick for the impacted element?

    OnClick is one though that has a distinct trigger. What about ones that don't such as onOverlap? Does EVERY object have to be tested EVERY frame (or whatever the default check timeframe is) against EVERY other object that it could be overlapping with?

    I was trying to mess around in Unreal Engine 4, and this is where the question really grew, because you can have an object only fire an overlap method if it overlaps with other objects of a specific class. So again, you have more checks going on!

    Am I just underestimating the speed at which computers can handle all these checks? Or are they operating in a more efficient way than a list of every item and its various event checks that need to be tested for on each time interval?

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

    Using the Little Man Computer To Count Up To A Number Inputted By The User, Outputting the Sequence

    Posted: 13 Dec 2020 03:38 AM PST

    Recently I bought a project book to help me learn assembly language, but I'm struggling to solve this problem: write a program to count to a number inputted by the user in steps of 2, outputting the sequence - (increment by steps of 2) I was wondering if anyone could help me solve the problem.

    If you need any more details, please feel free to ask. Thank you in advance!

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

    Is this the right subreddit to ask UML questions?

    Posted: 12 Dec 2020 11:14 PM PST

    Wanted to know if this is the right subreddit for asking UML questions and if not which is the correct subreddit?

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

    Best tech stack for an app like wechat or gojek

    Posted: 13 Dec 2020 12:52 AM PST

    Looking for the best language to write a superapp that will literally house EVERYTHING in it. Social media Ecomm stores. Uber. Eats. Airbnb. Chatting. Venmo. Etc. Little by little additional services will be added all through the same platform. I want to avoid having to rewrite from scratch in the future because it's not scalable. Think millions of requests per minute. Is this possible? I was thinking of loading the sections as they get used so no need for so much data to be downloaded from the beginning. Any recommendations from experienced programmers would be great.

    Thanks for your time!!!!

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

    How to architecture "New Feature Announcement" for a website powered by REST API on MySQL DB?

    Posted: 13 Dec 2020 12:11 AM PST

    I have my website backend as REST API and MySQL DB. Now whenever I introduce new features to my application, I want to notify all the users of my application(website). The announcement should be visible only once to the user, once read the "new feature announcement" should gets deleted to for that user, or seen status is set to true.

    One way is to create a table feature_announcements having N:N relationship with users table. Whenever an application update is made a script should run to fill the data into that table.

    Can someone please suggest other solutions for this problem?

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

    What Gift Card API does Mistplay use?

    Posted: 12 Dec 2020 11:39 PM PST

    In case you're wondering, Mistplay is an Android app that rewards users with points for playing games - that they can spend on gift cards: https://support.mistplay.com/hc/article_attachments/360058667014/20200225_162401.jpg

    I want to build an app that can give me gift card codes on demand to reward users with. So I am curious how someone like Mistplay would be able to get gift card codes like in the above picture?

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

    Maybe someone can help me with a program called raptor?

    Posted: 12 Dec 2020 11:16 PM PST

    So here is my issue, I'm creating a psuedo ATM machine in a program called raptor, and I'm trying to use a parallel array to match up usernames and passwords for the user to log in, here are my users

    Usernames and Passwords:

    rbrown blue 123

    lwhite red456

    mblack green789

    mgreen red123

    So I build a 2 parallel arrays, One array designated usernames[5], and one array designated passwords[5]. I then populate each element of that array with my users in the usernames[] array and my passwords in the passwords[] array. Now I start a loop and begin asking for usernames and passwords, however I need the exit condition I would use for my loop to match the username and the password. For instance I have rbrown assigned to the first element of names[], and I have his password stored in the same element in the parallel array passwords[], how would I match those up? What condition would I set? I really hope this makes sense lol. If someone knows a better way to do it I would greatly appreciate it!

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

    No comments:

    Post a Comment