• Breaking News

    Wednesday, May 8, 2019

    LPT: Learn git, open a github account, and upload even the smallest piece of code you write learn programming

    LPT: Learn git, open a github account, and upload even the smallest piece of code you write learn programming


    LPT: Learn git, open a github account, and upload even the smallest piece of code you write

    Posted: 07 May 2019 06:52 AM PDT

    Try to get every day to be green - https://i.imgur.com/3zM0ajy.png

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

    Any beginner friendly resources to learn the linux command line?

    Posted: 07 May 2019 04:04 AM PDT

    Hi,

    So I recently joined a new company where everything is on linux and coming from a fairly simple world of windows and GUI, I'm intimidated by the linux long timers' impressive cli skills.

    The tutorials I came across are too hardcore for a total newbie and I'm having a hard time picking it up.

    I see it as kind of a culture or a mindset where people do everything on cli (debugging c++ using gdb cli, vim for coding and whatnot) and I'm very eager to get into the clan as well.

    Please guide me or share your journey from a GUI person to a CLI nut. Thanks!

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

    There's Such a Thing As Using Too Many Ifs

    Posted: 07 May 2019 09:25 PM PDT

    All the below code examples are JavaScript, but are hopefully easy to follow along if you know your if/else. Let me know if there's any confusion or if you have any questions.

    I've copied the whole article here, but there's a link at the bottom to the original with syntax highlighting if it helps.

    How Many Is Too Many?

    Some people think that number is one and you should always substitute at least a ternary for any single if statements. I don't take that staunch of an approach, but I want to highlight some ways to escape common if/else spaghetti code.

    I believe a lot of developers fall into the if/else trap so easily, not because of the complexity of other solutions, but because it follows such a natural language pattern:

    if something do this, else do this instead.

    Wait, What's a Ternary?

    A ternary isn't a revolutionary difference from an if/else as they're both conditional operations, but a ternary does return a value so it can be used directly in an assignment.

    const greaterThanFive = (8 > 5) ? 'yep' : 'nope'; console.log(greaterThanFive); // 'yep' 

    The basic pattern is just a condition, one value to return if truthy, and one value to return if falsy.

    (condition) ? isTruthy : isFalsy 

    An alternative to If/Else

    Let's start with a scenario and walk through examples of different solutions.

    We'll be taking colors from user input and need to turn them into some preset color codes to match so we can change our background color. So we'll check for strings of color names and set our color code if we have a match.

    const setBackgroundColor = (colorName) => { let colorCode = ''; if(colorName === 'blue') { colorCode = '#2196F3'; } else if(colorName === 'green') { colorCode = '#4CAF50'; } else if(colorName === 'orange') { colorCode = '#FF9800'; } else if(colorName === 'pink') { colorCode = '#E91E63'; } else { colorCode = '#F44336'; }; document.body.style.backgroundColor = colorCode; }; 

    This if/else gets the job done. But we're saddled with a lot of repetitive logic comparing colorName and repetitive assignment of colorCode.

    Switch

    Now we could more appropriately change this into a switch statement. It better fits the concept of what we're trying to do; We have several cases of strings we want to match, and a default if none of our cases match.

    const setBackgroundColor = (colorName) => { let colorCode = ''; switch(colorName) { case 'blue': colorCode = '#2196F3'; break; case 'green': colorCode = '#4CAF50'; break; case 'orange': colorCode = '#FF9800'; break; case 'pink': colorCode = '#E91E63'; break; default: colorCode = '#f44336'; }; document.body.style.backgroundColor = colorCode; }; 

    But a switch still comes with a lot of boilerplate and repetitive code we could do without.

    Lookup Table

    So what are we really trying to accomplish here? We need to assign color codes in hex to color names, so let's create an object that holds color names as keys, and color codes as values. Then we can look up our color code by its color name by using object[key]. And we need a default value, so a short ternary that returns the default if no key is found will do so all while making the default part of our object.

    const colorCodes = { 'blue' : '#2196F3', 'green' : '#4CAF50', 'orange' : '#FF9800', 'pink' : '#E91E63', 'default': '#F44336' }; const setBackgroundColor = (colorName) => { document.body.style.backgroundColor = colorCodes[colorName] ? colorCodes[colorName] : colorCodes['default']; }; 

    Now we have a lookup table that neatly lays out our inputs and possible outputs.

    This isn't about a miraculous 'lines of code' (LOC) reduction (we went from 15 to 20 to 12.) In fact, some of these solutions may increase your LOC, but we've increased maintainability, legibility, and actually reduced complexity by only having one logic check for a default fallback.

    Trade Logic For Data

    The most important accomplishment of using a lookup table over an if/else or switch is that we've turned multiple instances of comparative logic into data. The code is more expressive; it shows the logic as an operation. The code is more testable; the logic has been reduced. And our comparisons are more maintainable; they're consolidated as pure data.

    Let's reduce five comparative logic operations to one and transform our values into data.

    Scenario: we need to convert grade percentages into their letter grade equivalent.

    An if/else is simple enough; we check from top down if the grade is higher or equal than what's needed to match the letter grade.

    const getLetterGrade = (gradeAsPercent) => { if(gradeAsPercent >= 90) { return "A"; } else if(gradeAsPercent >= 80) { return "B"; } else if(gradeAsPercent >= 70) { return "C"; } else if(gradeAsPercent >= 60) { return "D"; } else { return "F"; }; }; 

    But we're repeating the same logic operation over and over.

    So let's extract our data into an array (to retain order) and represent each grade possibility as an object. Now we only have to do one >= comparison on our objects and find the first in our array that matches.

    const gradeChart = [ {minpercent: 90, letter: 'A'}, {minpercent: 80, letter: 'B'}, {minpercent: 70, letter: 'C'}, {minpercent: 60, letter: 'D'}, {minpercent: 0, letter: 'F'} ]; const getLetterGrade = (gradeAsPercent) => { return gradeChart.find( (grade) => { gradeAsPercent >= grade.minpercent; }; ).letter; }; 

    Start Imagining Your Comparisons As Data

    When you need to compare or "check" values it's natural to reach for the if/else so you can verbally step through the problem. But next time try to think of how your values can be represented as data and your logic reduced to interpret that data.

    Your code will end up being more readable, maintainable, and purposeful in its intent with a clear separation of the concepts it represents. All of the code examples here function, but the right approach can turn It Works™ Code into 'great to work with' code.

    Link to original article

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

    Wordpress theme suggestions for developer blog/portfolio?

    Posted: 07 May 2019 08:38 PM PDT

    Hey guys. I'm working on getting a developer blog/portfolio page setup to improve my web presence and getting myself out there. I'm planning on doing a wordpress site, as I honestly just want this project to quick and simple so I can spend most of my free time improving my javascript skills and working on portfolio projects. I was wondering if anyone had any good themes they've used that they would recommend? I'm really looking for a simple design rather than something super artistic. Just thought I'd see if there were any you loved and wanted to recommend! Thanks!

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

    What is the future of JavaFX?

    Posted: 07 May 2019 10:06 PM PDT

    I really love JavaFX. I know it may not be of industrial significance, but I like to use it personally because of how damn easy it is. Seriously, is any other GUI framework as easy as this?

    But ever since it's not a part of the JDK itself, it has become much difficult to get it working completely. I did manage to get it to work in in IntelliJ, compile and run programs, but even IntelliJ can't make artifacts from it anymore.

    Due to these problems, I have switched back to JDK 10 and still using it. It's super easy. IntelliJ compiles my program into Jar and windows applications easily. Why did Java remove this feature? Is JavaFX doomed? I'm just so confused.

    Edit: This is my main problem

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

    [Question] My 10 year old wants to learn how to code/program but I don't have the slightest idea where to start.

    Posted: 07 May 2019 04:57 PM PDT

    I asked him earlier if he wanted to earn some money by learning how to use the lawn mower. He said he'd rather learn how to code. I thought this was fantastic and absolutely want to help him succeed for the future. The problem is that I have very little knowledge of where to start him. He does have a gaming laptop if that means anything at all. Any help would be greatly appreciated. Thanks

    Side note, he's still going to learn to cut the damn grass lol

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

    Personal project using rachet belt mechanism and Kinect. What do I need to learn language?

    Posted: 07 May 2019 11:58 PM PDT

    The project I'm planning on will utilize the following so far:

    -Some sort of tension meter(not sure if analog or digital)

    a. If the meter is analog possibly OCR to capture the readings of the meter

    b. If digital, a program to capture the readings of the meter.

    -A lever or means of adjusting said ratchet belt

    -A Kinect or similar camera. I've read about the driver hacks for Kinect to be used with PC, but I'm not sure how getting readings from the said camera would work(either with Kinect or similar consumer level camera).

    I assume for the meter it would depend on the means of reading. A digital one I figure involve whatever language the meter output in(I've seen some that even output via wifi but that's as far as I know for that tool). The mechanism might involve lower languages like C? As for the camera, I don't have much as a clue what the process would be calculating the angle say of shape from visual input.

    Edit: Sorry for title typo. Btw this isn't hw but I figured that was the best flair for the topic.

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

    Css and html fonts, download vs linking?

    Posted: 07 May 2019 11:55 PM PDT

    So I get that you can go to google select the fonts you want to use, and make a link and put that into you head. But when google doesn't have them. It seems all the sites only have a download option. I'm assuming so there not a ton of linking traffic headed to their site and it doesn't disable it. So I download it, and load it to my hosting server, or locally. putting it in a folder like I would images or something? And this makes things load faster, especially if google or something is having an issue?

    Specifically I'm trying to use font-family: Brandish; and font-family: Ink-free;

    Thanks

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

    Cors error from Api

    Posted: 07 May 2019 11:42 PM PDT

    Hi, I'm currently developing an app that makes a xmlhttprequest to a third party api. I used to test it in my localhost and never had any problems until today, im getting this error

    Access to XMLHttpRequest at 'http://thirdpartysite.org' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: The response is invalid.

    Does this means that they limited the access? or what?.

    Thanks in advance!

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

    How do I use express with vueJS for making an Single-page app?

    Posted: 07 May 2019 11:03 PM PDT

    I'm trying to make a social-media like app in express. Most tutorials teach you how to load all pages server-side, but I wanna do it client-side as a single-page app by using VueJS. How do I do that with Express?

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

    Should I learn Flask after learning Node and Express?

    Posted: 07 May 2019 10:23 PM PDT

    Heya, I recently started self-teaching myself Web Development in HTML5, CSS3, and JavaScript, with both PHP and Node/Express on the backend. I am considering learning an additional language, and was curious if there is any benefit to learning Flask?

    The reason I ask is that I noticed that Harvard's CS50 Intro to CS teaches Flask as if it were the best first web framework to learn, so I am wondering if I am missing out on any opportunities by not learning it. I am also looking at Django and Rails.

    Should I stick with Node/Express or would I be better off learning another language?

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

    What can I exactly do with the word print

    Posted: 07 May 2019 10:17 PM PDT

    So I'm trying to learn coding and I have figured out hello world or whatever but what could I do want the print I'm also trying to code tic tac toe if anyone has tips for tic tac toe using python

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

    Keyboard-Only Programming Setup

    Posted: 07 May 2019 09:48 PM PDT

    I'm an intermediate-level hobbyist/considering-turning-professional programmer who wants to be able to work anywhere (aka. comfortably in bed) without relying on a mouse or trackpad. What programs or combination of tools (text editors, file managers, desktop environments, etc.) would you recommend to fulfill this goal? I'm well aware of emacs and vim as choices for a keyboard-based text editor but would like to hear about easier-to-learn alternatives.

    My current/planned setup for this is a laptop running Ubuntu, the i3 window manager, ranger, and emacs.

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

    How to prepare for data structures?

    Posted: 07 May 2019 09:33 PM PDT

    I am taking data structures this summer and I know nothing. I have 6 weeks to prepare for it. Please tell me a good resource/stuff I should learn before my class starts. I need to know c++ stuff up to and including pointers/linked list. At our school there's a class before data structures, which is a pre req, which is basically cs 101 which teaches you that stuff but I already have credit for that class from 4 years ago when i took it as a non-cs major so didn't care and forgot everything. My plan was just to learn that class stuff on my own, I got all the material from my friend in the class, but if you guys have a better use where I can spend my time let me know. Because that class has 6 programming projects (500 lines code each), 40 lecture videos (50 mins each), 14 labs, 14 short quizzes, 3 exams. So it might be hard to do in 6 weeks, but I will try my best to finish all of it. Otherwise if you can tell me a better resource I can use my time on the next 6 weeks to learn c++ up to/including pointers/linked list please let me know.

    Data structures is pretty hard so I don't think a 5 hour full c++ tutorial would be enough, I need lots of practice and learning for all the topics of c++ up and including linked list

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

    The best time to make make yourself a snippets library was the first time you coded. The next best time is now.

    Posted: 07 May 2019 12:44 PM PDT

    I humbly suggest creating a repo with folders for each major area of your coding studies- css, javascript, whatever, and filling them with markdown file notes explaining topics you're learning, in your own words, as well as code snippets you can reference later. This will slowly build into a really useful personal reference as well as helping you practise using git. I feel like an idiot for struggling with evernote and similar options when the best thing was right there. Even more so, now that even github offer private repositories. Good luck and keep going.

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

    What does "expensive" mean in the context of SRAM and DRAM?

    Posted: 07 May 2019 03:26 PM PDT

    This may not be the right place to ask this question, but every time I try to look up the difference, it always says SRAM is more "expensive". What exactly is meant by this?

    submitted by /u/8-bit-eyes
    [link] [comments]

    Why does this program run properly on python IDLE but not on my terminal using ATOM?

    Posted: 07 May 2019 05:24 PM PDT

    Here is the code for the program :

    def hard(challenge) :

    return challenge

    a = input()

    b = int(a)

    c = b + 5

    hard(c)

    When I run this using the python IDLE it works fine. However, when I type it on ATOM and run it using my Mac's terminal it gives me this :

    Traceback (most recent call last):

    File "ex4.py", line 2, in <module>

    b = int(a)

    ValueError: invalid literal for int() with base 10: ''

    It says that the problem is with line 4. I've spent hours trying to figure out why this runs on the python IDLE and not on my terminal via ATOM. I'm (obviously) new to programming and this makes it difficult to know whether the IDLE or the terminal is running my code correctly.

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

    Trying to learn basic MYSQL from a youtube video, but I cannot figure out what is wrong with my syntax and it is making me irrationally angry

    Posted: 07 May 2019 09:07 PM PDT

    I'm stuck on this https://www.youtube.com/watch?v=HXV3zeQKqGY&t=5596s. My syntax is this: INSERT INTO students (1, 'Jack', 'Biology');

    I keep getting this

    ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1, 'Jack', 'Biology')' at line 1 

    Anyone know what I am doing wrong?

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

    Which courses do you think are the most useful in SWE career?

    Posted: 07 May 2019 08:52 PM PDT

    ***

    So, I got into my top choice school. I really like it (small classes, amazing faculty), and I've gotten pretty much a full ride from them. The problem is that it's a LAC (an elite LAC).

    So, my question to you is:

    Which courses do you think are the most useful for a future SWE? Obviously CS courses--which ones are absolutely essential? But also other STEM disciplines (for example, is Calculus 3 a must-have for people outside the game dev?), and--hell--even humanities and social sciences: There must be something you were glad you knew or wished you had taken in particular (like business/management classes or economics).

    Since I'm going to have to package my degree myself (there are no distribution requirements), I am looking forward to suggestions on how to build up my curriculum.

    If that matters, I'm considering going to a grad school, but I also want to be employable. Will definitely work before getting my master's. Maybe the company will pay for it. So, I want to be both good material for the grad school, but also very marketable. I would really appreciate your advice.

    Thanks!

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

    Finding it hard to look for intermediate resources

    Posted: 07 May 2019 02:52 PM PDT

    So I've been coding for about a year while balancing school , I understand the basics from variables to Views and with a bit of simple logic I have put together a basic single view app.

    But I wish to progress to slightly more intermediate levels of code , but I simply can't find any resources to help , Apple Swift documentations is about it , can any one please suggest any website or playlist on YouTube that is helpful

    Things like better optimization , layout of the code and other Stange but useful things like that. You know intermediate things

    Thank you

    submitted by /u/Slade-lab
    [link] [comments]

    Do you have to go to college to learn programming on a professional level and actually make it a career, or is it possible through online classes? If so, which ones?

    Posted: 07 May 2019 05:26 AM PDT

    Sorry if this is a stupid question, but I'm a beginner that took some online courses already but noticed that with those courses alone there's absolutely no way that I can make this my career.

    Stuff like codeacademy is good and all but even if it goes more in-dept than simple functions and variables, the reach/influence(?) of your code is limited to the coding app alone, and doesn't do anything substantial. Basically for example your python program only "exists" in IDLE and doesn't affect anything else on your computer outside of the IDLE app.

    Are there any online classes that teach advanced stuff like penetration testing or making complicated software that compares to a real life high school/college class?

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

    Learn Programming using Excel - Pseudo 3D Graphics

    Posted: 07 May 2019 02:30 AM PDT

    Hey guys,

    Excel is a pretty good tool to mess around with programming concepts and testing formulae etc before hardcoding them into your code. I've tried to demonstrate this by setting up what is generally quite complex (when starting out) graphics / math programming - in the easy to understand format of excel.

    Video demo is here:

    https://youtu.be/qoxmyH7GezE

    The excel file is here - feel free to download and play around with it! Almost everything is formula-based to aid understanding: https://github.com/s0lly/Pseudo3DEngineInExcel

    Hope this is helpful! And happy to put other things into excel that you might find interesting to learn through that medium; just let me know what might be of interest!

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

    Issue with my div elements dropping when a certain click event happens?

    Posted: 07 May 2019 08:45 PM PDT

    So I'm working on a to do project and the point is to make multiple to do lists. My problem is that when I create multiple lists by pressing the + in the side nav, and then click the + within the div the div that now has the input box and button elements drops below the other divs. However when i click the + in another div they line back up.

    https://codepen.io/Zach15/pen/qGEpxe

    Here is my codepen to the project. When I inspect it I can't seem to find the issue. My only thought could be that maybe is the divs being displayed as an inline block? No really sure. Anyway any help would be greatly appreciated!

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

    Can someone help me with web programming?

    Posted: 07 May 2019 08:08 PM PDT

    So a friend of mine asked me to create a website for an event he's hosting in a couple of months, and I'm good to go except for one feature he wants.

    He wants users to be able to input their information to register for the event, so that when they get to the event, we can pull up their information and they'll be good to go. I know some SQL and I image a database is required here, but not totally sure where to start. Any help would be greatly appreciated!!

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

    No comments:

    Post a Comment