• Breaking News

    Tuesday, November 30, 2021

    that "sixth sense" you get when you work on a code base for long enough: how to explain it to managers, and how to not sound like a pompous know-it-all when talking about it Ask Programming

    that "sixth sense" you get when you work on a code base for long enough: how to explain it to managers, and how to not sound like a pompous know-it-all when talking about it Ask Programming


    that "sixth sense" you get when you work on a code base for long enough: how to explain it to managers, and how to not sound like a pompous know-it-all when talking about it

    Posted: 30 Nov 2021 12:57 AM PST

    so basically when you first start working with a codebase you have no idea how the inner pieces work together, even though you know the language it's written in.

    like when there's a bug and you basically already know what the problem is because you know how the code works instinctually without needing to actually read the code.

    I've had experiences where a non-programmer manager would say that some new person is slow, when they are supposed to be "experiened developers" in the language.

    what is the best way to explain to managers that it's not the actual language itself, but the inner workings that you need to learn, and right away we really don't know how the thing works until we spend time with it.

    and I think I make myself sound like an asshole when they are talking about a discovered bug and I'm like "oh I already know what the problem is and why" and they think I am super smart but really it's because I just "know" how the code works, so I know what the problem is?

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

    Do people actually hate regex?

    Posted: 29 Nov 2021 07:07 AM PST

    I've seen my fair share of jokes about no one understanding or liking regex but do people really find it that bad? I've taken college classes in it and on occasion had to use it in projects. I've never sat there and though "sigh this sucks" or "this is impossible"? So I ask do people really hate regex or am I just in the minority of people who enjoy it?

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

    HackerRank difficulty

    Posted: 29 Nov 2021 06:26 PM PST

    Hi guys,

    I'm a starter on the market. I applied for a job as a devops cloud engineer. I received a link for a HackerRank challenge of that company for junior staff.

    The recruiter said that the difficulty isn't high and that I have 24 hours to finish the test when I start it. But holy sh*t I got scared when I saw the practice questions on the site. It seemed like die hard Math instead of python related questions.

    Is it weird that I'm scared?

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

    Please help me to find a new project (Python | Beginner - Intermediate)

    Posted: 30 Nov 2021 01:11 AM PST

    Hello everyone,

    I am still kind of new to programming, I have finished 1 project until now and have only worked with Python and Bash (I did some useful scripts for bash that made my life with linux easier so nothing special, though I know how to handle scripting and the console itself).

    I am at a point where I would really like to just learn more and practice a lot, so I'm looking for a new project that I could do in python, using object oriented programming (I havent really worked with classes yet), but I have absolutely no ideas for something that makes sense to make, is not too hard and also maybe will be kind of useful.

    So I'm asking you guys for help now. If you have any recommendations on what projects I might want to look into, I would love to hear about it. I'm always up for a challenge so it shouldnt be too easy and I would also like to work with many different aspects of the language so the more creative I have to get for a solution, the better.

    I appreciate every idea, Thanks in advance!

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

    why does my youtube-dl command not work?

    Posted: 30 Nov 2021 01:09 AM PST

    this shit is driving me crazy. I was just gonna let it run for a few hours while I finished a few errands, and now I've been sitting here for like 2 hours trying to get his shit to work despite not knowing anything about programming or windows or command lines.

    This command, that used to work fine in the past:

    youtube-dl --download-archive "archive.log" -i -o Z:\dl"%(playlist_index)s-%(title)s.%(ext)s" -f bestvideo+bestaudio

    now always yields this result:

    pic 1

    pic 2

    I used yt-dlp but I tried going back to youtube-dl and every time it's the same result. I also tried not having a destination folder, and nothing but "youtube-dl [URL]", and none of it worked. I also tried putting the latest version of ffmpeg in the youtube-dl folder itself and that didn't work either. I've tried the latest version of everything. And I know that "Z:\dl"%(playlist_index)s-%(title)s.%(ext)s"" is wrong, please don't tell me that it's the problem or I may actually go off the deep end.

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

    How difficult would it be to take a Spotify playlist and get the genre of each song from Beatport?

    Posted: 29 Nov 2021 06:31 PM PST

    Doing this manually song by song, playlist by playlist is a PITA. The Beatport search function is so slow.

    Would it be feasible for someone who has basically almost no experience to figure this out? I've done like a bit of scripting in bash and am not completely useless but essentially don't have any real programming experience. I would just need the output to a text document as opposed to putting them in separate playlists.

    Also is there a subreddit where you can get people to do 'smaller' tasks like this like fiverr or something?

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

    2-D Barcode Programming

    Posted: 29 Nov 2021 08:16 PM PST

    Hello r/AskProgramming

    I'm hoping this is the right sub to ask this. If not can someone direct me to the correct one?

    Basically, I have a 2-D bacode (Symbol DS6707-SR20007ZZR) and I have a software called BarTender by Seagull Scientific which creates barcode. I'm just trying to create a 2-D barcode that once I scan it on Microsoft Word or Excel, etc, I want the outcome to be like ex) 12345678 *tab* 1234 like this YouTube video here: https://www.youtube.com/watch?v=c-KLUxegQeg

    However, in the BarTender software there's a space called "Screen Data" where you can write down what you want the barcode to bring out after scanning. I tried to follow directions like the youtube video, but it didn't work. I was wondering if anyone can point out what I'm doing wrong or what's the BarTender function name for "Tab"

    Thanks.

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

    Opinion on generated interfaces

    Posted: 29 Nov 2021 11:47 PM PST

    I'm trying to find a solution for the following problem:
    How to automate and speed up work on routine front-end development tasks.

    So i wanted to gather some feedback from community if that's okay.

    The original idea was to create partially or even fully generated interfaces.
    A tool, that will minimize the work of Front-end developer. Something that will generate widgets, that can be used in new projects (widgets like tables with filters, sorting and pagination, toasters, forms, buttons, different inputs). Big widgets, like tables can be pre-integrated with back-end.
    So with that tool, front-end developer job would be to configure where to put a widget, some styles and base urls, but, ideally, that's it.
    Something like Extjs, but not so overly complex and more flexible with the ability to use it in projects based on different frameworks.

    I understand that customization can be difficult. If interface elements have predifined layouts and css styles, customization will be limited. But, is there a way to solve this problem?

    Does someone have any ideas what approach can be chosen here?
    May be my thought process is incorrect and there is some other solution on how to automate routine task in front-end that you can think of?
    And also, as front-end developers, if something like this existed, would you use it?
    I know that for a lot of front-end devs its easier and more reliable to create widgets for their projects themselves (at least this is true for devs I work with), but wouldn't you want an instrument to speed up the work on routine tasks?

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

    Can PSO be implemented to solve SLR models?

    Posted: 29 Nov 2021 11:17 PM PST

    I'm wondering how Particle Swarm Opmization can be used to solve Simple Linear Regression problems, where the LR function is y = a + bx given a certain dataset.

    I understand how to solve Linear Regression problems implementing Gradient Descent and Genetic Algorithms, but I can't find begginer information on how to use a PSO approach to this type of models or a similar predictive model.

    I would appreciate any help and thanks in advance.

    P.S. This is the SLR problem in particular I'm trying to solve: https://www.displayr.com/what-is-linear-regression/ . I'm just interested in knowing how to get b and m values from y = b + mx.

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

    Generated Interfaces

    Posted: 29 Nov 2021 11:00 PM PST

    I'm trying to find a solution for the following problem:
    How to automate and speed up work on routine front-end development tasks.

    So i wanted to gather some feedback from community if that's okay.

    The original idea was to create partially or even fully generated interfaces.
    A tool, that will minimize the work of Front-end developer. Something that will generate widgets, that can be used in new projects (widgets like tables with filters, sorting and pagination, toasters, forms, buttons, different inputs). Big widgets, like tables can be pre-integrated with back-end.
    So with that tool, front-end developer job would be to configure where to put a widget, some styles and base urls, but, ideally, that's it.
    Something like Extjs, but not so overly complex and more flexible with the ability to use it in projects based on different frameworks.

    I understand that customization can be difficult. If interface elements have predifined layouts and css styles, customization will be limited. But, is there a way to solve this problem?

    Does someone have any ideas what approach can be chosen here?
    May be my thought process is incorrect and there is some other solution on how to automate routine task in front-end that you can think of?
    And also, as front-end developers, if something like this existed, would you use it?
    I know that for a lot of front-end devs its easier and more reliable to create widgets for their projects themselves (at least this is true for devs I work with), but wouldn't you want an instrument to speed up the work on routine tasks?

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

    Polling and Long Polling still used?

    Posted: 29 Nov 2021 06:28 PM PST

    Are polling and long polling still used? It seems websocket has replaced these two.

    One thing that *might* use polling is heartbeats. You send a request every once in a while, and you are expecting a response acknowledging that the server has gotten the heartbeat, and that the connection is still alive.... or something along those lines.

    Edit: If so, what are cases where polling/long polling is better? Or what application simply uses polling/long polling?

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

    How to calculate the velocities of two colliding circles?

    Posted: 29 Nov 2021 05:23 PM PST

    Hi. I'm toying around with JS and Canvas and decided to make some bouncing objects that have collisions and obey gravity. The code works perfectly fine if the balls have equal masses. Otherwise, it tends to behave incorrectly. And by "incorrectly" I mean that the sum of the speeds after the collision are greater than the sum of the speeds before the collision.

    Input: Two ball objects.

    ball object fields: x: float, y: float, vx: float, vy: float, mass: float

    Goal: Given two ball objects (ball and other), calculate their new velocities after they collide.

    Current code: ```javascript let dist = distance(ball, other); if (dist <= collide_dist) { // Calculate the speeds of each ball let ball_speed = Math.sqrt(ball.vx2 + ball.vy2); let other_speed = Math.sqrt(other.vx2 + other.vy2);

    // Fetch the angle between the balls let angle = Math.atan2(ball.y - other.y, ball.x - other.x); let sin = Math.sin(angle); let cos = Math.cos(angle); // Controls how "bouncy" balls are when colliding // Note that a value of above 30 tends to make the balls chaotic // Literally, this is the distance the ball will travel // TODO: This formula is incorrect; it calculates values above 30 (BAD) let ball_dist = (ball_speed + other_speed) / (2 * (ball.mass / other.mass)); let other_dist = (ball_speed + other_speed) / (2 * (other.mass / ball.mass)); // Compute new velocities let bx = ball_dist * cos; let by = ball_dist * sin; let ox = other_dist * cos; let oy = other_dist * sin; // Update velocities ball.vx = bx; ball.vy = by; // Negative values because `other` goes the opposite direction other.vx = ox; other.vy = oy; 

    } ```

    Problem: The ball_dist and other_dist lines are calculating incorrectly. They should be values between 0 and 30 (from testing, values above 30 tend to "generate" energy and cause the balls to move faster than before colliding).

    I think the issue lies in the / ( 2 * (ball.mass / other.mass) ) because when the ratio is 1.5 or greater, the resulting speeds are too high.

    I'm not entirely sure what formula(s) to use. Any ideas?

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

    Online rook game

    Posted: 29 Nov 2021 10:43 AM PST

    I was wanting to create an online rook game since the one on the appstore, at least google playstore doesnt have many downloads and from the pictures doesnt look good. I was wanting to make my own since my grandparents love to play rook and id love to play Online with them. For right now, id be fine hosting a server to play with just 4 people, but long term id like to create an online game thats in the browser. I have a bit of coding experience, c++, python, bit of java. Whats the best way to go about this. Ive seen various posts about game dev and wasnt sure what approach was best for what i was wanting. It would be 2d so i wasnt going to use unity or unreal engine. Just a simple game that would look pretty. Thanks for any advice or guidance.

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

    Help in choosing idea

    Posted: 29 Nov 2021 07:47 PM PST

    So Im working on a project where I have a stock class with stock name, stock value, stock volume and stock volatility. I have another class profile with list and amount of stocks the profile has, value to invest, total value of stock profile has. I was thinking about creating a knapsack method to get stocks that would recommend stocks to buy. But the problem is that for knapsack we need stocks to have a weight and value. The stock value would be the weight but I can't compare 2 stocks with the same stock value. Should I try to stick with knapsack by using the volume and volatlity for the value in knapsack . Or would it be better to make a method that compares stocks change from previous day and current value and would return an ordered list of the recommended stock to buy based on value to invest.

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

    Passwords get hashed and salted when stored in DBs. - Why don't we at least hash all login details (email, username, etc.)

    Posted: 29 Nov 2021 12:17 AM PST

    Hey all!

    I recently started to configure/write the registration, login and password reset parts of my backend, and I had quite a few thoughts. I'd like to hear your take on it.

    My app is quite basic on the backend, simple database queries and sending a rendered page to the client. Since I am lazy AND afraid, I was thinking a lot about "what if someone exploits an input and manages to dump all tables?".

    Here's the thing, all things I store in the DB are public data anyway. Paths to pictures (pictures are public), names and handles, text, etc. EXCEPT for the email-address, the password obviously and the login username (!= display name).

    So these three fields are the ones that worry me in case the db gets dumped and made public.

    The password is hashed and salted, but why do I not salt and hash the other two fields? (or at least store them hashed?

    If I want to login, I provide username and password -> compare both hashes at login

    If I reset my password via Mail -> I provide the mail-address and compare the hashes to verify it exists.

    I understand that you can't use these informations then in the backend, for example for mass sending marketing mail, or if you hash a CC Number, you can't do monthly billing with auto renewal (same with for example a paypal mail address), but if I have not monthly billing, want to send mass mails or charge a CC when certain events occur, this sounds like a reasonable thing to do.

    It sounds too good to be true actually, that way I would not have to care much about the disaster scenario (that might not happen if I sanitize inputs, which I do, an harden the DB/Server).
    My biggest fear, as this is the first App I launch officially to the public, is the high GDPR fine when data get's breached, but if public data is public anyway, and private data is hashed, I might not be liable (that's going to be discussed with a lawyer anyway), but at least my users wont show up in any breach databases or receive even more spam.

    Long story short: why don't we hash all data in the DB that is not used, private and relies on user-input anyway? What's the downside?

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

    Best way to capture news sites headlines to a db or text based file?

    Posted: 29 Nov 2021 07:36 PM PST

    Trying to not to reinvent the wheel here and looking to see if there's something that's fairly entry level customizable or already existing in the wild. Some sort of RSS reader that I can run 24/7 and it just stores text data of the headlines. That I can dump on a simple db or something csv? I have rusty db skills T-SQL/Access. Plug in the news sites url.. any ideas? Ideas on where to start if I wanted to code this myself?

    thanks!

    submitted by /u/GenX-73
    [link] [comments]

    BIS major and a coding job

    Posted: 29 Nov 2021 02:12 PM PST

    My son will soon graduate with a Business Information Systems degree. He had 5 courses that involved coding. His first python class was the first class of any kind he ever enjoyed, his second python course was easy for him. He loved his class where he built mobile apps with Ionic. One course was basically 'learn SQL workbench, create SQL queries', the other 'learn Excel and some VBA'.

    Is that enough coding experience to get a coding job? Anybody ever go to a school sponsored job fair with a BIS degree? My son is kind of surprised programming was easy, he didn't ever expect to code for a living, but now he's wondering because he seems to like it.

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

    Why does background processing a service automatically restart it

    Posted: 29 Nov 2021 05:30 PM PST

    Hello World!

    A while ago I struggled to get a server launched using a docker container with a weird issue that I couldn't really ever figure out. Assume that example1.js and example2.js are both servers.

    When using:

    node example1.js 

    The server starts up fine and everything works perfect.

    When using:

    node example2.js 

    The server starts up fine and everything works perfect.

    When using:

    node example1.js & node example2.js 

    The service suddenly broke saying "port 4000 was already in use". That was an incredibly strange error to get since there was 100% nothing using port 4000, the only service using port 4000 on that machine was example1.js itself. This error was very strange to me since it made absolutely no sense why the server was restarting itself or trying to start itself twice.

    I later on figured out that using:

    nohup node example1.js & node example2.js 

    Works perfect.

    I learned that nohup catches the SIGHUP signals, or creates them, among other things to keep the process alive. I don't know the exact details of how that works but that's not really the confusing part to me. What I could figure out is that since the service is restarting itself, or failing, nohup catches the signal and correctly closes it, before starting it again.

    Up to today the one thing I still don't understand is why is nohup needed at all, why is that service restarting itself, or starting itself twice, in the first place, what is going on there? The part that's really confusing to me is why it would throw a port conflict on itself, when there's nothing that's telling it to restart itself or start itself twice. Even if it just straight up failed, or never started, I'd get that, but not just restarting itself.

    Can anyone explain to me what's happening here?

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

    Will I see any benefit choosing PCIE 4.0 over PCIE 3.0 SSD, for programming?

    Posted: 29 Nov 2021 04:24 PM PST

    Hello,

    I am wondering If I would actually see any performance and making things run smoother, If I choose PCIE 4.0 SD over the older PCIE 3.0 model for programming?

    Most of the time I am coding on Java, using IntelliJ Idea and using couple of docker containers.

    As far as I've heard, at the moment there is nothing that can reach the read speeds of PCIE 3.0 SSDs, let alone the 7000 MB/s read speeds of PCIE 4.0, is this right?

    Will I see any difference, on the smoothness of the IDE, compiling code, indexing files etc... If I choose to go PCIE 4.0?

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

    How to ignore a noise value in real time?

    Posted: 29 Nov 2021 03:32 PM PST

    I'm trying to make an alarm program that goes green when above 4.27v, goes red when below -2.56v, and no light in between these values. I have been supplied with a dataset from which I'm supposed to continuously read and make the alarm goes off accordingly. But there are some noise in the data when it's in the high values and I'm supposed to ignore these noise so the alarm doesn't flicker.

    For example, if the reading goes 4.30 > 4.40 > 4.20 > 4.50 > ...I have to ignore the 4.20 and the alarm have to keep being green, not turn off for 1 second then turn on again.

    This is what I have tried, but it still flickers:

    high_alarm = 4.27 low_alarm = -2.56 Q = 0.009765625 prev1 = 0 prev2 = 0 for i in range(120): volt_bit = my_daq.next_reading() volts = volt_bit * Q - 5 prev2 = prev1 prev1 = volts if volts > high_alarm: # green light bstick.set_color(index=6, name="green") elif volts <= high_alarm and volts >= low_alarm: if prev2 > prev1 and volts > prev1: continue lights_off() elif volts < low_alarm: # red light bstick.set_color(index=3, name="red") 

    I also have the idea to compare both previous and next data to the current value, but that's not possible because I have to do it in real time, so I'm not supposed to know future readings, only current & previous ones.

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

    Does an Italki for Programmers exist?

    Posted: 29 Nov 2021 07:26 AM PST

    Every year I try to get into programming. I have tried so so many ways to get started, but there is always something that stops me from progressing. Now for example is my virtual environment that is not clean at all.

    I think a mentor would be the right approach for the situation I am in. I have so many projects I want to work on but for that, I need a push at the start to get the idea of what/Where things are.

    A platform like Italki does for people who want to learn new languages but for coding would be brilliant. To talk to someone experienced for 1h and align all my questions, fix my issues, and learn.

    Does anyone know any platform like this?

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

    What's wrong with this Lark grammar?

    Posted: 29 Nov 2021 01:11 PM PST

    I've reached this (simplest) version of my project's Lark grammar that fails:

    ``` WS : /[ \t]+/

    ?flag : "draft" -> draft_flag | "flagged" -> flagged_flag

    ?and_predicate : and_predicate WS "and" WS flag | flag

    ?or_predicate : or_predicate WS "or" WS and_predicate | and_predicate

    ?predicate : or_predicate ```

    It parses "draft and flagged" perfectly, but not "draft or flagged":

    Unexpected token Token('OR', 'or') at line 1, column 7. Expected one of: * AND Previous tokens: [Token('WS', ' ')]

    I can't understand why; I suspect it's either something I fundamentally misunderstood about LALR parsers OR something I missed about Lark.

    Looking forward to finding out in which way I was a dumbass.

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

    OOP Inheritance Quick Question - Java

    Posted: 29 Nov 2021 11:35 AM PST

    For my adventure game I'm using OOP

    I want to be able to promote my adventurer to a specific class like Knight/Magician.

    So how is the structures work? Main Class: Adventurer Sub Class: Knight, Magician

    then when I promote them when they reach a certain level I just copy the data from adventurer, construct a new knight, and then overwrite the adventurer reference with the new knight one with old adventurer data?

     

    Extra question:

    So for my Adventurer class which will be abstract (using java)

    Should I also make another sub-class which is like a 'noob' or 'beginner' which later then swaps sub-class (to knight or magician) later on? That way my adventurer class is like purely abstract.

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

    How to apply a method to every combination in a list

    Posted: 29 Nov 2021 07:03 AM PST

    Hi,

     ttc_list = [] ttc_list = self._balls[i].time_to_collision(self._balls[i+1]) 

    time_to_collision is a method that basically calculates the time for two balls at two different positions to collide (given their velocities). So,

    self._balls[i].time_to_collision(self._balls[i+1]) 

    calculates the time taken for ball i and ball i+1 to meet. I am wondering if there is any way to alter this code so that (using 4 balls as an example) it calculates the time taken for ball i and ball i+1, ball i and ball i+2, ... , ball i and ball i+4, ball i+1 and ball i+2, ball i+1 and ball i+3 etc, so basically calculating the time for each ball to meet with eachother, and then put these times in a list. How can I do this?

    The goal is to have a list, from which I can then extract the minimum time.

    Thanks in advance

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

    Deleting last file from each sub-folder

    Posted: 29 Nov 2021 05:43 AM PST

    Not sure if this is the right place to ask but here we go!

    I have a bunch of subfolders with some pictures in each one of them.

    I need the last picture deleted in each one of them (also, all of them are numbered in 000.jpg format, if that helps).

    My best guess is to go over batches but cant say that I have any idea on how to do it and Google wasn't helpful at all.

    Any help is appreciated, thanks in advance! :)

    Edit: Found answer: for dir in ./*; do (cd "$dir" && ls -Rt && rm "$(stat -c "%Y:%n" * | sort -t: -n | tail -1 | cut -d: -f2-)"); done

    It accesses subdirectory, sorts all files by date, newest to oldest, and in my case deletes the first on the list.

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

    No comments:

    Post a Comment