• Breaking News

    Tuesday, July 14, 2020

    Former English teacher solves a math problem with Python. learn programming

    Former English teacher solves a math problem with Python. learn programming


    Former English teacher solves a math problem with Python.

    Posted: 13 Jul 2020 04:44 PM PDT

    I left teaching after eight years and have been learning Python on Codecademy for 59 days straight and I'm having an absolute blast. Learning new things at 35 makes me feel so good I can hardly stand it and I'm thrilled to be getting into this career.

    Along with learning to program, I've been going to the gym to lift and walk on the treadmill. My watch tracks steps but can't track the flights of stairs I climb because I'm not actually moving up. My s.o is the math and chemistry person in the relationship and I hadn't touched math since sophomore year in high school so this was a true triumph for me.

    I knew that there was a way of solving this but I had no idea where to start. After all of the things I had done so far in learning Python, I knew that if I spent enough time on it, I could figure it out. Two days later, a lot of math on paper, and a thousand Google searches later, I came up with this.

    import math # angle calculated using an angle gauge on the treadmill base. # treadmill incline of 1.5 = 1 degree of incline # calculated with an average of 14' per flight of stairs. def treadmill_climb (angle, distance): height = (math.tan(math.radians(angle))) * distance flight = round((height * 5280) / 14) return "Walking {} miles at a {} incline is like walking up {} flights of stairs."\ .format(distance, angle, flight) treadmill_climb(3, 3) 

    Does walking up an incline and walking up stairs to a similar height burn a similar amount of calories? I really have no idea and that's not what matters. Through learning to program I have a different way of thinking about the world and what I can do with programming as a tool. I've learned to learn in a new way and it has changed my life.

    Thank you to everyone here that continually encourages programmers of all skills and ages. We appreciate you. Go forth and be good to yourselves.

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

    Why do some programmers think that Python is for noobs?

    Posted: 13 Jul 2020 10:43 AM PDT

    is it because its easy to learn and many new programmers are learning it everyday?

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

    "Your new password is too similar to one of your previous passwords" - How does this work without storing plaintext?

    Posted: 13 Jul 2020 11:38 AM PDT

    Where I work, we have an enforced security policy to change passwords every 90 days.

    If, in the process of changing your password, you enter a new one that is "too similar to one of your previous passwords", the new password is rejected. It doesn't have to be exactly the same, just similar.

    My company is generally really on the ball with information security, but the only way I can think to compare a new password to an old password for "similarity" would be to store passwords in plain text. Which would cause all our infosec people to freak out (not to mention our board of directors).

    So is there some other programmatic way to do this comparison for "similarity"? How does this work?

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

    Losing motivation and feeling little

    Posted: 13 Jul 2020 09:08 AM PDT

    So quarantine happened and my college closed, I suddenly have a lot of time and it was perfect because I was struggling to learn Web dev parallel with my full time classes. I finished HTML, CSS, learned Bootstrap, made a portfolio website for a friend which honestly felt great because it was one my first project and he really liked it. Things started to feel a big dry after a while and I was doing JS then. I wasn't happy but I was intrigued and curious. I finished the a lot of stuffs did some small scale things and I don't know what went wrong but I did not enjoy, I thought it was maybe a moody week or something but it only got worse. It was like I lost my spark.
    This got worse when I started Node and it felt so confusing I had to take a break and I tried looking for jobs (not really wanting to apply but if there was anything with a low bar why not) and I was devastated at the requirements and all. This got worse as in forums I saw people who's weekly projects was way better than my project with took a month. 6 months into Web dev and I feel so dry. I'm afraid if I'll never be good enough or I'm not cut out for it.

    The worst part is I always believed programming was my passion. I still remember seeing a computer for the first time in 2003 and I was mind blown by it, I still remember in my schooling time we had a little coding classes with QBasic (yes our school gave us an introduction to programming with a 30 year old language ). I remember when I made a circle, then changed the background colour then added in more random shapes essentially recreating my 2nd grade art with Paint. That, that feeling of writing something and the computer doing it for you and seeing it work. That's when I fell in love with programming. Now I'm a CS undergrad and for a few months I'm losing that feel. This is just college and regular life. I'm afraid what it will be like for competitive companies where I might build my career.

    P.s : Sorry for the rant-ish post.

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

    Why is learning PHP not recommended?

    Posted: 13 Jul 2020 11:45 PM PDT

    Some of the articles I read and podcasts I listen to state the following:

    Do a research in your local geographic area, and check which languages and technologies are mostly used, and which ones the jobs require, then start learning that language.

    I did a research, and most of the languages I found are either PHP or ASP Dot Net, Apperantly these two make up a big chunk of the work opportunities offered around here.

    Now, whenever I browse subreddits such as /r/learnprogramming, or /r/webdev I always see discussions regarding the above technologies, such as people really not recommending them, people stating that no one should learn them, and they are dead, etc.

    Why is that? And should I really not learn PHP? Or a language like ASP Dot Net?

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

    Does any of you have a cheat sheet for name conventions for the most popular languages?

    Posted: 13 Jul 2020 02:56 PM PDT

    I code in many different languages and remembering every different naming convention for every language is literally impossible for me. I would appreciate it a lot if any of you know a source where I can look up the naming conventions on one place. My most used languages are, C, C++, C#, Javascript, Python (Html and css would also be a cool extra)

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

    What is a socket?

    Posted: 13 Jul 2020 04:27 PM PDT

    Hello everyone, I am new to programming, I have been learning python as step to become a pen tester. While I was watching some programming videos, I found one that shows how you can build a web server using socket library in python.

    However, the video did not explain what a socket is, all he said was that "it is end point of communication"

    If anyone can explain what sockets are to me I will be very grateful.

    Thank you all for your time and I wish you all a good day.

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

    passing a user defined class/struct as pass by value

    Posted: 13 Jul 2020 10:04 PM PDT

    hey. i've run into quite an unexpected and odd bug in my code, though i'm sure i know why. i'm writing a basic gui using openGL and the win32 api, and as a test i decided to write a basic pong game using my library. just as a test, i wrote a function that took two of my classes as pass by value, instead of pass by reference or pointer.

    unfortunately, this appears to be the cause of the issue. the parameter scope function gets destroyed, which calls my explicitly defined destructor classes to delete the openGL buffers. Because the parameter object is shallow copying, this deletes the openGL buffers of the original objects i had passed in, causing plenty of unexpected behaviour.

    my question is, how is it i get the function to deep copy (allowing my to tell it to create new openGL buffer objects) when i pass a class by value to a function? writing a simple function overload for the operator= doesn't appear to do anything. thanks.

    code for the function i am calling:

    bool isColliding(pr::RectangleShape p, pr::CircleShape b) 

    code for the overloaded operator i have wrote (just checks to see if it is called; it isn't)

    pr::RectangleShape& pr::RectangleShape::operator=(const RectangleShape& rect) { std::cout << "rect\n"; return *this; } 

    edit: lmao, i was just being retarded. if anyone stumbles across this, you have to make a copy constructor. you do NOT have to overload operator=, as that would only be used when it is used (obviously), but not when it could be used interchangeably (as making a copy of an object using a copy constructor is virtually the same as doing it with the = operator).

    to make a copy constructor, simply make a regular constructor with the name of your object as a const reference as a parameter. then do with it in the definition as you please

    i.e.

    Example(const Example& example); 
    submitted by /u/PoobearBanana
    [link] [comments]

    Best video lessons on java?

    Posted: 14 Jul 2020 12:23 AM PDT

    I've been looking at tutorials on YouTube but they have nothing but errors and people are telling me its bad practices but just say "study" more. But I cant even get past the basics if nobody helps me with understanding what I'm doing wrong. An example video I watched here I cant get to work and nobody can seem to explain why.. https://youtu.be/91a7ceECNTc At 21:20 he gets a snake to pop up but it doesn't work for me. He provides his code in video description. But I've followed step by step, I've even tried copying and pasting but it doesn't work.

    I want to make a simple game or something to make this fun and still learn but I cant learn any further if tutorials online are outdated or bad syntaxes etc... Ive been over methods, it's, loops etc.. How do I use then practically now? It seems like every example of a tutorial online on how to make a simple game doesnt even work so I follow hours of videos and they just waste my time and I dont learn anything new. If a tutorial showed how to make a game of pong I could understand for the next game on how to move up or down left or right etc... Can someone please help this has been a year between my real job and this and I hit a dead end. Lynda.com, codeacademy, udemy all of it just teaches the same basics over and over. Then the next step up to intermediate seems impossible. Someone recommend a good video series please? The Stanford classes seem super out of date as well.

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

    Preparation for interview with Google ( Software Engineering Internship)

    Posted: 14 Jul 2020 12:19 AM PDT

    I am a Computer Engineering major. I am a rising Junior. I am about to start the interview process with Google. I have no other internships or experiences to help guide me. Any suggestions on how I should prepare?

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

    Don't know which language to learn first

    Posted: 13 Jul 2020 01:44 PM PDT

    Hey guys! I'm a noob in programming and I have decided to enter data science stream. Should I learn python and django ( I know learning these will take time though) or should I first learn any of the mainstream language like C and then start learning python and django and then discover data science???? Is there any requirement that I should compulsory learn any of the mainstream language or should I just learn python and django??? Please anybody reply. I'm confused AF. (Sorry for bad English and noob questions)

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

    Stdout redirected to a.out instead of output.txt linux

    Posted: 13 Jul 2020 11:49 PM PDT

    Hi, I am using ubuntu and when I run g++ hello.cpp 2> err.txt 1> out.txt the out put (Hello World) is redirected to a a.out file which contains some weird stuff like: @@@@������-�=�=���-�=�8, but if I run ./a.out I recive a "Hello World" message. Same happens in alpine linux inside a docker container. Is there any way I could convert the a.out file to a normal txt file or to write the output in out.txt (also the out.txt is empty and if an error occurs it will be redirected to err.txt)? If I run mv a.out a.txt and open the file, my text editor stop running.

    submitted by /u/Alex-02-
    [link] [comments]

    How to manually iterate through a hash map in python?

    Posted: 13 Jul 2020 08:03 PM PDT

    To gain experience with data structures, I am incorporating a hash map in one of my programs. The purpose of this program is to create a database of tornadoes that occurred in each state in both 2019 and 2014, and then calculate which states have experienced an increase or decrease in tornado occurrences over the past five years.

    In order to calculate which states experienced an increase or decrease, that would require the use of iteration. However, I received an error message saying that the object was not iterable when I attempted to execute a for loop to print each state.

    My main class has three methods, one instantiates the size of the map, one that instantiates the index of the key value pair, and another that allows me to add a state and its data to the database. I then made an instance of the class so I could manually enter the data. I only copied the data for states starting with "A" so the post is shorter.

    class StateData2019 :
    def __init__(self):
    self.size = 50
    self.map =[None] * self.size

    def _get_state_index (self, state):
    state_index = 0
    for char in str (state):
    state_index += ord(char)
    return state_index % self.size

    def add_state(self, state, tornadoes):
    state_index = self._get_state_index(state) # Retrieves state index
    state_tornadoes = [state,tornadoes] # Initializes cell to [state, tornadoes]
    if self.map [state_index] is None : # If cell is empty
    self.map [state_index] = list ([state_tornadoes]) # Insert pair
    return True
    else:
    for state_data in self.map[state_index]: # For each key value pair:
    if state_data[0] == state: # If the first cell member is the state
    state_data[1] = tornadoes # The second cell member is the tornadoes
    return True
    self.map[state_index].append(state_tornadoes) # Add new pair to cell block
    return True

    states = StateData2019 ()
    states.add_state("Alabama", 95)
    states.add_state("Alaska", 0)
    states.add_state("Arizona", 10)
    states.add_state("Arkansas", 31)

    for state in states:
    print(states)

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

    C/C++ tutorial for the intermediate?

    Posted: 13 Jul 2020 11:47 PM PDT

    So, I'm not sure, if this subreddit is right for this kind of question, but would anyone know of a slightly advanced tutorial for C/C++? I know the basic syntax and usage of the language from university and a couple of projects and I have about 3 years of experience in Java and some in Python. So I don't need stuff like arrays and loops explained to me. I'm looking for a tutorial, that would introduce me to more advanced, real-life-like problems in C/C++. I would like to get my skill to a level that I could market to potential employers.

    Any advice would be appreciated.

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

    Need help with Repository design pattern in Spring

    Posted: 13 Jul 2020 07:59 PM PDT

    I'm pretty new to Spring framework and with some experience of Android. I'm facing issues to implement some features in Spring by mocking architectural patterns from Android. Repository in Android manages both local database and network datasource, using network as primary source and local database as some sort of cache. Data fetching would first call the api and save the data in local database for future use.

    However, Repository in Spring seems to take care only of persistence database. I tried to API calls in repository layers, and it feels like repository implementation becomes quite ugly as it starts involving DTO to domain model mapping and so on... feels like repository is becoming more than what it should be. From my bit of research, people are also recommending setting up Service classes for external API integrations. I'm not sure why the repositories seem to be different in each framework, and What's the best way to implement such logic in Spring? Really need some help, I'm still not finding a clear answer

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

    Multiple courses at once or one at time for optimal learning?

    Posted: 13 Jul 2020 10:57 PM PDT

    I recently decided I wanted to learn a little deeper into two factions specifically. JavaScript and general databasing. I found two courses whose syllabuses I liked and I started with the JS course first. It's going fine, but it dawned on me that maybe I should have started both at the same time and split time evenly between them. Just thinking about how we learn in an educational setting, you go from one class to another. Is this the best way to learn? Does it matter at all? Just looking for opinions on pros/cons of each way. Thanks.

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

    Can someone help me understand what am I doing wrong.

    Posted: 13 Jul 2020 10:55 PM PDT

    I am trying to make this simple rock paper scissors game in javascript but for some reason it is not working how it is supposed to. It gives a random outcome when the code is fully executed. For example if the user inputs paper the outcome can be draw, undefined or anything else. What am I doing wrong?

    function computerPlay(){ let computerMove = Math.floor(Math.random()*3) if (computerMove == 0){ return "rock" } else if (computerMove == 1){ return "paper"; } else{ return "scizzors"; } } function playRound() { if (playerSelection == computerSelection) { return "draw"; } else if (playerSelection == 'rock' && computerSelection == 'paper') { return "paper beats rock. computer wins"; } else if (playerSelection == 'rock' && computerSelection == 'scissors') { return "rock beats scissors. player wins"; } else if (playerSelection == 'scizzors' && computerSelection == 'rock') { return "rock beats scissors. computer wins"; } else if (playerSelection == 'paper' && computerSelection == 'rock') { return "paper beats rock. player wins"; } else if (playerSelection == 'paper' && computerSelection == 'scissors') { return "scissors cut paper. computer wins"; } else if (playerSelection == 'scissors' && computerSelection == 'paper') { return "scissors beat paper. player wins"; } } console.log(computerPlay()); let computerSelection = computerPlay() let playerSelection = prompt("rock, paper, scissors?"); console.log(playRound(playerSelection,computerSelection)); 
    submitted by /u/greencharizard20
    [link] [comments]

    is there anyway to restrict usage from included header files if i am making a static link library?

    Posted: 13 Jul 2020 10:44 PM PDT

    i've recently been making a basic GUI that i plan on turning into a static link library for use in the future. to make it, i used the win32 api, openGL, and various other functions in the c++ standard library. i was just wondering, is there anyway i can restrict the user from accessing these functions? for example, i know in virtually all good 3rd party libraries i've used, i am unable to access any of the functions in the c++ standard library without including their respective headers myself, even though i'm sure they used the functions in them at least once, somewhere in their code.

    so is there anyway to disallow the user to use specific functions provided in specific headers? sorry if this is a stupid question.

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

    How can I integrate Python with Cpp?

    Posted: 13 Jul 2020 10:41 PM PDT

    I have learned quite a bit of both Python and Cpp. How can I integrate them? Is it a good idea to mix two language one which is high level and the other low level. In what situation should I try to integrate them?

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

    I think I figured it out

    Posted: 13 Jul 2020 10:30 PM PDT

    I went from being an envious wet-lab grunt to an egotistical software engineer. I couldn't believe how simple it was. I'll tell you the tactics here so you don't have to waste years of your life in class.

    Being a software engineer is about teachability and iteration. You have to be willing to learn, you have to keep trying when you fail. The main technique is keeping things simple. Simple code is clean code. Tackle five simple problems instead of one big problem.

    Simple also means reusability and abstraction. Don't write new code to make HTTP requests when you can use a package. You think doing it yourself makes you a better engineer. It doesn't. Keep it DRY (Don't Repeat Yourself).

    Frontend engineering is a lot like backend engineering. Backend engineering is like any other type of engineering. The main differences are the languages used. The principles remain the same.

    Choose a language that is well suited to what you want to create. Python is good for mathematics and machine learning. You'll need HTML and CSS to make a website. Just starting? Learn Java.

    Write short programs. Avoid doing too much at once. Engineers aren't as smart as you think.

    If you've built enough and struggled enough, you'll notice that you can comprehend new technologies quicker. That's how it works.

    That's it. You just learned 85% of what it takes. Discuss.

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

    Need Career Path Advice As a Final Year Computer Science Student

    Posted: 13 Jul 2020 10:23 PM PDT

    Hi guys I am a student of computer science.I am in my final year.10 different people say 10 different thing go for web development,mobile development,data science or machine learning, cybersecurity .Some say web will be dead,people don't download new app, ai is the future blah blah...

    Can some one give me advice on real life scenario??

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

    Resources To Learn How To Program Photo Editing/Filters App

    Posted: 13 Jul 2020 01:38 PM PDT

    Hi All

    As per the title I am interested in finding some resources to learn how to program a photo editing/filters type app similar to Instagram, VSCO, Prisma etc

    Having had a search on Google, I couldn't find anything in particular, so was hoping somebody may have some recommendations on how to pick this kind of thing up?

    Appreciate any advice anyone can offer.

    submitted by /u/2020Corp
    [link] [comments]

    Integer class and null in Java

    Posted: 13 Jul 2020 10:19 PM PDT

    Hi there! I am not sure what pattern is best to follow for the following use case. We have an object that is being fetched which includes an integer field i.e { String name: 1 Integer age : 32 }

    Age here is optional so it may be defined or not, if not then the value of age is null

    After fetching this object in JSON I convert it into a java POJO, I then check whether a value was provided for age by doing a null check

    i.e if (age != null && age !=0)

    Is there a better way to do this since I have heard null checks are frowned upon? Maybe using Optionals or something I am not familiar with?

    Thanks

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

    Is there a website with a lot of db schema for APIs?

    Posted: 13 Jul 2020 10:06 PM PDT

    Is there a website with a lot of db schema for APIs?

    I want to make a dozen of different APIs to get better, but I also want to make at least 1 API that's super complex with a lot of database tables and many one-to-many and many-to-many relationships. Could you give me some ideas along with their respective db schemas?

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

    No comments:

    Post a Comment