• Breaking News

    Sunday, May 12, 2019

    Spent 5 hours straight and just finished writing my first Python program to fetch stock prices, please feel free to let me know if I am doing anything wrong or if I am breaking any unspoken coding rules for writing a program :) learn programming

    Spent 5 hours straight and just finished writing my first Python program to fetch stock prices, please feel free to let me know if I am doing anything wrong or if I am breaking any unspoken coding rules for writing a program :) learn programming


    Spent 5 hours straight and just finished writing my first Python program to fetch stock prices, please feel free to let me know if I am doing anything wrong or if I am breaking any unspoken coding rules for writing a program :)

    Posted: 12 May 2019 03:21 AM PDT

    Credits to u/straightcode10 , she had posted a video earlier last month about using python for web scraping, I finally had some free time on hand today and gave it a try. I started a little bit of VBA programming last year so it's helping me with the learning pace also I made some changes to the original tutorial by u/straightcode10 in my code and plan on building on it further. Let me know if you guys have any concerns or ideas :)

    import bs4
    import requests as rq
    """
    @author : NoderCoder
    """
    Stocks =[ 'AMZN','FB','BEMG']

    def FetchPrice(ticker):
    """
    Enter ticker and based on the that the function returns the values of the stock
    Might experiment with GUI and API late to make this Faster
    """
    url = 'https://finance.yahoo.com/quote/'+ticker+'?p='+ticker
    r = rq.get(url)
    soup = bs4.BeautifulSoup(r.text,"xml")
    price_soup = soup.find_all('div', {'class': 'My(6px) Pos(r) smartphone_Mt(6px)'})#[0].find('span')
    #converting the soup tag object into string
    Temp_string = []
    for x in price_soup:
    Temp_string.append(str(x))
    ps: str = Temp_string[0]

    # Looking for price
    p_i_1: int = ps.find('data-reactid="14">')
    p_i_2: int = ps.find('</span><div class="D(ib) Va(t)')
    p_v = ps[(p_i_1 + 18):p_i_2]

    # looking for price change
    pc_i_1: int = ps.find('data-reactid="16">')
    pc_i_2: int = ps.find('</span><div class="Fw(n) C($c-fuji-grey-j)')
    p_c = ps[(pc_i_1 + 18):pc_i_2]

    # looking for time
    pt_i_1: int = ps.find('data-reactid="18">At close:')
    pt_i_2: int = ps.find('EDT</span></div></div><!-- react-empty: 19')
    p_t = ps[(pt_i_1 + 18):pt_i_2]
    op_list = [ticker,p_v,p_c,p_t]
    return op_list
    for i in Stocks:
    print('the function value is',FetchPrice(i))

    Output :

    the function value is ['AMZN', '1,889.98', '-9.89 (-0.52%)', 'At close: 4:00PM ']

    the function value is ['FB', '188.34', '-0.31 (-0.16%)', 'At close: 4:00PM ']

    the function value is ['BEMG', '0.0459', '-0.0084 (-15.53%)', 'At close: 3:56PM ']

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

    How do I learn to code from a textbook?

    Posted: 12 May 2019 10:15 PM PDT

    I'm a computer science student and I'm about to be taking my first intro to programming class in C++ and I figured it would be good to get ahead and start going over the textbook. The problem is that I've never really used textbooks for anything more than practice and I don't know how to go about learning something from scratch out of one. Are there any recommendations y'all would have on how to learn programming from a textbook?

    *Not sure if it matters but the book is Programming: Principles and Practice Using C++ by Stroustrup

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

    Can someone explain something about dependency injection?

    Posted: 12 May 2019 01:55 PM PDT

    When I was looking at the wiki it said there's 3 types of injections (besides using a framework). Constructor, setter and interface https://en.wikipedia.org/wiki/Dependency_injection

    If it's a dependency, isn't it bad practice to set it outside of the constructor? I was always taught an object should be usable after construction and every method should be callable in any order (except maybe transactions with a start and end)

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

    How do I learn in depth about things like alignment, cache, pipelining, branch prediction, speculative execution, etc.?

    Posted: 12 May 2019 10:31 PM PDT

    Title says it all. I have a vague understanding about what all of those things are, but how can I learn about them rigorously and in depth?

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

    In Visual Studio for C++ what is the benefit of Console App(.NET Core).

    Posted: 12 May 2019 10:26 PM PDT

    I decided to switch from Java to C++ for a personal project, if i use Console App does that mean whichever program i make can be run on most OS?

    would Empty Project be a more oriented version?

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

    Why most developer conferences at the same time?

    Posted: 12 May 2019 07:57 PM PDT

    I am just curious to know, why most big tech company have their developer conference usually during the same time period.

    Is there any particular reason behind it?

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

    Where can I start with learning Lua?

    Posted: 12 May 2019 07:44 PM PDT

    I'm making a game with another dev (I'm mainly an artist) and he's decided we should go with LOVE, I don't want to be a complete idiot when it comes to the code or backend. Where can I start?

    I have some experience with html and Python so I understand the basics, but not much more

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

    What's the best place to learn C?

    Posted: 12 May 2019 07:21 PM PDT

    Hey, not a new programmer here but I've learned the basics of C a while back and wanted to start picking up and going to advanced levels and build projects

    so what are the best (free) resources/videos/websites to learn C? thanks for any responses

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

    Ways of getting more randomness in C# than using the Random class?

    Posted: 12 May 2019 08:55 PM PDT

    I'm not really looking for unique, or even true randomness. I just want something that doesn't pick the same handful of values a bunch, sometimes even the same one several times in a row. I've got a range from 0-60, and most of the time it seems to cycle through the same set of numbers. So I was wondering if there was an algorithm that I could implement that would get me better results than what I'm getting now? It could be that I just don't understand Random.Next, which I currently have set to a value between 0 and an array's length. Is there more I can do to ensure that the values picked are more spread out?

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

    Getting a value from 1-100 randomly with just Math.Random?

    Posted: 12 May 2019 08:14 PM PDT

    Hey guys, I'm a complete noob to programming and even tried to Google this but couldn't find anything specific for it (everything I came across wanted to use "ceil" or max min, things I haven't learned yet and the teacher doesn't want).

    So the question it asks is "Write a Java program that generates a random number between 1 and 100, then prompt the user for a number between 1 and 4. Next make the program determine if the number entered by the user is a factor of the random number."

    int number1 = (int) (1 + Math.random() * 53);

    Does this line work for 1-100 part? At max it seems to generate 100.7, which would be rounded down to 100 right? And starts with a 1? I'm unsure how to test this.

    Thanks.

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

    Confused about learning

    Posted: 12 May 2019 11:52 PM PDT

    I want to learn programming. But I am confused about doing practical stuff like ATBSP or theoretical like MIT's Intro to Computer Science first. My journey is going to be of a self-taught programmer.

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

    Interact, partner, collaborate, share and participate with other developers in different projects and tech events!

    Posted: 12 May 2019 11:43 PM PDT

    Hello! My friend recently started a discord server for developers. They're still small but growing rapidly. They're helping new developers learn and also creating a place where developers can interact, collaborate, partner, etc. At 100 members, they're going to be hosting some cool events like hackathons, defcons and a lot more! The community also helps a lot with beginners trying to learn programming and other programming activities! Interested? Join here - https://discord.gg/5PBPFfK

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

    [C] I occasionally get this misaligned address error when working with pointers, in this example what am I doing wrong?

    Posted: 12 May 2019 07:55 PM PDT

    What am I doing wrong with pointers here?

     Line 16: Char 19: runtime error: store to misaligned address 0xffffffffbebebebe for type 'int', which requires 4 byte alignment (solution.c) 

    0xffffffffbebebebe: note: pointer points here

    int* sortArrayByParity(int* A, int ASize, int* returnSize){ int* sorted = (int*)malloc(sizeof(int)*ASize); int* evens = sorted[0]; int* odds = sorted[ASize-1]; for (int i=0; i<ASize; i++) { if (A[i] % 2 == 0) { *evens = A[i]; evens++; } else { *odds = A[i]; odds--; } } return sorted; } 
    submitted by /u/11010001101001
    [link] [comments]

    [C#] Resize window depending on Taskbar visibility or if the foreground window covers the taskbar

    Posted: 12 May 2019 02:53 PM PDT

    I have an application that needs to dynamically resize its main window if the Taskbar was automatically shown/hidden and/or if the foreground window (excluding my own application's window) is covering the taskbar (or is in non-exclusive fullscreen/borderless window mode).

    Example: If you were watching a youtube video and put the video in fullscreen, my always on top window needs to start covering the taskbar, if you go out of fullscreen video mode the application needs to return to its normal size.

    I've tried getting the foreground window state which doesn't work for my application because it requires either checking when the foreground window changes or checking it every x amount of time using a timer.

    Is it possible to fire/trigger an event when the taskbar's visibility changes or the foreground window enters a non-exclusive fullscreen mode (or something like borderless window in games), and how would I do this?

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

    How to stop auto-code generation visual studio 2017?

    Posted: 12 May 2019 04:06 PM PDT

    I know this question isn't exactly specific to a language, but I'm teaching myself C in visual studio and I for the life of me can't stop it from generating the hello world program as the default whenever a new project is created. I'd also like to be able to remove the auto comments. It's such a minor thing, but I feel like it's going to give me an aneurysm.

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

    Book for Java

    Posted: 12 May 2019 02:23 PM PDT

    I looked into the FAQ and was looking through some of the books there, specifically the ones for teaching java to beginners, but I can't seem to find one that is very up to date. This may be a dumb thing to say, I mean I don't really know if it being an older book matters too much. Does anyone have suggestions for a book to learn Java that has a more recent publication date?

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

    Learning how to program in C++

    Posted: 12 May 2019 09:54 PM PDT

    Hi guys,

    I'm coming up with tutorials on how to learn programming in C++. Starts at a beginner level and will evolve to advanced programming. Check out the playlist (I currently have 11 C++ tutorials out and more on the way, at least a couple tutorials every week!)

    https://www.youtube.com/watch?v=zcEI046FHCg&t=6s

    Thanks!

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

    My files aren't importing into my main.py

    Posted: 12 May 2019 03:33 PM PDT

    Hey guys so I'm trying to import some files I made (they have functions in them relied upon by my main of course), and I'm doing import fileName and I have init.py in the directory containing all of these files. I'm fairly sure they share a working directory. Any tips?

    Let me know if I should show you skeleton or code.

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

    I know exactly what I want to do, but I have no idea where to start.

    Posted: 12 May 2019 09:20 PM PDT

    Hey everyone! I've started planning the purchase of my first home, but during my house hunting I'm often in need of data that I currently have no access to: value per square meter. I assume it is trivial for a real estate website to present this information but unfortunately it is nowhere to be found. I'm in Brazil and mostly use ZAP Imóveis.

    Is there any way I can extract data from that service and use it for something else? My dream result would be a map colored according to value per sqm, from green (cheapest) to red (expensive) or something like that. In the future, maybe I could track how prices change in different areas, or how a new mall improved house values? You know, that kind of thing.

    Any thoughts? Thank you for reading!

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

    Is there any use learning the B Programming language now?

    Posted: 12 May 2019 03:18 PM PDT

    I've stumbled on some old documents related to this language and was wondering if there's any use learning it, even if just for the benefit of learning something new.

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

    Could someone tell me what I'm missing?

    Posted: 12 May 2019 08:47 PM PDT

    Could someone tell me how to fix this program below so that each time it loops the distance adds to itself?

    As it is now the distance stays at 4.9.

    It's supposed to calculate the distance after every loop but only the counter goes up.

    Function Main

    Declare Real fallingTime, fallingDistance, currentTime, distance

    Assign fallingTime = 1

    For currentTime = 1 to 10

    Call fallingDistance(fallingTime)

    Assign distance = fallingDistance(fallingTime)

    Output "After "

    Output currentTime

    Output "seconds, an object falls "

    Output distance

    Output "meters."

    End

    End

    Function fallingDistance (Real fallingTime)

    Declare Real fallingDistance

    Declare Real gravity

    Assign gravity = 9.8

    Assign fallingDistance = 0.5 * (gravity * (fallingTime ^ 2))

    Return Real fallingDistance

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

    I can't understand the solution for the "Find Common Characters" challenge. Can anyone help me understand what's going on ?

    Posted: 12 May 2019 08:42 PM PDT

    I stumbled across a very difficult challenge on Leetcode called "Find Common Characters", although it is considered easy to the website. Here is the description of the challenge:

    Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer.

    You may return the answer in any order.

    Input: ["bella","label","roller"] Output: ["e","l","l"] 

    I got stuck and looked up the solutions (I was stuck for awhile unfortunately). Here is a solution done in Java:

    public List<String> commonChars(String[] A) { List<String> ans = new ArrayList<>(); int[] count = new int[26]; Arrays.fill(count, Integer.MAX_VALUE); for (String str : A) { int[] cnt = new int[26]; for (char c : str.toCharArray()) { ++cnt[c - 'a']; } // count each char's frequency in string str. for (int i = 0; i < 26; ++i) { count[i] = Math.min(cnt[i], count[i]); } // update minimum frequency. } for (char c = 'a'; c <= 'z'; ++c) { while (count[c - 'a']-- > 0) { ans.add("" + c); } } return ans; } 

    What I don't understand is line 7 and 11. I don't understand this part:

    for (char c : str.toCharArray()) { ++cnt[c - 'a']; } 

    The ++cnt[c - 'a'] is doing what exactly ? It's a counter array but what does substracting the character - 'a' specifically mean ? It's an ASCII code index ? I'm confused. I've seen ++cnt[c - 'a'] in a lot of other solutions in a lot of other languages. What is being stored in cnt[] ?

    Thanks for the help!

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

    Any recommended resources for mysql?

    Posted: 12 May 2019 02:28 PM PDT

    I need to download, install and use mysql for a project. anyone with any recommended resources for mysql? happen to be on a mac. i've used postgres before and done a short sql book, so installing, creating a DB, tables, etc, not unfamiliar but doesn't hurt to do that more if there is a great resource.

    need to install it on a mac, and integrate tomcat, jsp for a form page that submits form inputs to a mysql db.

    EDIT: as a start, fortunately installed it on the mac using homebrew, and can stop, start it:

    https://tableplus.io/blog/2018/11/how-to-download-mysql-mac.html

    having trouble installing tomcat using homebrew as well.

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

    Working with a Circular Linked List recursively in C++, experiencing segmentation faults and memory leak issues.

    Posted: 12 May 2019 08:25 PM PDT

    Like the title says, I am experiencing segmentation faults/memory leaks in a circular linked list. The objective of this function that I'm trying to achieve is being able to determine whether the second last node in a circular linked list is a multiple of 5. For example:

    Here is an example generated linear linked list of numbers. 2 -> 10 -> 18 -> 20 -> 2

    In this list, the 4th node/the integer of 20 is divisible by 5, therefore I will report that it is a multiple of 5.

    Before looking at the function, here are things that should be assumed: - There is another function already generating a linear linked list of numbers for us - Pointer 'rear' is already set to be at the end - The data we are working with is all integers.

    Here is the link to the code: https://pastebin.com/DHTj6zF2

    Thank you for helping! And in case anyone was curious, this is for a C++ data structures class. This is just a practice problem for a midterm I have soon.

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

    Working on my first C# project. Why is the Visual Studio debugger coming up blank?

    Posted: 12 May 2019 04:03 PM PDT

    Edit: Rebuilt the program and it worked! I'll have to compare the two, the lines in the middle were added by Visual Studio's suggestions, and they definitely weren't necessary. Thanks for the help :)

    I followed this tutorial to write a simple dice roller. The last line, I assume, is from my text box. Am I just missing something that will tell it to draw the buttons? Or maybe I have something in the wrong place? Visual Studio suggested the "public Form1(IContainer, components, etc...) line and the "this.button, etc" lines. I tried adding various things inside the "Initialize.Component()" line and that just threw errors and it wouldn't let me run it. I've been trying to figure this out for two hours. I'm a complete beginner and have only been learning for about a week, so I'm running out of ideas to search and play with. If anybody could point me in the right direction, I'd greatly appreciate it!

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using System.Windows.Forms;

    namespace Dice_Roller

    {

    public partial class Form1 : Form

    {

    public Form1()

    {

    InitializeComponent();

    }

    public Form1(IContainer components, Button button1, TextBox textBox1, Label number)

    {

    this.components = components;

    this.button1 = button1;

    this.textBox1 = textBox1;

    this.number = number;

    }

    private void Button1_Click(object sender, EventArgs e)

    {

    Random random = new Random();

    int randomNumber = random.Next(1, Convert.ToInt32(textBox1.Text) + 1);

    number.Text = Convert.ToString(randomNumber);

    }

    private void TextBox1_TextChanged(object sender, EventArgs e)

    {

    }

    }

    }

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

    No comments:

    Post a Comment