• Breaking News

    Tuesday, February 25, 2020

    (Javascript/ReactJS) How to declare an Array/Objects of an Object? Ask Programming

    (Javascript/ReactJS) How to declare an Array/Objects of an Object? Ask Programming


    (Javascript/ReactJS) How to declare an Array/Objects of an Object?

    Posted: 25 Feb 2020 11:46 AM PST

    Hello, I am attempting to declare a variable in the following fashion but the current syntax is incorrect. https://imgur.com/a/jM5GlQi

    What's the correct way to declare the above? I tried various things and none of them worked and not sure how i can go about this one.

    Or is the only way creating 2 dififerent Objects separately then an Array for them?

    Edit. Oopsy, the title should have been "... an Array/Object of objects".

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

    As a beginner in programming, Which language should I prefer C, C++, Java or Python and why?

    Posted: 25 Feb 2020 09:00 PM PST

    [C] Data type reference material review

    Posted: 25 Feb 2020 01:48 PM PST

    I put together some reference material from notes that I have taken over the years about data types in C and would love for someone knowledgeable to review it. Corrections and suggestions are welcomed.

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

    Creating a Tour Planning Software - Any help to get started in the right direction is appreciated

    Posted: 25 Feb 2020 02:41 PM PST

    Custom Built Tour Planning & Venue Identification System

    Hello, I am looking to have some software built, and would like any pointers or guidance to start heading in the right direction with this. Listed here are the requirements for the program. Ideally, it would fill in open spots using our venue database. This would allow us to put in two points, and then could show suggestions between points A and B.

    -Identifying potential venues to fill open tour spots

    -Filter by driving distance away from route to next spot

    -About 7,500+ venues in our database

    -Creating a report of the venues info once route is finalized

    Below is an image of some concepts for how it could look/feel. Any help is appreciated.

    https://i.imgur.com/K2EoOrB.png

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

    Arduino project with graphical interface

    Posted: 25 Feb 2020 02:24 PM PST

    I need some advice on what language / environment to use.

    I'm doing a project that

    • connects to an arduino with 6 buttons through serial
    • buttons control simple user interface
    • interface has lots of animations (2D/3D, etc.)
    • needs to be connected to databases easily
    • runs on windows 10

    Some ideas:

    • WPF - easy to connect to arduino, animations seem like a hassle though, 3D tutorials on youtube are like 10 years old and not impressive
    • Unity - easy 2D, 3D animations, though needs a workaround to connect to arduino, no idea about databases etc.
    • standard html5, css, javascript app, though it's probably shit for serial communication

    Any ideas?

    submitted by /u/Accomplished-Routine
    [link] [comments]

    [Python/Webapp] How do I connect/Where do I start to build a webpage that talks to python program on my server?

    Posted: 25 Feb 2020 12:48 PM PST

    Hello,

    I am pretty confused when it comes to connecting multiple things into one functioning system. I have a python program that analyzes telegram html files containing messages and builds a database. Then it creates graphs using sql queries and matplotlib. Now I thought about making a front-end for this application on a page, where I could upload files which would be sent to my server, analyzed and then displayed as graphs.

    No idea where I should start. I know how build a static page, I know how to build python program. But I have no clue how to make a page that connects them all. I started learning d3.js to build graphs.

    What should I learn/where should I start with dynamic pages that send data to my server and get replies.

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

    [JS CSS] Can you tell me of a more clever way of de-selecting one button when you select another than storing the id of the old button?

    Posted: 25 Feb 2020 12:45 PM PST

    I made a small example for you:

    https://www.w3schools.com/code/tryit.asp?filename=GC0BAVI00XMZ

    My issue is that I feel that storing the currently selected button id in a variable, so you can invoke it when another button is selected and revert the originally selected button's class and content to a normal state, is kind of a wonky solution.

    This was my way of doing it before I learned about querySelector and the power of children classes, and I feel like the answer lies there somewhere, but I just can't see it. Looping with a query selector, trying to find the one of the buttons that is of class "selected" feels also as wonky and wasteful as making a variable. But I dunno what would be better and more legit. What would someone who knows what he is doing do (within the borders of vanilla js and css)?

    tnx!

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

    Android: Populating EditText with String array

    Posted: 25 Feb 2020 12:31 PM PST

    Is there any way to populate an EditText with a string array of comma seperated values? At the moment with this code the EditText only displays the last element of the array, eg: if ingredients1 was 1, 2, 3, 4, 5 then only 5 would appear in the EditText.

    String[] ings = ingredients1.split(",");

    ArrayList<String> iList = new ArrayList<String>(Arrays.asList(ings));

    mIngredSend = (EditText) findViewById(R.id.etSendIngred);

    for (String ing : iList) {

    mIngredSend.setText(ing + ",");

    }

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

    Player destroys closest entity

    Posted: 25 Feb 2020 11:24 AM PST

    I'm trying to get the player to destroy an entity in my game but can't figure out a way for the player to decrease the health of the entity, I'm trying to do it that when the player presses the space bar, it will decrease the health of the closest entity, the way I'm calculating closest is using Axis aligned bounding box methodology, the entity class is abstract and I am creating other entities using that like player and rock

    the Code in the Player class for checking if the space bar is down is

    if (window.getInput().isMouseButtonDown(GLFW.GLFW_KEY_SPACE)) attack(); 

    the attack method on the player class is still empty

    public void attack() { } 

    the code in the entity class for hurting the entity is, where active is a boolean and returns true until the health is at 0

    public void hurt() { health -=1; if(health<=0) { active = false; destroy(); } } 

    in the render method in the world that renders entities, it stops rendering the entity isActive is false

    for (Entity entity : entities) {// itaarate through all the entities in list of entities entity.render(shader, camera, this);// render each entity if(!entity.isActive()) entities.remove(entity); } 

    the AABB code that checks which is the nearest entity is

    AABB[] boxes = new AABB[25];//surrounds entity with 5*5 bounding boxes for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { boxes[i + j * 5] = world.getTileBoundingBox( (int) (((transform.position.x / 2) + 0.5) - (5 / 2)) + i, (int) (((-transform.position.y / 2) + 0.5) - (5 / 2)) + j); // gets everything around player for // bounding boxes } } AABB box = null; // // getting closest box // for (int i = 0; i < boxes.length; i++) { if (boxes[i] != null) { if (box == null) box = boxes[i]; Vector2f length1 = box.getCenter().sub(transform.position.x, transform.position.y, new Vector2f()); Vector2f length2 = boxes[i].getCenter().sub(transform.position.x, transform.position.y, new Vector2f()); if (length1.lengthSquared() > length2.lengthSquared()) {// used squared to save cpu power box = boxes[i]; } } } // // colliding with it // if (box != null) { 

    what im trying to do is call the hurt method on which is the closest entity to the player when the user presses space

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

    Web Dev CSS Grid Newbie

    Posted: 25 Feb 2020 11:12 AM PST

    Tried to create a layout like Reddit with a light gray background and white boxes.

    background and boxes do not show up

    https://codepen.io/SamsSams/pen/LYVWVrr

    What am I doing wrong please?

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

    [JS] How is the .onclick function stored in memory, waiting to be activated?

    Posted: 25 Feb 2020 05:04 AM PST

    While messing with querySelector I suddenly realized that I already have the element object reference stored in a variable from when I created it. That would mean that instead of this_parent.querySelector(".surname").style.backgroundColor = "RoyalBlue"; , I could just use surname.style.backgroundColor = "RoyalBlue"; so I don't know. The first one looks more legit, but the second one works just as well.

    And this brought me to my question. The first solution is unmistakeable, but in the second one how does the computer know that this specific instance of var surname in that specific loop of the creation of that specific element is the one that should be linked to .onclick? Owait, I think I can guess. Maybe the variable contains the reference to this specific element object, and that reference is somehow stored in the function waiting to be executed, and in another loop the element object will have a different address because it is a different entity, and this is why they can be differentiated.

    So, in short:

    1. Where exactly are the references computed and stored, waiting for execution?

    2. is the second way of doing it legit and better or worse than the first one?

    Tnx

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

    I have advanced Vanilla Javascript knowledge. I want to create a small bussiness website, where to start?

    Posted: 25 Feb 2020 10:59 AM PST

    Hello guys,

    I'm currently working with SharePoint on my workplace. I got a lot of knowledge on Vanilla Javascript (html and css too), from creating custom solutions on Sharepoint pages. Using ajax and rest api to get data from SP lists and using plugins for the front-end side of the website.

    The thing is I know nothing about the server side thing on websites.

    I used a google a lot for this, but there are SO MANY OPTIONS on where to start. And I thought that maybe someone could help me buy nudging me in the right direction.

    I'm not afraid to learn and to spend hours on it. I just want to be sure that the thing that im trying to learn is going to be the right thing for what I need.

    If I wanted to create a website for a Nutritionist in which I can show:

    • Photos of the place on a gallery.
    • Contact forms.
    • Services.
    • etc...

    For now ** I think I don't need** more advanced stuff like a shop, chat... Stuff that I guess would need a Mysql database. Or maybe I do but I don't know because of my low experience on this field.

    What should I start looking at first? Looking for a host, looking for tutorials on where/how to build this kind of thing?

    If someones knows where what I should start learning, do you have a example or tutorials that I could follow?

    Thank you so much!

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

    Need some quick assistants with Python 3 turtle function for class

    Posted: 25 Feb 2020 10:52 AM PST

    long story short i am in a computer programming class and cannot for the life of me find out what is wrong with this code. If you could help me out GOD BLESS YA if not that's fine i am still trying google xD. my code has to look somewhat like it does down there, ofcourse with some addons to fix the code. Try it imagine you are first starting to learn Python 3, that is what level i'm at right now.

    edit: Sorry, i meant class as in the class i goto

    Code:

    import turtle

    tess = turtle.Turtle()

    wn = turtle.Screen()

    steps = [160, -43, 270, -97, -43, 200, -940, 17, -86]

    for num in steps:

    tess.tilt(steps) #i am getting the error here!

    tess.forward(100)

    print(tess.heading())

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

    I can't think of the name of a tool I'm looking for.

    Posted: 25 Feb 2020 06:33 AM PST

    I believe is a MS tool. It's like a mini version of visual studio. It's not the Community Edition. You can write code and compile it. I just can't recall the name. Thanks in advance.

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

    Best practice to change SQL data

    Posted: 25 Feb 2020 09:32 AM PST

    Let's say I have a postgreSQL table being written to about 100 rows every minute and one of the columns is a datetime field (without timezone) in CST timezone. I want to make a change to it so that the timezone would be GMT.

    Here's my idea:

    1. Alter and add a new column called isGMT with a falsy default value
    2. Change the code writing to table so that the datetime field is in GMT timezone and set isGMT to true
    3. For rows where isGMT is falsy, update the value of the datetime fields to GMT timezone
    4. Remove the column isGMT

    This seems like a lot of steps and I'm wondering if there's a better way.

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

    What was your "uh-huh" moment?

    Posted: 25 Feb 2020 04:48 AM PST

    What was your "uh-huh" moment for coding? The point where you felt like you finally got the hang of it?

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

    Does StackOverflow have a tag for the programming language Q (the language from Kx Systems)?

    Posted: 25 Feb 2020 08:03 AM PST

    I know that SO has a tag for `q` but it doesn't seem to be the correct language for the language that is used by Ks systems. Is there a tag for this language or not?

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

    Where do I find data regarding Software engineering

    Posted: 25 Feb 2020 06:39 AM PST

    More precisely I want to find out how many People graduate yearly as Software engineers relative to the Jobs that Open yearly in that field

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

    How to represent a yang file as an object tree in Python

    Posted: 25 Feb 2020 06:04 AM PST

    I would like to represent a yang file as a tree data object in Python. I haven't found any libraries online that can accomplish this. One option I did come across was convert the yang into it's corresponding yin then use one of Python's xml libraries from there. However, I'd rather avoid that extra step if I can. Does anyone have suggestions of libraries or other methods that could accomplish this?

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

    How much Math is required for Game development?

    Posted: 25 Feb 2020 02:18 AM PST

    How good do I need to be at math to dip my toes into Game development

    What concepts complex or simple do I need to have a good understanding of?

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

    Best way to share one dev environment across multiple pcs

    Posted: 25 Feb 2020 02:16 AM PST

    So I have a situation currently. I have 3 setups, a pc at work, a pc at home, and a laptop for on the go. And I am trying to find out what the best manner in which you keep all the same env across all machines. For example, when I install an extension in vscode on my laptop, it needs to auto install on the other systems.

    What is the best way that you have come across to set this up?

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

    Suggestions for technologies for my project

    Posted: 25 Feb 2020 06:01 AM PST

    Need help from a programmer

    Posted: 25 Feb 2020 05:56 AM PST

    Not sure if this even is the right sub to ask for help, but I've got myself in the sort of trouble that only a programmer can fix.

    I've created a fairly lengthy index for a book, and realized at the end... there is no page 28 in my document.

    -_______________________________________________-

    So every number in my index from 29 on is one too high. Is this an easy fix? If anyone can help a poor editor out, you would earn heaps of IRL karma. Please!!

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

    Player destroys closest entity

    Posted: 25 Feb 2020 11:38 AM PST

    I'm trying to get the player to destroy an entity in my game but can't figure out a way for the player to decrease the health of the entity, I'm trying to do it that when the player presses the space bar, it will decrease the health of the closest entity, the way I'm calculating closest is using Axis aligned bounding box methodology, the entity class is abstract and I am creating other entities using that like player and rock

    the Code in the Player class for checking if the space bar is down is

    if (window.getInput().isMouseButtonDown(GLFW.GLFW_KEY_SPACE)) attack(); 

    the attack method on the player class is still empty

    public void attack() { } 

    the code in the entity class for hurting the entity is, where active is a boolean and returns true until the health is at 0

    public void hurt() { health -=1; if(health<=0) { active = false; destroy(); } } 

    in the render method in the world that renders entities, it stops rendering the entity isActive is false

    for (Entity entity : entities) {// itaarate through all the entities in list of entities entity.render(shader, camera, this);// render each entity if(!entity.isActive()) entities.remove(entity); } 

    the AABB code that checks which is the nearest entity is

    AABB[] boxes = new AABB[25];//surrounds entity with 5*5 bounding boxes for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { boxes[i + j * 5] = world.getTileBoundingBox( (int) (((transform.position.x / 2) + 0.5) - (5 / 2)) + i, (int) (((-transform.position.y / 2) + 0.5) - (5 / 2)) + j); // gets everything around player for // bounding boxes } } AABB box = null; // // getting closest box // for (int i = 0; i < boxes.length; i++) { if (boxes[i] != null) { if (box == null) box = boxes[i]; Vector2f length1 = box.getCenter().sub(transform.position.x, transform.position.y, new Vector2f()); Vector2f length2 = boxes[i].getCenter().sub(transform.position.x, transform.position.y, new Vector2f()); if (length1.lengthSquared() > length2.lengthSquared()) {// used squared to save cpu power box = boxes[i]; } } } // // colliding with it // if (box != null) { 

    what im trying to do is call the hurt method on which is the closest entity to the player when the user presses space

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

    No comments:

    Post a Comment