• Breaking News

    Thursday, October 8, 2020

    Hello guys, I have a question about where this b came from (C#) Ask Programming

    AskProgramming

    Hello guys, I have a question about where this b came from (C#) Ask Programming


    Hello guys, I have a question about where this b came from (C#)

    Posted: 08 Oct 2020 06:33 PM PDT

    [RESOLVED]

    Here is the code:

    char a = 'a';

    char b = 'b';

    char c = '\r';

    char d = 'd';

    string e = ("" + a + b + c + d);

    Console.WriteLine(e);

    Console.ReadLine();

    And it somehow prints out this :

    > db

    db!!!!!! What???? I am so confused. Shouldn't it be just 'd'? Can someone explain what the computer's thought process is?

    >I thought it'd be "Okay I'll print 'a'. Now I'll print 'b'. Ooooh \r, then I'll go to the very beginning of the line. Now I'll print 'd', and because I'm at the beginning of the line, that'll override the 'a' and 'b' I just wrote leaving just 'd'."

    The only thing I can think of is that /r only lets you override the first char, and not every subsequent thing

    Any input would be greatly appreciated...

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

    Is implementing multi-processing going to save me time as a developer when debugging/testing?

    Posted: 08 Oct 2020 05:27 AM PDT

    We have some pretty massive datasets and it can take 5-10 minutes to run code outside a debugger, code inside a debugger a little longer. I was considering attempting to implement multi-processing. Splitting my dataset up into ~4 groups, and using multiprocessing to work on each at the same time.

    This only benefits me. In production, this code is run overnight/over weekends/ in the background.

    My question- Is this difficult to implement(Python)? Will I have new problems that you wouldn't run into without multiprocessing? Will this save me time in development?

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

    Any API about upcoming elections?

    Posted: 08 Oct 2020 07:36 PM PDT

    Is there any api that provides data about upcoming elections? not just the presidential elections but all small elections for a certain jurisdiction.

    Thank you

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

    Should I be using JavaScript or Python to make an Instagram scheduled upload program?

    Posted: 08 Oct 2020 07:10 PM PDT

    First of all I'm a complete newbie as it pertains to programming so excuse me if the question seems dumb. I currently manage 4 Instagram theme pages manually by myself. I'm looking to create a program that could be used to schedule uploads. I know this is against Instagrams terms of service, but I would just be trying to connect my program to my iPad and run it through that way. I have 2 questions.

    Is this even possible to do. I just want to schedule the post and then do all my engagement manually such as commenting and liking my followers comments.

    Could I do this with JavaScript or should I go about doing it with Python? I was planning on learning html, css, and JavaScript anyways. But if it's better to do in Python then I'd rather learn that first.

    I'm not trying to make money with it or anything. Just to help automate my process. I want to learn programming as a new skill and don't need it for work.

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

    Is static web really a thing?

    Posted: 08 Oct 2020 09:24 AM PDT

    Is it just for informational sites or niche applications? Or is it more of a separation of concerns? Could current monolith or microservice web applications/sites benefit from its ideals in any way?

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

    No programming

    Posted: 08 Oct 2020 09:13 PM PDT

    I sometimes feel my life is a mess.

    I learnt programming in the first 2 years of my college and was average at it. However I was very motivated to do UI/UX and frontend. After trying to create UIs for a lot of apps and websites, I realised that I cannot create illustrations but only create screens using shapes, colors, typography, spacing etc. So I pivoted to writing HTML and CSS.

    At the penultimate year of my college companies start to hire and therefore I shifted back to programming. Since this was so asynchronous, I never truly learnt the fundamentals unlike my friends who dedicated their time to only programming.

    I however landed a job through programming. Now I am very much into frontend frameworks like angular, react and just creating sites out of them. That's my job too. Here's the problem.

    I have to pass a programming test in my organisation inorder to get myself promoted. I don't know how long will my life shift from programming to software development.

    I have no confidence and no motivation to learn programming now but I need to get promoted to learn from the best in my company.

    What is wrong with me? Also, I suffer from anxiety, depression if that helps.

    submitted by /u/bP96_gR-4
    [link] [comments]

    C# Help

    Posted: 08 Oct 2020 09:04 PM PDT

    Hello everyone! I'm new at coding and would like some help on an assignment. I will post what I have so far in the comments section! I'm getting 5 errors but not sure why. Thank you!

    An accurate sales forecast is an important tool for companies to have. It helps managers gauge the demand for their products. It helps companies better manage inventory. It allows managers to financially plan for the company's growth.

    A sale team of XYZStartup wants to investigate the optimal price of their product to maximize their profit for the next several weeks of planning horizon, utilizing a simple formula provided below.

    𝑆𝑎𝑙𝑒𝑠 = (𝑝𝑟𝑖𝑐𝑒) ∗ (𝑏𝑎𝑠𝑒 𝑑𝑒𝑚𝑎𝑛𝑑 − (1 + 𝑝𝑟𝑖𝑐𝑒 𝑠𝑒𝑛𝑠𝑖𝑡𝑖𝑣𝑖𝑡𝑦) ∗ 𝑝𝑟𝑖𝑐𝑒 + (𝑝𝑟𝑖𝑐𝑒 𝑠𝑒𝑛𝑠𝑖𝑡𝑖𝑣𝑖𝑡𝑦) ∗ 𝑐𝑜𝑚𝑝𝑒𝑡𝑖𝑡𝑜𝑟′𝑠 𝑝𝑟𝑖𝑐𝑒), where base demand is randomly drawn from 95 to 105 and price sensitivity is randomly drawn from 4 to 7.

    There is one competitor in the market. The competitor is vigilant enough to track your product price in real time using an AI tool so that they always copy your price strategy (e.g., the competitor's price is always the same as yours).

    You, as an IS professional, are required to develop a program that conducts the following process.

    (1) Reads a price from the user. The price must be in the range of $5 to $85. If the user provides a price out of the range, the program askes the user to provide a price again.

    (2) Calculate the sales (using the formula above) 30,000 times (3) Print out the average expected sales.

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

    Wireshark: How can I use MAC addresses and TTLs to identify which interface a pcap was captured on?

    Posted: 08 Oct 2020 09:19 AM PDT

    Forgive me if this isn't appropriate for this subreddit, but I need some help regarding network security and I don't know where else to post this. I have a pcap and need to identify which interface it was captured on. In file properties, the interface is unknown. I have the MAC addresses and TTLs of each packet, but I don't know who captured the packets. Any help would be greatly appreciated.

    Packets sorted by TTL

    Endpoints MAC addresses

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

    OCR but also recognizes handwriting

    Posted: 08 Oct 2020 05:16 PM PDT

    Does anyone know what I need to do for this venture? I'm currently diving deep into programming and I'm looking for an open-source program that I could use as a basis.

    Goal:
    To be able to identify printed handwritten text on forms
    Store that information in a file and folder.

    Thank You in Advance!

    submitted by /u/Flamingo-Hefty
    [link] [comments]

    Best practices/advice on going about programming projects / Getting things "done"? [N00B]

    Posted: 08 Oct 2020 03:40 AM PDT

    I'm not much of a programmer but run a business in which programming projects are regular - e.g get a landing page up, develop a web app etc. I'm looking to start outsourcing most of these projects to freelancers. I have used Upwork in past but inefficiently and it has cost more time than me doing alone. I operate alone and have never worked inside a business around programming so am not sure of the best practices when starting a project or getting basic things "done" through using one or multiple freelancers.

    For example, I have a landing page that requires a copywriter - I can get from Upwork - and a guy to code a quick static page for me to get domain and put on AWS. How do I go about this as efficiently as possible, any tutorials on outsourcing you can recommend, books, best practices or software to use to make group projects as quick and streamlined

    I apologize in advance for grammar errors or if what advice am asking for seems vague I am happy to elaborate as this was written quickly on phone

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

    Can't find a fix anywhere for this issue

    Posted: 08 Oct 2020 03:48 PM PDT

    Currently taking a NetApps class and have to code a website. I keep getting the following error:

    "The type java.io.IOException cannot be resolved. It is indirectly referenced from required .class files"

    I imported the controllers package and it is giving me this error for my servlet. Does anyone know how to fix this? Thanks.

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

    Does Opera change its VPN's virtual location's IP address?

    Posted: 08 Oct 2020 03:06 PM PDT

    I see these three Virtual locations for Opera's VPN. Suppose that I always pick Americas before I log onto a forum under "Account 1". For context, I live in the Middle East.

    1. Does Opera change this one virtual location's details? How often? Will I appear to have different IP addresses? Or just one IP address?

      Suppose I create another account on the same forum, but always pick Asia before logging on under "Account 2".

    2. Can the forum's administrators infer from IP address (or other details) that accounts 1 and 2 are using the same IP address?

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

    How to make _getche() only accept specific characters

    Posted: 08 Oct 2020 02:29 PM PDT

    I need input from the user to select and option (1 2 or 3) and want to make sure that they cant enter anything else than 1 2 or 3. It should not require the user to press the enter key, which is why I assumed you need to use getche(). I am a beginner by the way. The language is C++

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

    Hiring a developer to build a program for me that takes dozens of user inputs, performs some calculations, and generates the correct answer. There are many scenarios, special cases, exceptions, etc. What's the most helpful way for me to teach the programmer the 'logic'? Flowchart? Excel table?

    Posted: 08 Oct 2020 08:11 AM PDT

    It's mainly yes/no and integer user inputs. The decision tree for this process is massive and would be a gigantic flowchart.

    What if I create a table in excel that has every possible input field and make it so the output field generates every possible output scenario based on the combination of inputs?

    I just want to make it easier for the programmer to understand and implement the decision tree.

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

    How would I build this? (Total beginner)

    Posted: 08 Oct 2020 01:51 PM PDT

    Hi all,

    Hoping this is the right place for a complete non-coder to ask about getting started.

    Basically, I run a small community scheme that matches random neighbours with each other every month to meet up for coffee. At the moment, the numbers are pretty small, so I just collect email addresses via a web form and match people manually, but as it grows it is becoming more labour intensive each month.

    So my question is, is it possible to create programme that will automate this process for me? If so, what do I need and where would I start?

    I thought that using a Macro in Excel would go some way to helping me, but I'm interested in learning how to code, so thought this would be a good project to try.

    Here's more info how the process works now, which I do on my MacBook:

    People sign up using a Google Form
    I download a csv of the responses each month
    I copy the responses to a new tab for that month on my 'master' excel sheet
    I use =Rand to generate numbers for each entry
    I sort from highest to lowest
    I mark the top two entires pair 1, the next two pair 2, etc.
    I check that it's the first time two people have been matched together by looking through previous months pairings
    I open Outlook (linked to a Google email account) and open a draft email template
    I manually enter the two names and email addresses
    I press send, repeating the last three steps until I've sent all the emails

    I would really love to be able to build something to automate this whole process.

    Hopefully this is simple enough to be achievable, but not so simple that it's meaningless to code something for…

    Many thanks!

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

    Debugging serial communication

    Posted: 08 Oct 2020 01:10 PM PDT

    Hey All, I have loop back working on both computers, but when connected to each other, no joy.

    I used powershell to create and open a port and then did a $port.writeline("hello") and then $port.readexisting() with paperclip across pins 2 and 3 to get loopback.

    The connection is COM1 male connector on back of computer A. Then a female to female gender bender. Then a cable matters USB to rs232 serial Adapter with USB plugged into computer B, set as COM7.

    On both machines, at the gender bender, I can paperclip across 2 and 3 and loopback works.

    When I connect computer A to computer B, no data transmitted from A to B or from B to A.

    Both are set to 19200, none, 8, 1

    Any ideas? I'm totally not desperate.

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

    API integration

    Posted: 08 Oct 2020 12:59 PM PDT

    Does someone knows if API that paypal has in payment checkout option exists for shipping? how can i include my courier business like that?

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

    Best practices/advice on going about programming projects / Getting things "done"? [NEWB]

    Posted: 08 Oct 2020 05:11 AM PDT

    I'm not much of a programmer but run a business in which programming projects are regular - e.g get a landing page up, develop a web app etc. I'm looking to start outsourcing most of these projects to freelancers. I have used Upwork in past but inefficiently and it has cost more time than me doing alone. I operate alone and have never worked inside a business around programming so am not sure of the best practices when starting a project or getting basic things "done" through using one or multiple freelancers.

    For example, I have a landing page that requires a copywriter - I can get from Upwork - and a guy to code a quick static page for me to get domain and put on AWS. How do I go about this as efficiently as possible, any tutorials on outsourcing you can recommend, books, best practices or software to use to make group projects as quick and streamlined

    I apologize in advance for grammar errors or if what advice am asking for seems vague I am happy to elaborate as this was written quickly on phone

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

    What courses should I start at first?

    Posted: 08 Oct 2020 06:36 AM PDT

    Hi. So I am relatively new with programming languages and I got multiple courses that interested me but I do not know in what order I should start studying them. I'd be very thankful if somebody could help me with that question.

    List:

    A) Java Programming Masterclass for Software Developers. Link to a course

    B) The Ultimate MySQL Bootcamp: Go from SQL Beginner to Expert. Link to a course

    C) PHP for Beginners - Become a PHP Master - CMS Project. Link to a course

    D) The Complete JavaScript Course 2020: Build Real Projects!. Link to a course

    E) The Web Developer Bootcamp. Link to a course

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

    Possible error in Cracking the Coding interview textbook(6th edition)?

    Posted: 08 Oct 2020 08:34 AM PDT

    In the solutions section for the first chapter, in question 1.6 for string compression, it states that time complexity for concatenation of strings of length n each is O(n2) . But in question 1.9 for string rotation, it states that the time ccomplexity of the algorithm is O(n) despite containing concatenation.

    1.6 String Compression: Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string. You can assume the string has only uppercase and lowercase letters (a - z).

    SOLUTION

    At first glance, implementing this method seems fairly straightforward, but perhaps a bit tedious.We iterate through the string, copying characters to a new string and counting the repeats. At each iteration, check if the current character is the same as the next character. If not, add its compressed version to the result.

    How hard could it be?

    String compressBad(String str) {

    String compressedString = "";

    int countConsecutive = 0j

    for (int i = 0j i < str.length()j i++) {

    countConsecutive++;

    if (i + 1 >= str . length() II str.charAt(i) != str.charAt(i + 1)) {

    compressedString += "" + str.charAt(i) + countConsecutivej

    countConsecutive = 0;

    return compressedString.length() < str.length() ? compressedString str;

    This works. Is it efficient, though? Take a look at the runtime of this code.

    The runtime is O(p + k2), where p is the size of the original string and k is the number of character sequences. For example, if the string is aabccdeeaa, then there are six character sequences. It's slow because string concatenation operates in O( n2) time.

    But in question 1.9,

    1.9 String Rotation: Assume you have a method isSubstring which checks if one word is a substring

    of another. Given two strings, S1 and S2, write code to check if S2 is a rotation of S1 using only one

    call to isSubstring (e.g., 'waterbottle' is a rotation of 'erbottlewat').

    SOLUTION

    If we imagine that S2 is a rotation of S1, then we can ask what the rotation point is. For example, if you rotate waterbottle after wat, you get erbottlewat. In a rotation, we cut S1 into two parts, x and y, and rearrange them to get S2.

    S1 = xy = waterbottle

    x = wat

    y = erbottle

    S2 = yx = erbottlewat

    So, we need to check if there's a way to split S1 into x and y such that xy = S1 and yx = S2. Regardless of where the division between x and y is, we can see that yx will always bea substring ofxyxy. That is, S2 will always be a substring of S1S1.

    And this is precisely how we solve the problem: simply do isSubstring( s1s1, s2).

    The code below implements this algorithm.

    boolean isRotation(String S1, String S2) {

    int len = S1.length();

    if (len == s2.length() && len> 8) {

    String S1S1 = S1 + S1;

    return isSubstring(S1S1, S2);

    return false;

    The runtime of this varies based on the runtime of isSubstring. But if you assume that isSubstring runs in O(A+B) time (on strings of length A and B), then the runtime of isRotation is O( N) .

    Please help.

    Edit- Random j characters are semicolons.

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

    What python libraries are useful for creating a price monitoring interface?

    Posted: 08 Oct 2020 06:02 AM PDT

    Hello, I'm currently working on a project in which I'm applying concepts from this book about trading and machine learning. I'm working in parallel on building some prototype trading system that has a simulator, and I'm not quite sure what would be an efficient clean way of live tracking prices for multiple stocks. What I mean by tracking prices is to have some app(possibly with an interface) that is constantly running which is connected to an api, and I'm expecting prices to reflect locally as soon as a price change happens in the same fashion as many trading applications have this already. Of course I'm not asking for code, I'm just asking for what tools / python libraries would be useful in creating such functionality. The non-clean way that I know is to scrape prices periodically using requests / scrapy or whatever every second/minute or so, but I don't think that's what happens in real life applications which is exactly what I'm asking for.

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

    I have been working on online coding challenges during the lockdown to improve my career prospects. I recently came across a particular problem that I'm not able to solve within the execution time limit of the challenge. I'm coding in java. Any help is appreciated. Thanks in advance.

    Posted: 08 Oct 2020 11:55 AM PDT

    You are given an integer K and a string S that contains lowercase English alphabets of length N, where N is always a multiple of K. You are required to convert the given string to a special string.

    A special string is a string that follows a repeating pattern of K characters till the total length of the string is N. For example, if S = abedef and K = 2, then the special string can be ababab or bcbcbc or any other string that follows the mentioned criteria.

    In order to convert the string, you can perform an operation on the string. Considering lowercase English alphabet are set as circular, you can rotate the character of the string on either side in one operation. For example, for "a" you can rotate it to "b" or "z" You can perform this operation any number of times on any character of the string. Performing this operation once costs you 1 unit. The task is to convert the given string to a special string in the minimum cost.

    Input format:

    • The first line contains T denoting the number of test cases • Next T lines contain Two space separated integers K and S, where K is an integer and S is a string.

    Output format:

    For each test case, print the minimum cost in a new line.

    Constraints:

    1<=T<=10

    1<=K<=100

    1<=S<=106

    The string contains only lowercase English characters.

    Sample Input:

    4

    3 abcdefghi

    3 abcabcabc

    3 abcdefabc

    1 azazaz

    Sample Output:

    18

    0

    9

    3

    Explanation:

    abcdefghi is converted to a repeating pattern of defdefdef. Cost = 3+3+3+0+0+0+3+3+3=18.

    abcabcabc is already a repeating pattern. Cost = 0.

    abcdefabc is converted to abcabcabc. Cost= 0+0+0+3+3+3+0+0+0 = 9.

    azazaz is converted to aaaaaa. Cost = 0+1+0+1+0+1 = 3.

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

    Nested Iterator Loop

    Posted: 08 Oct 2020 11:15 AM PDT

    public void growGrass() { Iterator<Integer> y = this.heights.iterator(); Iterator<Integer> x = this.widths.iterator(); while (x.hasNext()) { while (y.hasNext()) { double r = Math.random(); Object groundType = at(x.next(),y.next()).getGround(); if (r < 0.05 && groundType instanceof Dirt){ at(x.next(),y.next()).setGround(new Grass()); } } } } 

    I'm making a function that iterates through x and y axis of a "game map". The code grows a grass if the ground type at a coordinate (x,y) is a dirt. When the application is run the, while loop does not stop. Im not sure what is the problem here

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

    What is the purpose of this data pointer in this I2C function?

    Posted: 08 Oct 2020 10:59 AM PDT

    Hi,

    I am interfacing a sensor with a MSP432 microcontroller and have an I2C question:

    bool writeI2C(uint8_t ui8Addr, uint8_t ui8Reg, uint8_t *Data, uint8_t ByteCount)

    {

    /* Wait until ready to write */

    while (I2C_isBusBusy(EUSCI_B1_BASE));

    /* Assign Data to local Pointer */

    pData = Data;

    /* Disable I2C module to make changes */

    I2C_disableModule(EUSCI_B1_BASE);

    /* Setup the number of bytes to transmit + 1 to account for the register byte */

    i2cConfig.byteCounterThreshold = ByteCount + 1;

    I2C_initMaster(EUSCI_B1_BASE, (const eUSCI_I2C_MasterConfig *)&i2cConfig);

    /* Load device slave address */

    I2C_setSlaveAddress(EUSCI_B1_BASE, ui8Addr);

    /* Enable I2C Module to start operations */

    I2C_enableModule(EUSCI_B1_BASE);

    /* Enable master STOP, TX and NACK interrupts */

    I2C_enableInterrupt(EUSCI_B1_BASE, EUSCI_B_I2C_STOP_INTERRUPT +

    EUSCI_B_I2C_NAK_INTERRUPT + EUSCI_B_I2C_TRANSMIT_INTERRUPT0);

    /* Set our local state to Busy */

    ui8Status = eUSCI_BUSY;

    /* Send start bit and register */

    I2C_masterSendMultiByteStart(EUSCI_B1_BASE,ui8Reg);

    /* Enable master interrupt for the remaining data */

    Interrupt_enableInterrupt(INT_EUSCIB1);

    // NOW WAIT FOR DATA BYTES TO BE SENT

    while(ui8Status == eUSCI_BUSY)

    {

    #ifdef USE_LPM

    MAP_PCM_gotoLPM0();

    #else

    __no_operation();

    No comments:

    Post a Comment