• Breaking News

    Monday, September 21, 2020

    How to add an item to... Ask Programming

    How to add an item to... Ask Programming


    How to add an item to...

    Posted: 21 Sep 2020 07:06 PM PDT

    How to add item to...

    basic list data structure function
    Javascript array array.push(item)
    C++ vector vector.push_back(item)
    Python list list.append(item)
    Java list list.add(item)
    Go slice append(slice, item)
    Rust vec vec.push(item)

    Am I the only one who has to look this up every time I swap languages... is there a reason why these languages all choose to name the act of adding to their basic list data structure so differently?

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

    What information or concepts are transferable from Microsoft Access to other SQL databases?

    Posted: 21 Sep 2020 12:16 PM PDT

    So I am taking a database class as part of the requirements for my Web Development certification program. The problem is that we are exclusively using and learning about Microsoft Access, which is disappointing because I was really hoping to learn from better database programs that use SQL. The course description didn't mention any specific program that we were using to learn database concepts either and is required to get my certificate, so I don't have any choice but to take this class. With that said, are there any concepts or information that would be useful for creating databases in general and that are applicable to SQL databases?

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

    Should we continue to invest in Razor pages or retool in pure View.js

    Posted: 21 Sep 2020 05:25 PM PDT

    We operate three marketplace websites. Our tech stack is .NET 4.5, SQL Server and a mixture of Vue.js and Razor pages on the front end with lots of jQuery. We've recently come to understand certain of our pages may not be indexed by google due to vue.js not rendering the content on first load so google bots can read the content. These pages have lots of database calls and business rules hence the complex queries on the page.

    We are currently considering:
    Option 1 - Whether to leave Razor pages completely and build the front end with Vue.js and enable server side rendering with the help of Node.js (Primary server side still .NET Framework - C#) or
    Option 2 - Remove Vue.js completely and rely on razor pages to render the pages to the client.
    Option 1 will take much longer to implement in our system due to legacy code, which will slow down delivery of our backlog. Option 2 will involve 4-6 weeks of dev and essentially means investing even more in Razor which we are concerned will be moving backwards in tech and make future development slower, make for a less stable and slower system and make attracting and retaining engineering talent harder. For some context on our business; we currently have 2 full-time engineers and considering a third.

    We would really appreciate feedback on:

    A. Are any other approaches available to help us solve this problem?

    B. What are the benefits or drawbacks to the options we are looking at?

    C. Are there long term consequences of each of these solutions? How difficult they would be in terms of implementation and maintenance?

    D. If you were in our situation which would you choose and why?

    Thanks in advance.

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

    How to automate Github to run a few SSH commands on a remote server?

    Posted: 21 Sep 2020 07:11 PM PDT

    I feel like this should be an easy task but I am not able to find any tutorials or guides on how to do it. Basically what I am looking for is if there is a commit or a merge to the master branch I want a remote server to automatically pull the updated master branch and restart a service. Is this something github is capable of or should I be looking for something to sit on the server and monitor the remote master branch?

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

    New Programming Language to learn

    Posted: 21 Sep 2020 06:47 PM PDT

    So I'm in 2nd year college taking a "Computer Science" course. So the programming language that we will use in our subject (Object Oriented Programming) is "Python" and in our Database subject, we will use the "My SQL". I just want to learn this from the very very basic until I run a program using these. So where should I learn this? Suggest me some website or tutorial videos!

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

    Do you pronounce SQL "ess cue ell" or "sequel" and why?

    Posted: 21 Sep 2020 03:05 PM PDT

    [C#][Question] I have an assignment that uses Abstract Classes and Generic Collections and I am really unsure of how to proceed. Any help would be appreciated ASAP

    Posted: 21 Sep 2020 09:41 AM PDT

    Here is the link to the assignment and highlighted question.
    https://imgur.com/a/3wl4trT

    Would really appreciate any responses.

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

    Is there some legal reason a language/framework can't use the same terminology as something existing?

    Posted: 21 Sep 2020 04:09 PM PDT

    It's bugged me for years that we have switch vs case that do the same thing, but with different words. Today I'm reading Vue vs React, Vue 3 (just released) added an idea directly from React called portals, but they decided to call it teleport instead.

    Is there some reason they can't use the same name, or do they just enjoy making things harder on developers?

    Fme, 9 times out of 10, the issues we run into are basically the same in any language, but now a search only returns half the answers unless you know the syntax another language/framework uses for the same functionality.

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

    First time interning

    Posted: 21 Sep 2020 07:27 PM PDT

    (18M) interning for my father's friend who owns a company that writes software. I've never been in any type of workplace before, nevertheless interned for somebody. Any advice?

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

    Docker-Compose, Nginx, and Hot Reloads

    Posted: 21 Sep 2020 05:34 PM PDT

    https://stackoverflow.com/questions/64001499/docker-compose-nginx-and-hot-reload-configuration

    Hello World!
    I'm looking for some help in configuring my docker-compose environment to allow for hot reloads. I've been stuck for days and would love some help if you had any ideas :)

    See link to Stack Overflow post on this!

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

    Help? How important are naming conventions in programming?

    Posted: 21 Sep 2020 05:20 PM PDT

    I work as a LAMP developer in a small group at a large university in the USA. Historically, I've been very much a lone ranger, writing code nobody else would ever see, in an environment without any explicit management layer -- and so was my coworker, who was also a LAMP developer in a different group at the same university. We're both self-taught and have been in the field for more than a decade.

    So, they put us in single group together, and we began trying to collaborate on projects. We've had some problems adjusting to this arrangement, but we respect each other and we are trying to learn to work together effectively.

    The latest issue surrounds naming conventions. His variable names tend to be snake cased abbreviations of plain English words - so "Department Supervisor" might become $dept_sup, or $dep_spvsr, or $dpt_sup, or whatever makes sense to him in the moment.

    Historically, I've done the same thing, though we end up choosing different abbreviations. I find this really frustrating - forcing me to frequently lose my cognitive flow to go find the variable name he chose, because it's not what I would have chosen.

    Recognizing that this was costing us productivity, and that my variables probably didn't make sense to him either, I proposed that we start using the full, natural English names for things, snake cased, as variable names. So, $department_supervisor, to use the earlier example. It's a lot of typing, but it should completely eliminate the need for mind reading, and typing is a lot easier than mind reading. It's also somewhat self-documenting. I see code written like this in, for example, the PHP in the WordPress core.

    He finds the really long plain English names disruptive, though, in a way that sounds similar to my complaint about ad-hoc abbreviations but might be simple resistance to change. He hasn't articulated the problem fully yet, and I've asked him to try to think about why it bothers him.

    I'd like to establish a common naming practice that enables the two of us (and any future colleagues!) to work productively and peacefully together.

    TL;DR What resources can you offer on the importance of naming conventions, how to settle on a particular rule set for naming, and so on? How do the big shops do this?

    Thanks so much to anyone who wades through this wall of text and takes the time to answer.

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

    [Python] How can I execute code after function that has to keep running?

    Posted: 21 Sep 2020 04:02 PM PDT

    So it's for a discord-twitter bot project. I have a function that keeps checking if any new tweets are available (basically an infinite loop that yields new tweet if found, else time.sleep())

    I need to run the discord bot after calling this function, but since it's an infinite loop after calling it I can't continue the execution.

    I tried to run the bot before that function ( client.run(discord_token) ) but once I do that I face the same problem and I can't execute the code after.

    I tried using async, await and an event loop that has those two tasks but I did not work.

    I also tried threading.Thread(target=foo) but did not work either.

    I've been stuck for nearly 2 days and I guess I'm doing things wrong .. Could you please help me out?

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

    Large SQL Queries (Over 5000 lines) that process data.

    Posted: 21 Sep 2020 03:52 PM PDT

    Hello, I'm working on a 5000 line mysql file that queries magneto tables and creates an internal product & category taxonomy + inventory levels. This file total 5000+ lines and it's growing.

    My question is, does working on a big mysql file like this make sense to you? I ask because a huge MySQL file like this isn't the easiest to understand or pass on to team new team members. Are there tools we should be using for data processing that would make the code more manageable.

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

    c++ getting std out error

    Posted: 21 Sep 2020 03:52 PM PDT

    Question: https://i.imgur.com/GzopER1.png

    My code:

    class Car{

    private:

    int yearModel;

    string make;

    int speed;

    public:

    Car(int y, string m){

    yearModel = y;

    make = m;

    speed = 0;

    }

    int getYear() const{

    return yearModel;

    }

    string getMake() const{

    return make;

    }

    int getSpeed() const{

    return speed;

    }

    void accelerate(){

    speed += 5;

    }

    void brake(){

    speed -= 5;

    }

    };

    Error: https://i.imgur.com/tr8wBAL.png

    I think there's an error with my speed going to negatives, but I'm not sure how to fix it.

    Any help appreciated.

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

    [C#] Questions about trying to display data from an API using POST request

    Posted: 21 Sep 2020 12:06 AM PDT

    Hello, I'm trying to display the response from an API POST request on a C# ASP.NET MVC web app.

    I'm pretty lost, just a new student, no idea what's going on.

    The code which does this must be in C# and the results from the POST request need to be taken and displayed on the website. I have absolutely 0 idea how to even start, I've tried googling but the problem is I don't even know if the guides are what I'm after. One of the guides I've looked at is this, but I'm not sure if it's right.

    I have Postman, not even sure what it does but I'm basically trying to get the results from the bottom to be displayed on the site. https://imgur.com/a/kxjitGA (don't know if these things are sensitive so I just blurred the important-looking stuff)

    The thing I'm confused about is aren't post requests suppose to put something up through a form or something while GET requests pull the data. However, I was told to use this POST request to get the data onto my site.

    If anyone has a link to a guide or can help clear things up a bit will be greatly appreciated, thanks.

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

    Producer consumer deadlocking

    Posted: 21 Sep 2020 03:25 PM PDT

    Full disclosure, this is an aspect of a class assignment.

    I have a producer consumer system that at a high level looks like this. There are four ring queues, 1 producer process, and n consumer processes. The producer continuously picks one of the four queues at random and writes a new entry to it (an integer). Each consumer picks one of the four queues at random and removes an entry from it. Consumers run until they have collected d queue entries.

    Synchronization among all processes is achieved via semaphores (I can go into detail on this if you'd like). A deadlock may occur if a producer gets stuck waiting on a full queue for a consumer to make room on it meanwhile all consumers are stuck on empty queues waiting for the producer to produce something on it.

    After playing around and running the program several times my observation is that when the program is run with a small number of consumers, the chance of the run leading to a deadlock dramatically decreases. The opposite is also true.

    Either I've done something wrong or I'm just having trouble wrapping my head around this... Intuitively I would think that a plentiful number of consumers would lessen the chance of a stuck producer and so keep the chance of deadlock way down. But the opposite is true. Am I missing something here?

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

    How to set up an environment to make several programmers work on the same website

    Posted: 21 Sep 2020 02:35 AM PDT

    I am building a website with PHP for flexibility and modularity and I do server configuration with Apache in the directories. Next to that of course html, css, JS and some mySQL. I have cloud hosting and use cron jobs to automate all this. Programming is done via an FTP connection with an IDE directly on the server. When major changes are needed I create a temporary url on which I program it and put it on the public pages when it is finished and tested.

    Previously I was the only one programming, but now I'm not alone in that anymore. That makes the above setup risky and inefficient. So I want to do version control. I came up with the following: Gitlab to do version control and branch management, XAMPP to build a server locally and preview your own developer branch, Jenkins to test the master branch and push to the production branch. I would then be the branch master that determines when something is included in the master branch and when it is pushed to the production branch on the cloud host server.

    Is this a smart setup, or could it be simpler/better? How do I setup something like this? I've spent some hours studying Git/Github/Gitlab and Jenkins, but I can't figure it out. So somehow I have to include my existing website in the picture above...

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

    Can't import the file

    Posted: 21 Sep 2020 01:34 PM PDT

    I saved a text file containting 10 names as names.txt
    Tried using

    name = np.gentotxt('names.txt', dtype=3)

    nothing happen? also tried
    open(names.txt)

    but to no help..

    Does anyone know what I'm doing wrong?

    submitted by /u/Aggressive-Cat-4824
    [link] [comments]

    Do you know any tools to take the exam online? I am looking for something simple, but with the compiler attached to a text editor. I did some research but nothing great.

    Posted: 21 Sep 2020 11:40 AM PDT

    I did some research and the closest I could find was HackerRank

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

    Developing aircraft flight dynamic for flight simulations

    Posted: 21 Sep 2020 11:36 AM PDT

    Hey everyone! I hope you're doing well.I really curious about how can I make this type of development.But I know this is hard to develop especially for the complex aircraft and exactly team work.How can I learn this process? I searched but I couldn't find any good source.Can you share any source with me ? (Books,documentary,article,video source) I will be appreciate.

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

    [Language Agnostic] Gamification - Awarded points decay over time

    Posted: 21 Sep 2020 11:32 AM PDT

    Looking for interesting ideas about how to implement the following in an attempt at gamifying a process in an IT department:

    • a task is assigned to a user
    • when the task is finished, the user marks the task as complete
    • the user is awarded points related to how quickly the task was completed
    • points are awarded and visible on a leaderboard where all users who are competing have their points tallied and ranked

    What's a good way to "decay" points as time passes?

    I'm currently just doing a "dumb" way of allowing 20 minutes to complete the task and deducting 1 point per second.. with a default amount of points added no matter what.

    This has a few issues:

    1. Users are given an incentive to hurry through the task because the points decay from the very first second it's assigned.
    2. There's a very big chance for "runaway" winners, disincentivizing people who are behind and think they can never catch up.

    Looking less for actual code and more for approaches.

    I'm writing this "off the side of my desk" and it's intended to be pretty simple. So, while I'm looking for ideas/approaches to improve it, I'm not likely to implement something huge and complex.

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

    Python interpreter error

    Posted: 21 Sep 2020 04:47 AM PDT

    I'm new to programming.

    So when I try to install phyton I get the error. "No python 3.8 installation found". How do I install it? I uninstalled it once before but now I cant get it back. I deleted the folders. I tried downloading it from the windows store (recomended on a forum) but nothing is working. how do get the 3.8 installation so I can download the latest python version.

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

    How I should progress in my learning path?

    Posted: 21 Sep 2020 05:49 AM PDT

    I am a beginner programmer. I understand some of the basic concepts and able to make a static website right now. I was actually looking for the answer for this question sometime back and found through this subreddit that the answer was CS50. I went through the course, found it interesting and even asked some of the members here about it.After which I proceeded down the CS50 path. Its been almost 2 months and I dont see any developments in my knowledge

    In summary my issue is that I understand the lectures very clearly but I am unable to practice it on the exercises. I have not been able to completely finish even one exercise. I would like to know if i should look for another medium to learn or should i approach this in a different way?

    Sorry if there are any grammatical errors.

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

    Need help with a polling function for an arduino based eeprom programmer

    Posted: 21 Sep 2020 01:45 AM PDT

    Hey all,

    So a couple of you may know who Ben Eater is, for those who don't he makes youtube videos about building computers on breadboards and goes into great detail about how it all works. I decided to take the plunge and buy a whole heap of components and make my own computer.

    Long story short I ended up making an eeprom programmer similar to that of Ben Eaters, with a few modifications. The difference is the one I am trying to make will be more comprehensive in that it will also contain a polling function and a page write function. I haven't started the page write function yet as my focus has been to try to write the polling function so I can further refine the byteWrite function (originally it had a 10 ms delay for performing a read right after when the data sheet suggests it can be much lower). The problem comes in with the actual polling function, when I try to use that for timing everything just goes haywire and I have no clue why. I have had problems from the timing being off and performing an incorrect read, to getting stuck in loops, to nothing happening at all and I'm at a loss as to what it could be.

    I also have a few other questions as to why certain things make the write function work. I've commented them in the appropriate lines of code. Happy to go into further detail if required.

    Hardware wise everything is working just fine, I've got the address going to two 8 bit shift registers and everything else being controlled by the arduino nano itself.

    Here is the datasheet for the eeprom I'm working with:

    https://au.mouser.com/datasheet/2/268/doc0006-1108095.pdf

    Here is the code:

    #define ADDR 2 #define CLK 3 #define LATCH 4 #define WE 5 #define IO0 13 #define IO7 6 byte IO = 0; int addr = 0; void setup() { // put your setup code here, to run once: pinMode(ADDR, OUTPUT); pinMode(CLK, OUTPUT); pinMode(LATCH, OUTPUT); digitalWrite(WE, HIGH); pinMode(WE, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); Serial.begin(57600); writeData(0, 3); Serial.println(IO); // SIMPLE DISPLAY FUNCTION FOR SERIAL MONITOR for (int base = 0; base <= 255; base += 16) { byte data[16]; for (int offset = 0; offset <= 15; offset += 1) { data[offset] = readData(base + offset); } char buf[80]; sprintf(buf, "%03x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", base, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]); Serial.println(buf); } } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED_BUILTIN, HIGH); delay(500); digitalWrite(LED_BUILTIN, LOW); delay(500); } void setAddress(int address, boolean OE) { // PUSHES ADDRESS TO SHIFT REGISTERS addr = address; shiftOut(ADDR, CLK, MSBFIRST, (address >> 8) | (OE ? 0x00 : 0x80)); shiftOut(ADDR, CLK, MSBFIRST, address); } void setPinMode(String mode) { // ALLOWS ME TO CHANGE PINMODES WITH A FUNCTION if(mode.equals("INPUT")) { for(int i = IO0; i >= IO7 ; i--) { pinMode(i, INPUT); } } else if(mode.equals("OUTPUT")) { for(int i = IO0; i >= IO7; i--) { pinMode(i, OUTPUT); } } else { Serial.println("PinMode set at invalid state"); } } void poll(byte data) { // THIS IS THE FUNCTION IN QUESTION setPinMode("INPUT"); setAddress(addr, true); latch(); while(true) { if(digitalRead(6) == data) { break; } } } byte readData(int address) { // READS THE DATA AND RETURNS A BYTE byte data = 0; digitalWrite(WE, HIGH); setPinMode("INPUT"); setAddress(address, true); latch(); for(int i = IO0; i >= IO7; i--) { data = (data << 1) + digitalRead(i); } return data; } void writeData(int address, byte data) { //WRITES THE DATA. ALSO HAVE QUESTIONS HERE IO = data; setAddress(address, false); latch(); setPinMode("OUTPUT"); for(int i = IO7; i <= IO0; i++) { digitalWrite(i, data & 1); // UNSURE AS TO WHY BITWISE 'AND' FIXES THIS FUNCTION data = data >> 1; } digitalWrite(WE, LOW); delayMicroseconds(1); // NEED TO TRY TO FIGURE OUT A WAY TO GET THIS DELAY DOWN TO A MINIMUM OF 100 NANOSECONDS. digitalWrite(WE, HIGH); delayMicroseconds(1); poll(IO); //delay(10); // NEED TO FIGURE OUT AS TO WHY THIS TIMER NEEDS TO BE 10 MILISECONDS IN ORDER TO MAKE THIS FUNCTION WORK. } void latch() { // LATCHES OUTPUT FOR SHIFT REGISTERS digitalWrite(LATCH, LOW); digitalWrite(LATCH, HIGH); digitalWrite(LATCH, LOW); } 

    Cheers,

    UnoDeaj05

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

    No comments:

    Post a Comment