• Breaking News

    Thursday, December 5, 2019

    How to go deeper than surface level programming learn programming

    How to go deeper than surface level programming learn programming


    How to go deeper than surface level programming

    Posted: 04 Dec 2019 09:34 AM PST

    Hello,

    I'm currently a second year CS student and have touched the surface of a couple of languages such as C++ , Java and Python. I see many students already deciding career paths and fields they want to pursue such as web development or data science but I haven't found anything that clicks till now.

    I would like to pursue python further but I don't know how to get knee deep into the gritty modules and libraries and find what I'd love to do as a job for the next 20 years. Any advice on how to proceed with going deeper into languages and what all should I consider and what are the options ? Thank you

    If any of you are on discord in the field , I would love to dm you all and get to know more about the python field and projects My discord is Cookieswoop#1413

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

    My wife is learning programming; please advise how to save my marriage.

    Posted: 04 Dec 2019 06:23 PM PST

    My wife decided to be a QA, and part of here remote course is to learn java. The course schedule is hard. In 2 weeks, they suppose to learn things that take months in a regular bachelor's degree education.

    Situation

    When she asks me to help to solve the issue in her homework, I can not deep dive into her homework in 1 minute to give precise advice on where exactly she should change a symbol or a word to "make it work."

    I have a magister's degree in computer science. I wish here to understand things and not just "complete homework."

    My approach

    To navigate here understanding, I start asking questions, but it freaks her out, and we end up in a bad. Obviously, my approach is not working.

    She thinks that I'm asking questions to blame her for being stupid, which is definitely not my intention, but my emotional intelligence is 0 out of 10.

    Her approach

    If she asks a question, I should give an answer to help here solve any issue right away. She refuses to accept that she doesn't understand the essential things to complete homework and prefer to just pass.

    I could act under here approach, but it would take 2 hours of my time daily and will not help her in the long term

    Question

    How would you suggest me to act?

    Should I just tell that I'm not able to help?

    Should I accept all blaming that I'm not supportive?

    submitted by /u/vlad-metric
    [link] [comments]

    TEDx Talk "How Computer Science Made Me Brave"

    Posted: 04 Dec 2019 05:57 PM PST

    This speech encourages people to learn programming to increase their creativity and confidence.

    I thought it would be inspirational to some of you struggling with learning right now.

    https://youtu.be/nZ1ehJqXor0

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

    What exactly is classified as "DevOps" knowledge for Full-Stack Developers?

    Posted: 04 Dec 2019 08:08 PM PST

    I often see Full-Stack Developers as being described as being able to do a little bit of DevOps work.

    But what does that actually mean?

    DevOps can be anything from knowing how to simply use GitHub all the way to knowing the in's and out's of SRE work (using Chef/Puppet/Ansible and understanding large Infrastructure / Distributed Systems).

    Do most Full-Stack Developers need to know AWS? What about Docker? Or is Heroku sufficient?

    I often hear that AWS and Docker are overkill for personal side projects for junior Developers, yet I see junior Developers using AWS S3, Lambda, EC2, and Docker, even Kubernetes on side projects, so I'm not sure what exactly to learn.

    Thoughts?

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

    My ebooks on JavaScript, Python, Ruby regular expressions is free through this weekend

    Posted: 04 Dec 2019 08:13 PM PST

    Hi!

    I just released my book on JavaScript RegExp. It is an example based guide that covers regular expression features one by one from scratch. Each chapter also has a cheatsheet for easy reference and exercises to test your understanding.

    I'm thankful for all the support I received at the start of the year for Python re(gex)? book and I've been able to improve descriptions, examples and book formatting based on various feedback I've received. To celebrate, I'm making all my ebooks free through this weekend. You can still pay if you wish :)

    Hope you find the books useful. As always, I would be grateful for your feedback and suggestions.

    Happy learning :)

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

    Circuit Solve Design Architecture C++

    Posted: 04 Dec 2019 09:41 PM PST

    This will be more of a feedback based question. I am trying to build a circuit simulator in C++ and so I have been studying modified node analysis (MNA). I have been referring to these notes here https://www.swarthmore.edu/NatSci/echeeve1/Ref/mna/MNA3.html. I think I have a fair comprehension of how it works so my thought process is as follows

    • Set up a linear set of equations of the form Ax=y where A is matrix that contains the conductances of the circuit and has been augmented with various 1's, x is a vector of unknowns which has the voltage of all the nodes in the circuit beside a ground and the currents going through and voltage source, and y is a vector of 0s representing summed circuits at a node (KCL) and also contains the voltages of all voltage sources.
    • To solve the circuit we simply solve for the vector x which can be done by left hand multiplying by the matrix A inverse (a library like Eigen can do this). I think this can be done by iterating over all the components in a circuit and getting their conductances and adding them to the correct indices in the matrix.

    To do this I have created the following structure (albeit a simplified version). I have made three classes, a component class that represents a generic component from which specific components will inherit from, a node class representing a voltage node in the circuit, and finally a circuit class that holds all the data. Here are the sample code snippets, the node class

    // node.h class Component; // forward declaration class Node { private: std::unordered_set<Component*> m_components; double m_voltage; public: // public methods ... }; 

    The component class

    // component.h class Node; // forward declaration class Component { private: std::unordered_set<Node*> m_nodes; public: virtual double getValue() = 0; // other public methods ... }; 

    Instance of a class inheriting from component

    // resistor.h class Resistor : public Component { private: double m_resistance; public: double getValue() override {return m_resistance;} // other public methods ... }; 

    Lastly the circuit class

    // circuit.h class Circuit { private: std::unordered_set<Node*> m_nodes; std::unordered_set<Component*> m_components; public: void addComponent(Component* c, Node* n1, Node* n2); // solve for DC state of circuit lets say and handle logic // for getting A matrix void solve(); // other public methods ... }; 

    So the way a user might use these functions is like so

    int main() { Circuit cir; // 10 here is the ohms of the resistor we initialize Resistor* r1(new Resistor(10)); Node* n1(new Node()); Node* n2(new Node()); // This adds the component to the circuit as well as the nodes // to the circuit and the component cir.addComponent(r1, n1, n2); return 0; } 

    Some problems I see is that when I have a generic component pointer being added to the circuit, sometimes I need to update the circuit in a specific way for a specific component. Also I am not really sure how to handle updating timestamps especially when handling AC responses. This could be done using more virtual functions or possibly the visitor design pattern. If anyone could give feedback or offer suggestions I would appreciate it.

    submitted by /u/curiosity-alpha
    [link] [comments]

    Need advice building a back end for my Machine Learning based web application

    Posted: 04 Dec 2019 09:09 PM PST

    Hey guys!

    I recently started making a web app that uses machine learning to allow users to make predictions. The GUI will be made using ReactJs (the front-end), but I am a bit unsure how to approach the back-end. In the past, I've had experience with Google Firebase, which I primarily used for its database and Cloud Functions.

    But for this project, I'm afraid I might have to create a server the conventional way (at least what I understand to be the conventional way) by setting up a database on a server hosted by AWS, and putting my Machine Learning/back-end code on there. I am a bit confused though because I want to know how I can bridge the gap between the back end and front end. With Firebase, we could use the SDK to access the database from the front-end, but how do I do that with the type of back-end I am proposing?

    My question, is what are my first steps to setting up this backend server and enabling it to communicate with the front-end using HTTP? From what I understand, at some point (when I am able to have communication between the back-end and front-end), I'll have to migrate my trained ML model onto the server and have it make predictions based on the user's selection on the web application.

    Any advice is appreciated! Thanks in advance!

    tl;dr - How to set up a back-end that can communicate with my front-end from scratch?

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

    question about loop

    Posted: 05 Dec 2019 12:17 AM PST

    Hello everyone!

    Im doing course in Coursera for SWIFT and I stuck:

    When the code below is executed what will be the final value of the result variable?

    var result = 0

    for x in 0...11 {

    result += x

    }

    I believe the answer is 11 but it says its wrong, any help will be appreciated !

    thank you

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

    What is the minimum viable product for a coding project when you're trying to get hired? How many lines of code?

    Posted: 04 Dec 2019 05:40 PM PST

    I have a bunch of projects on my GitHub ranging from 50 lines of code to 750ish. They do things like:

    - Clone some of Twitter's basic functionality, including signing up and logging in, posting a tweet, and uploading a file to a (firebase) database.

    - Retrieve the friends list of everyone I follow on Twitter, cross-reference who they follow, and make recommendations on who I might like to follow based on who my followers are following.

    - Scrape data from Realtor.ca's databases using GET and POST requests.

    I'm wondering if these projects would be enough to get an employer interested in me. I know it's hard to say, but maybe someone who was recently hired can tell me what their coding portfolio had in it when they were hired so I can compare.

    I've also heard stories of people getting hired when they had simple one page apps in their front-end portfolio.

    But what I'm really wondering is, what should I be aiming for?

    What amount (and quality) of code is enough to prove to an employer that I know a language well enough to work professionally?

    And what should I use as a standard to prove to myself that I am worth employing?

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

    Is there any harm in learning Java and SQL side by side?

    Posted: 04 Dec 2019 11:20 PM PST

    Hey guys, I am an absolute beginner and currently learning Java from MOOC fi. And I am intrigued to learn SQL too. So, is it recommended to learn SQL side-by-side, or should I first complete Java and then learn SQL?.

    TIA. :)

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

    How to start 2d gamedev on java for Android?

    Posted: 04 Dec 2019 10:42 PM PST

    I am New in java and still learning it. I hear many advices that if you want to learn programming language you need to make your own projects. I have an idea about simple 2d game for Android and i would like to start developing it right now, while learning. it would improve my knowledge, give me more experience than Just reading books. 1.So what program should I use to make 2d pixelized world, character etc? I googled, but could not get the final answer, many developers use unity, your suggestions? 2. Any good resources to learn? Is Murachs beginning java book is good for total beginner? I read many books about java and found this one yesterday, previous books were well written but they have many unuseful information. I tried hyperskill and mooc till i stuck thats the main reason i decided to switch to the book. Thats why i dont know what to do :( To start with nerd ranch i need to have at least good understandings of OOP

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

    Lp3thw or Automate the Boring stuff in python?

    Posted: 04 Dec 2019 10:36 PM PST

    It's been 3 months since now that I'm learning python with Lp3thw but it seems to me that the book isn't so clear. In fact all the things I learned by now are from the Internet beacuse in that book Zed Shaw DOESN'T teach most anything. I've done some research and I found ATBS in every recommendation. Now, would you quit Lp3thw (ex38) to start ATBS?

    submitted by /u/55Fenomenale
    [link] [comments]

    Not getting correct OUTPUT!!

    Posted: 04 Dec 2019 10:34 PM PST

    In this question of Hackerrank https://www.hackerrank.com/challenges/apple-and-orange/problem. My source code goes as:

    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
    int main()
    {
    long int s,t,a,b,na,no,apple[200000],orange[200000],i,diffa,diffb,counta=0,countb=0;
    scanf("%ld%ld",&s,&t);
    scanf("%ld%ld",&a,&b);
    scanf("%ld%ld",&na,&no);
    for(i=0;i<na;i++) scanf("%ld",&apple\[i\]); **for**(i=0;i<no;i++) scanf("%ld",&orange\[i\]); **if**((a<s)&&(a<t)&&(a<b)&&(s<t)&&(t<b)) { diffa=s-a; **for**(i=0;i<na;i++) { **if**((apple\[i\]>=diffa)&&(apple[i]<=t))
    counta++;
    }
    diffb=t-b;
    for(i=0;i<no;i++) { **if**((orange\[i\]<=diffb)&&(orange\[i\]>=-s))
    countb++;
    }
    printf("%ld\n",counta);
    printf("%ld",countb);
    }
    return 0;
    }
    I passed 3 test cases but not all of them. For rest of the test cases it says Wrong Answer.

    One of the test cases is this: https://hr-testcases-us-east-1.s3.amazonaws.com/25220/input03.txt?AWSAccessKeyId=AKIAJ4WZFDFQTZRGO3QA&Expires=1575534744&Signature=q3z2PKe%2FOhN84itRbqd%2B0EEyzzI%3D&response-content-type=text%2Fplain

    Output for this test case is this: https://hr-testcases-us-east-1.s3.amazonaws.com/25220/output03.txt?AWSAccessKeyId=AKIAJ4WZFDFQTZRGO3QA&Expires=1575534795&Signature=FPLNQRiWV11WfQIGa0kNHt%2BgOHE%3D&response-content-type=text%2Fplain

    But for my program it says wrong answer. Where am I doing wrong?

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

    Card game - python

    Posted: 04 Dec 2019 04:33 PM PST

    I'm trying to write some python code based on the card game Set. The first half is complete and doesn't need to be messed with, but the second half needs a lot of work. Any suggestions would be great

    """PART 1 -- the set cards: Study the SetCard class (SetCard.py). """ class SetCard(object): ''' instance variables (attributes) for color, count, shading, shape ''' ### DO NOT CHANGE THIS CLASS! # constructor: expects a value for each instance variable (attribute) # count is int color, shading, shape are each a one letter code def __init__(self, count, color, shading, shape): self.count = count self.color = color self.shading = shading self.shape = shape # getter methods, one for each attribute def getCount(self): return self.count def getColor(self): return self.color def getShading(self): return self.shading def getShape(self): return self.shape # displayCard method prints out the elements of one set card. # Works by calling a specific method for each non-numeric attribute. def displayCard(self) : print(self.count, self.displayColor(), self.displayShading(), self.displayShape(), end=' ') # converts color attribute to a String for output def displayColor(self) : if (self.color == "R"): return "Red " elif (self.color == "G"): return "Green " else: return "Purple" # converts shading attribute to a String for output def displayShading(self): if (self.shading == "O"): return "Open " elif (self.shading == "S"): return "Solid " else: return "Striped" # converts shape attribute to a String for output def displayShape(self): if (self.shape == "D"): return "Diamond " elif (self.shape == "O"): return "Oval " else: return "Squiggle" """ PART 2 -- the PlaySet program INFO ABOUT PROGRAM STRUCTURE: The basic idea of the program is this: - create a deck of 81 set cards - randomly select 12 cards to put on the table, display the table cards - repeatedly do the following until the user says to Quit or the deck has no cards left (the user has to play at least one round, and after that round and each subsequent round the user is given the choice to Quit or keep Playing) - ask the user to specify 3 cards that might be a set - if they are a set: indicate to the player that they found a set,remove the 3 cards from the table, replace them with 3 cards randomly chosen from the deck - redisplay the table cards There are a few key points to note: The program has two play modes. - In one mode, the deck cards will be loaded from a file that is given to you (testInput.txt), and the sequence of cards chosen for the table is determined by the numbers in a file that is given to you (testSequence.txt). This provides a mode that simplifies testing of your code. - In the other mode, the program will generate the 81 cards in the deck, and will handle the random selection of new cards for the table. Keep in mind that your program should never pull a card more than once from the deck. This means that you must indicate in the deck that a card is no longer available possibly check more than one location in the deck in order to find an available card. You must utilize the color, shape, shading encoding given in the starter code. If you do not, then the data file we have provided will not work properly and it will appear that your program does not work correctly. """ import copy import random from SetCard import SetCard as SetCard random.seed() # restart the random number generator based on clock time # three global variables that we need for getting the next card in the sequence sequence = [] sequenceIndex = 0 loadFromFile = False def main (): ''' ADD TO THIS ''' global sequenceIndex, loadFromFile # this forces Python to use/change the global var # deck, table will both be lists of SetCard deck = [] # deck will eventually hold 81 cards table = [] # table will hold 12 cards at a time print("Should the deck be generated randomly or loaded from file?") print("Enter 'False' for random or 'True' for load from file: ") loadFromFile = input() # have to convert from input text to Boolean value if loadFromFile == 'True': loadFromFile = True else: loadFromFile = False # build deck with data loaded from file if loadFromFile: loadDeck(deck) # loadDeck is provided for you below # else generate a deck else: makeDeck(deck) # populate the deck # fill the table with initial group of 12 cards (and remove them from deck) for i in range(0, 12): selectIndex = getGoodIndex(deck) table.append(copy.copy(deck[selectIndex])) # no aliasing!! deck[selectIndex] = 0 # use 0 to indicate that card was used print() displayTable(table) print() ''' PUT THE GAMEPLAY LOOP HERE. UNDER WHAT CONDITIONS DOES PLAY CONTINUE? WHAT HAS TO BE DONE EACH TIME THROUGH THE LOOP? WHAT DOES ONE ITERATION OF THE GAME LOOK LIKE? ''' #------------------------------------------------------------ # isEmpty function: a deck is passed in as a parameter. # The return value is a boolean which is true if the deck has no more # cards available. Otherwise false is returned. # WRITE THIS function #-------------------------------------------------------------- # makeDeck function: a deck is passed as a parameter (it will be empty) # This function is responsible for putting cards into the deck. # It will have to use the SetCard constructor. # WRITE MOST OF THIS function def makeDeck(deck): # You MUST stick with these encodings for the card data, and remember that # the allowable count values are 1, 2, 3 colorChoices = ["R", "G", "P"] shapeChoices = ["O", "D", "S"] shadingChoices = ["O", "S", "T"] # WRITE THE REST OF THE CODE THAT GENERATES ALL # 81 COMBINATIONS OF COUNT, COLOR, SHADING, SHAPE, # AND PUTS CORRESPONDING CARDS IN THE DECK #-------------------------------------------------------------- # isSet function: receives three cards as parameters. # Returns a boolean value: true if the cards form a set, false if they don't. # Bases its result on whether each of the 4 characteristics satisfies # the rules for a set. def isSet(card1, card2, card3): # each characteristic has to be same or have all three values present return colorMatch(card1, card2, card3) and countMatch(card1, card2, card3) and \ shapeMatch(card1, card2, card3) and shadingMatch(card1, card2, card3) #-------------------------------------------------------------- # YOU MUST PROVIDE THE FOUR FUNCTIONS THAT ARE INVOKED BY isSet. EACH # MUST RETURN True IF THE SPECIFIED CHARACTERISTIC # SATISFIES THE SET REQUIREMENTS ACROSS THE THREE CARDS. # colorMatch function: receives three cards as parameters # Returns a boolean: True if the color characteristic satisfies the requirements for a set # countMatch function: receives three cards as parameters # Returns a boolean: True if the count characteristic satisfies the requirements for a set # shapeMatch function: receives three cards as parameters # Returns a boolean: True if the shape characteristic satisfies the requirements for a set # shadingMatch function: receives three cards as parameters # Returns a boolean: True if the shading characteristic satisfies the requirements for a set #-------------------------------------------------------------- # getGoodIndex function: receives a deck as parameter # Returns an integer which represents the location in the deck of a card def getGoodIndex(deck): global sequenceIndex, loadFromFile # if the data was loaded from file, then there is no need to generate a random # value for the index. We can just grab the next value in the provided # sequence of index values if (loadFromFile): selectIndex = sequence[sequenceIndex] sequenceIndex += 1 else: # WRITE CODE THAT WILL GENERATE AN INDEX OF A VALID CARD IN THE DECK. # (MAY BE NECESSARY TO GENERATE MORE THAN ONE RANDOM INDEX) # IN ORDER TO FIND A LOCATION IN THE DECK THAT STILL HAS A CARD return selectIndex #-------------------------------------------------------------- # displayTable function: receives the table as a parameter. # Displays the table, using the displayCard function for each card. # DO NOT CHANGE FUNCTION def displayTable(table): # display cards on table for i in range(0, 12): table[i].displayCard() if (((i+1) % 3) == 0): # only 3 cards per row in the display print() #-------------------------------------------------------------- # load a sample deck of cards to use. # will be run if the user specifies that the deck should be # loaded from a file. # DO NOT CHANGE FUNCTION def loadDeck(deck): fileIn = open('testInput.txt', 'r') fileData = fileIn.read() # get the entire line of data splitData = fileData.split(",") for i in range(0, 81): offset = i * 4 deck.append(SetCard(splitData[offset], splitData[offset+1], splitData[offset+2], splitData[offset+3])) fileIn.close() loadSequence() # set up the sequence from which to draw cards #-------------------------------------------------------------- #load the sequence from which to draw cards # will be run if the user specifies that the deck should be # loaded from a file. In that case the program # also generates a fixed sequence that is used # for selection of table cards. # DO NOT CHANGE FUNCTION def loadSequence(): fileIn = open('testSequence.txt', 'r') fileData = fileIn.read() splitData = fileData.split(",") for i in range(0, len(splitData)): splitData[i] = int(splitData[i]) for i in range(0, 81): sequence.append(splitData[i]) fileIn.close() main() 
    submitted by /u/throwaway8649287
    [link] [comments]

    Analysing Latin Words

    Posted: 04 Dec 2019 10:30 PM PST

    I want to write a Script (in Python or Java), that takes a Latin word as input and then finds out wheter its a verb, noun, adjective or something else, and then returns details about this word like the tense, person, whether it's active or passive etc. For example input:"vici" output: [past tense, 3.person singular, masculine]

    What is the best way to do this? Is this even possible without an enormous amount of work/are there any library's or something I could use?

    submitted by /u/5pun_
    [link] [comments]

    Does anyone know the tech used to create The Marthon Clothing's Smart Store?

    Posted: 04 Dec 2019 10:23 PM PST

    Developed by Iddris Sandu . Heres a link to what I'm talking about specifically. Mystery Language

    Thank you

    Clarification: the link is to a Instagram clip of Iddris using the tech in action.

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

    [Unity C#] Pong question

    Posted: 04 Dec 2019 10:13 PM PST

    Hello! I'm making pong, and i'm trying to make it to where if it is the left paddle then it only uses W and S and if it's the right paddle it uses up and down arrow. I made an enum for leftPaddle and rightPaddle. How would I wrap the movement code into lets say: if(leftPaddle) {u can use w and s but not up and down arrow}. Thanks!

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

    Quick questions about programming

    Posted: 04 Dec 2019 10:04 PM PST

    Typical bs I know with these questions but they're legitimate.

    I'm little over a year away from ETSing from the Army and really want to get into computers in some way. I work with them all day, though all I do is clean, maintain and provide early warnings for the air defense battery here. I've always loved them and use them all day at work and at home. But what has peaked my interest the most that I've seen is programming.

    It's just, honestly, the coolest thing to witness to me. Watching these crazy looking lines written down that cause x thing to work, etc etc. I want to make that a career and go to college for it. I'm currently most interested in learning Windows OS programs, since that's what I am already most comfortable with.

    So my questions are as follow:

    1) What is the best degree to pursue for such a career?

    2) Is it something that's truly enjoyable and fun to work with as a career?

    3) Any tips and tricks for a newbie?

    4) Any other suggestions outside of programming, or am I looking at a good, solid career path?

    Any and all help is greatly appreciated!

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

    Struggling with the decision to go to college for Computer Science

    Posted: 04 Dec 2019 09:50 PM PST

    I am a web developer and have been struggling with the decision on whether or not to continue my education in college. I dropped out, despite my parents wishes, around year 3 in my pursuit of a degree in Computer Engineering and a minor in Computer Science.

    I have finally become comfortable in my decision in permanently dropping out as I have maintained a solid growing career in Web Development with now managing a team as a lead developer. I have even come to a point where I regret going the 3 years I did considering the loss of time and money and understanding the requirements of becoming a web developer.

    Though for me I do not believe going to college for a Computer Science degree is a good idea, I do believe it is right for some paths.

    I made a video to explain my thought process and the pros and cons I saw by walking both paths as a traditional student, and the path as a self taught developer.

    https://www.youtube.com/watch?v=ybOuWyQB0ug

    I am interested in your thoughts and personal stories as well, and I hope to reach others that are struggling with a similar choice and decision.

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

    What is a good method of creating a desktop application similar to a blog in VB.NET?

    Posted: 04 Dec 2019 09:44 PM PST

    I wanted to create a desktop application similar to a blogging website where you can add and remove a long list of text, do a keyword search and browse many blogs. I'm coding in vb.net. Any idea on how to tackle this project on what methods and algorithms should I be looking for? I first thought of database but I didn't find a way on how to input long list of text.

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

    Learn Coding Channel! :D

    Posted: 04 Dec 2019 09:40 PM PST

    I'm am employee at a FAANG company, and I've made a coding channel! :D

    About a year ago, I tried making a channel dedicated to teaching coding. Since then, I've done YouTube more as a hobby/way of discussing issues that are important to me, but I've decided to reboot my coding channel with my new video skills 🤩

    Right now I'm focusing on making videos about CS Fundamentals. My current 2 videos are more concept focused, but I'll be making plenty where I code along too. Also my channel branding is like.. non-existent and pretty tacky rn :P I'll be working through that over time. :P

    Lemme know your thoughts or suggestions for topics! :D I'll probably be doing 2ish videos per month to start (especially with the concept-focused videos since they involve a bit of time editing and scripting).

    Here's the channel link: https://www.youtube.com/channel/UCwKgUU85RbyFDT-sjbqS21g

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

    Need help with making this code work

    Posted: 04 Dec 2019 09:08 PM PST

    I am making a program to read a text file, parse the contents and assign the contents into class variable. However I am getting the following error

    Exception in thread "main" java.util.InputMismatchException

    at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextInt(Scanner.java:2258) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at CourseWork.Inventory.readParse(Inventory.java:16) at CourseWork.StockProgram.main(StockProgram.java:8) 

    My classes are follows:

    StockProgram.java

    package CourseWork;

    import java.io.FileNotFoundException;

    public class StockProgram {

    public static void main(String[] args) throws FileNotFoundException {

    Inventory assets = new Inventory();

    assets.readParse();

    }

    }

    Inventory.java

    package CourseWork;

    import java.io.File;

    import java.io.FileNotFoundException;

    import java.util.Scanner;

    public class Inventory{

    void readParse() throws FileNotFoundException {

    Scanner readFile = new Scanner(new File("inventory.txt"));

    readFile.useDelimiter(",\\s");

    StockItem[] items = new StockItem[0];

    while(readFile.hasNext()) {

    String name = readFile.next();

    String stock_code = readFile.next();

    int stock = readFile.nextInt();

    int unitP = readFile.nextInt();

    String Value = readFile.next();

    StockItem newStockItem = new StockItem(name, stock_code, stock, unitP, Value);

    items = addStockItem(items, newStockItem);

    }

    }

    private static StockItem[] addStockItem(StockItem[] items, StockItem itemToAdd) {

    StockItem[] newStockItems = new StockItem[items.length + 1];

    System.arraycopy(items, 0, newStockItems, 0, items.length);

    newStockItems[newStockItems.length - 1] = itemToAdd;

    return newStockItems;

    }

    }

    StockItem.java

    package CourseWork;

    public class StockItem {

    static String name;

    static String stock_code;

    static int stock;

    static int unitP;

    static String Value;

    StockItem(String name, String stock_code, int stock, int unitP, String Value){

    this,name = name; //ignore the "," on this line. I added that instead of "." because reddit doesn't allow that

    this.stock_code = stock_code;

    this.stock = stock;

    this.unitP = unitP;

    this.Value = Value;

    }

    }

    inventory.txt

    resistor, RES_1R0, 41, 1, 1

    resistor, RES_10R, 467, 1, 10

    resistor, RES_100R, 334, 1, 100

    capacitor, CAP_10pF, 648, 12, 0.01

    capacitor, CAP_30uF, 2, 73, 30000

    capacitor, CAP_300uF, 585, 85, 300000

    diode, BY126, 118, 12

    diode, BY127, 45, 12

    diode, 1N4004, 194, 6

    diode, 1N4148, 201, 5

    transistor, AC125, 13, 35, PNP

    transistor, AC126, 40, 37, PNP

    transistor, BC107, 20, 10, NPN

    transistor, BC108, 9, 12, NPN

    transistor, TIS88A, 42, 50, FET

    transistor, OC44, 57, 50, PNP

    transistor, 2N2369A, 37, 18, NPN

    IC, NE555, 8, 17, "Timer"

    IC, LF356, 1, 45, "JFET op-amp"

    IC, Z80A, 0, 800, "CPU"

    IC, TL741, 20, 12, "op-amp"

    Thank You very much for your Help

    Edit: Forgot to add the Text File

    Edit2: I made it readable

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

    How to make python return a bunch of values from a if statement and for loop and put it inside of a dictionary.

    Posted: 04 Dec 2019 08:37 PM PST

     import csv def democrat(a,b): a = {} b = {} with open("presidents.txt") as f: reader = csv.reader(f) for header in reader: if "Democrat" in header: return a elif "Republican" in header: return b else: break democrat(a,b) 

    sample of my csv file:

    George H. W. Bush,Republican,1989,1990,1991,1992 Bill Clinton,Democrat,1993,1994,1995,1996,1997,1998,1999,2000 George W. Bush,Republican,2001,2002,2003,2004,2005,2006,2007,2008 Barack Obama,Democrat,2009,2010,2011,2012 

    So I have this function that I am trying to make a dictionary for separate presidents in the different parties. So I have if statements that see if Democrat or republican are inside the header, and if they are, return that row.

    I used the if statements before and used to print democrat or republican, so the if statements arent the problem.

    The problem is using return. When it gets the first value it just returns and stops the loop altogether. How do i get it to iterate through and get all of the values inside of the csv file? I also need them to be inside different dictionaries: one for republican, one for democrat.

    Comment

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

    With JavaScript, is there ever a time where we should NOT use arrow functions?

    Posted: 04 Dec 2019 11:18 AM PST

    As I've been learning React, I've also learned how arrow functions actually solve some issues with binding where the usual function() {} setup produces some errors. So I'm just wondering if there is ever a time where we should not use arrow functions in general, or is it safe to always use arrow functions?

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

    No comments:

    Post a Comment