• Breaking News

    Friday, January 22, 2021

    Created my first substantial (for me at least) program today! learn programming

    Created my first substantial (for me at least) program today! learn programming


    Created my first substantial (for me at least) program today!

    Posted: 21 Jan 2021 03:07 PM PST

    I decided to start learning Python with some of my spare time. Its only been a few days but I felt like I was being too passive just watching tutorials. Now that I had the syntax and very basic concepts down, I decided to venture into creating my first "real" project (i.e. something that would take more than 10 simple lines of code).

    I wrote a program to organize a folder with ~100 mp3s on my computer into new folders based on artist and album into the path music\artist\album.

    It took quite a bit of googling errors and selecting the right modules but I finally got it to run like a charm while following the principle of Don't Repeat Yourself. It feels really good to problem solve on my own rather than have a tutorial tell me what to do or google "how to..."

    Very excited to continue learning!

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

    Any books for JavaScript similar to Automate The Boring Stuff With Python?

    Posted: 21 Jan 2021 05:55 AM PST

    Hello !

    I started to learn Python in October 2020 but I'm moving to JavaScript now. This book helped me immensely to really understand the basics of Python and now that I'm learning JavasCript I'm looking for something similar for this language.

    ​

    So far I've been learning with this website: https://javascript.info/logical-operators (logical operators is the chapter I'm in) but it lacks something that I can't really put my finger on it.

    ​

    So is there anything like this book but for JavaScript? I don't mind if it's for an absolute beginner since I am one or if it's boring. I just want to understand the language better. Thank you :D

    Edit: thnx a lot for the replies! Im saving every book on a list so far and researching about them

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

    Is this a good purchase for a beginner?

    Posted: 21 Jan 2021 10:01 AM PST

    I've come across this bundle of books and wanted a second opinion on how useful they would be for a beginner, or if there are ways I could essentially get the same information for free online.

    So let me know your thoughts.

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

    Do you find it hard to sit down in one spot for more than an hour?

    Posted: 21 Jan 2021 10:50 PM PST

    I think this flaw of mine is what is holding me back from studying more when trying to learn programming. Then I'm going Uni next year and I'm going to be sitting down for long periods a day. Do you have this problem? How do you deal with it? It's also summer in my country and so makes things worse as I don't have air con in my room.

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

    Learn the same thing from different people

    Posted: 21 Jan 2021 11:45 PM PST

    Something I've discovered recently as I've been learning Algorithms and Data structures is that learning the same thing from different people can skyrocket the learning process.

    I was struggling to understand the Big O notation. I read a couple of articles then watched a YouTube video by csdojo. I then read the part about Big O in Cracking the coding Interview as I have the book and then I recently discovered the free courses at Rithm school. I read the part about Big O and everything suddenly made sense.

    I was able to connect all the different dots from the previous things I'd learnt. Just felt I should share this in case anyone is struggling to understand a certain concept.

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

    Free courses on algorihtms by Princeton University

    Posted: 21 Jan 2021 01:03 AM PST

    These are two courses from Coursera (developed by Princeton University) which I highly recommend for introduction to algorithms. I wen through them myself to refresh my algorithm implementation skills :-)

    A word of caution, these courses are not really for people that are just starting with programming, it's more of an intermediate level. All samples and exercises are in Java, so you should have at least basic exposure to Java.

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

    Teaching 10-year-olds programming

    Posted: 21 Jan 2021 09:49 PM PST

    I'm teaching computer programming to some pretty sharp kids, 4th – 6th grade, over zoom. I'm running into some problems. Zoom is terrible for adhoc collaboration, and basic computer concepts are generally way advanced even for smart kids at this ago. They are barely getting into pre-algebra and things like folder structure, program flow and function parameters are real head-scratchers!

    My question: Have you successfully taught programming to a group of kids this young? What techniques and formats worked for you?

    I've tried:

    - General HTML formatting – not really programming and the nesting concepts tend to lose most kids.

    - Code Monster – Too advanced for most

    - Super basic Javascript using an online editor (http://js.do) – Better in some ways, but lack of intellisense hurts, and the concepts are still too advanced for most.

    I'm considering:

    - LOGO https://www.calormen.com/jslogo/

    Note: tools should be web-based since the kids are working from a variety of platforms (Win, Mac, Linux)

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

    Nodejs how to add success and failure pages in this case?

    Posted: 21 Jan 2021 06:11 PM PST

    I am implementing Mailchimp in a local server for learning purposes and I cant figure out how to redirect to a failure page when there is an error in registering a contact's email(e.g. when a user who is already registered tries to register again).Here is my code:

    const express = require("express"); const bodyParser = require("body-parser"); const app = express(); app.use(bodyParser.urlencoded({ extended: true })); const mailchimp = require('@mailchimp/mailchimp_marketing'); app.use(express.static("public")); app.listen(3000, function() { console.log("the server is running on port 3000"); }); app.get("/", function(req, res) { res.sendFile(__dirname + "/signup.html"); }); app.get("/success", function(req, res) { res.sendFile(__dirname + "/success.html") }); app.get("/faliure", function(req, res) { res.sendFile(__dirname + "/faliure.html"); }) app.post("/", function(req, res) { var status = false; const firstName = req.body.fName; const lastName = req.body.lName; const email = req.body.email; mailchimp.setConfig({ apiKey: "xxxxxx", server: "xx", }); const listId = "aa11941909"; async function run() { const response = await mailchimp.lists.addListMember(listId, { email_address: email, status: "subscribed", merge_fields: { FNAME: firstName, LNAME: lastName } }); console.log() console.log( `Successfully added contact as an audience member. The contact's id is ${ response.id }.` ); } run(); }); 

    when I try to use "if(res.statusCode===200) " in the async function run(), there is an error. Please advise on how I should go about redirecting to a success and failure page in this case. Thank you.

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

    JavaScript : When should I really be using OOP Programing?

    Posted: 21 Jan 2021 06:08 PM PST

    I recently finished my first project where I created a game with HTML, CSS, and basic Javascript. After looking at the code and seeing how repetitive it is I've been trying to condense a lot of the original functions and have been trying to implement OOP with it. I've run into many problems such as not being able to re assign objects which i realized I need to use set to do that and other issues. These used to be variables and now I am re thinking the scope of everything. I am now having to re write the entire code instead of revising.

    I am wondering when I should be using OOP and when it isn't necessary. I've recently watched a lecture where the lecturer said to use OOP for everything but I feel that it may not be the right call for this game I created.

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

    How to understand bigger systems and codebases?

    Posted: 21 Jan 2021 07:20 PM PST

    I worked at a company for several months and realized compared to other students I was slow on ramping up and understand how underlying processes work. I am also a weaker programmer, so how do I go about improving this? Is it innate?

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

    Why on some websites all the code on one page?

    Posted: 21 Jan 2021 07:41 AM PST

    Hey, in web development courses, it's always been said to keep your JS scripts, CSS styles in separate files. It's easier to read and keeping the HTML page tidy. But when I inspect some popular websites (I believe made by professionals) all styles, scripts, everything put into an HTML document with thousands of lines. Why websites prefer this way? Because of performance or any other benefits? Thanks.

    Edit: Thank you very much for all your valuable explanations.

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

    The "Build your own Redis" challenge

    Posted: 21 Jan 2021 07:39 AM PST

    Hi!

    A year ago, I launched the Build your own Redis challenge, a hands-on (i.e. fun) project to learn about how Redis works under the hood. Covers topics like event loops, TCP servers, the Redis protocol (v2, not v3) and more.

    The challenge is broken down into 7 stages, each building upon the previous one. Each stage includes instructions on what is to be done, and occasional hints depending on what programming language you're using. You submit code via a git push, and we run tests against your implementation to verify your work.

    The challenge is still in Early Access, but it has come a long way from the initial version. The instructions & hints have gotten better, and we support a wide variety of languages (started out with just Python & Go). ~150 people have attempted the challenge, and ~60 of them completed all stages. 9 programming languages supported at the moment, and support for more are on the way.

    If this sounds interesting to you, would love to have you try it out!

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

    Writing game engines in c++, recommendations

    Posted: 21 Jan 2021 03:40 PM PST

    Hey, i really wanted to learn to write game engines. I just started with OpenGL in visual studio and enjoy it. Do you think opengl is good or is there any lther, i think its called "perference" for c++ game engine designing? Ty for your help!

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

    I can't switch the Dr. Java compiler to JDK

    Posted: 21 Jan 2021 05:49 PM PST

    Hello guys, thanks for any help.

    I have to use Dr. Java for a programming class, and the compiler I'm supposed to use is the JDK. But I can't change it from the default Eclipse compiler to the JDK. Despite specifying the JDK folder as a path for Tools.jar location and Extra Classpath in Dr. Java's preferences -> Resource locations section, I still don't see the JDK as an option as a compiler in Compiler Options.

    Any help is appreciated.

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

    I want to learn how to code and want to learn what languages are best for what tasks

    Posted: 21 Jan 2021 05:44 PM PST

    I want to know what they best all around language is and what is best for certain tasks.

    submitted by /u/Fun-Dragonfly-153
    [link] [comments]

    Is there a good way to learn good software development practices for small personal projects?

    Posted: 21 Jan 2021 05:46 AM PST

    Things like ticket management and handling git branches, dev environments, deployment, but specifically for a small one-person project.

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

    Flappy Bird Game In Java ——Best project for beginners! ��

    Posted: 22 Jan 2021 12:54 AM PST

    My Flappy Bird game in Java is now open source on GitHub ! 😍It is completely based on Java basic class library.I think it is very friendly for Java beginners!You can learn from it and transform it into a game of your own !😎

    click it : GitHub

    Overview

    A Flappy Bird game based on Java basic class library

    • Bird flying
    • Clouds flutter
    • Random normal pipes generation
    • Random hover pipes generation
    • Random hover and moving pipes generation
    • Moderate difficulty control
    • Beautiful game graphics

    All projects use Java basic class library, based on Java 14, suitable for beginners to learn

    This project contains two separate source codes, which are English comments (src) and Chinese comments (zh/src)

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

    Time required for completing courses from W3S

    Posted: 22 Jan 2021 12:49 AM PST

    Hey y'all,

    How are you doing?

    I am starting HTML, CSS, JavaScript and SQL Courses from W3S. And I wanted to know from you folks about how much time it would take me to do each one of them. And can I rush through them?

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

    How can I tell if my code is "bad"?

    Posted: 22 Jan 2021 12:35 AM PST

    I recently heard that PHP is disliked by many people, and when I looked up why, what I heard was that PHP doesn't do much to stop poorly written code. I'm still not entirely sure what this means, and I was also confused by why people were trash talking w3schools at the same time.

    Long story short, would someone mind reviewing these 2 projects of mine? I want to be a web developer without a degree, but I fear how far I will get without understanding what is bad vs good.

    QnA Site

    Automatic zoom opener with GUI

    Also, is that really why languages like PHP and vanilla JS are hated on so much? Or is there another reason?

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

    Reliable sources for learning python

    Posted: 22 Jan 2021 12:25 AM PST

    So I'm in my last year of high school and we have an end of year project on a subject of our choice. I chose "learning python" and am in need of reliable sources that i can link as i need to put where and how i got my information from. By reliable i mean credible or popular websites or apps as i don't think youtube videos apply.

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

    How does one of these lists have list[i].length defined, and the other one doesn't have it defined when they are esentially the same code.

    Posted: 21 Jan 2021 06:17 PM PST

    This is the code where wordList[i].length works when running the application

    var wordList = getColumn("Words", "Word");

    var filteredWordList = [];

    filter(getNumber("lengthDropdown"), getText("letterDropdown").toLowerCase());

    onEvent("lengthDropdown", "change", function(){

    filter(getNumber("lengthDropdown"), getText("letterDropdown").toLowerCase());

    });

    onEvent("letterDropdown", "change", function(){

    filter(getNumber("lengthDropdown"), getText("letterDropdown").toLowerCase());

    });

    function filter(len, letter){

    filteredWordList = [];

    setText("output", "");

    for(var i=0; i<wordList.length; i++){

    if(wordList[i].length == len && wordList[i].substring(0,1)==letter){

    appendItem(filteredWordList, wordList[i]);

    }

    }

    if(filteredWordList.length == 0){

    appendItem(filteredWordList, "No Options Available");

    }

    hideElement("waitingImage");

    hideElement("unclickable");

    setText("output", filteredWordList.join(", "));

    }

    This is the code where animalList[i].length doesnt work, when they are the same pieces of code

    var animalList = getColumn("Animals List(1)", "Animal");

    var filteredAnimalList = [];

    filter(getNumber("dropdownLength"), getText("dropdownLetter").toLowerCase());

    onEvent("dropdownLength", "change", function(){

    filter(getNumber("dropdownLength"), getText("dropdownLetter").toLowerCase());

    });

    onEvent("dropdownLetter", "change", function(){

    filter(getNumber("dropdownLength"), getText("dropdownLetter").toLowerCase());

    });

    function filter(length,letter){

    filteredAnimalList = [];

    setText("animalsOutput", "");

    for(var i=0; i<animalList.length; i++){

    if(animalList[i].length == length && animalList[i].substring(0,1)==letter){

    appendItem(filteredAnimalList, animalList[i]);

    }

    }

    if(filteredAnimalList.length == 0){

    appendItem(filteredAnimalList, "No Options Available");

    }

    setText("animalsOutput", filteredAnimalList.join(", "));}

    Any clue on why and how to fix the second one?

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

    At what point can you start applying to software engineering/development jobs?

    Posted: 21 Jan 2021 02:29 PM PST

    What is the baseline/minimum required knowledge needed?

    If you know the basics of programming ie (int, bool, ..., if/else, for/while, functions, methods, array, lists, dictionaries, tuples, sets, file writing and reading, modules, ...etc), and you also know object oriented programming as well as data structure and algorithms.

    Are you far off reaching that baseline? What is next?

    Also I like to compare to a traditional CS curriculum. Anyone here got a CS degree and work as a software engineer? What was actually useful? Like which courses apart from what I mentioned above (basics of programming, OOP, data structures and algorithms).

    My understand from college degrees is that it's really theoretical and that it teaches you to do research, and that it actually teaches you computer science. But what you wanna learn is programming, not computer science, so a lot of the stuff in a CS degree is useless for having a job or something? I'm sure there's still a bunch of must take courses though? What is roughly the name of some useful college courses and what should they cover?

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

    How can I assign value to a string “char by char” after declaration in c?

    Posted: 22 Jan 2021 12:10 AM PST

    int main(void) { string original = "ABCdef"; string upper; string lower; for (int i = 0; i < 6; i++) { if (isupper(original[i]) > 0) { upper[i]= original[i] - 32; } else { upper[i] = original[i]; } } for (int i = 0; i < 6; i++) { if (islower(original[i]) > 0) { lower[i] = original[i] + 32; } else { lower[i] = original[i]; } } } 

    I made the mistake of asking this question on stackoverflow first, which is not the best place for less experienced coders...

    My goal here is to create 2 new strings, upper and lower, that are the uppercase and lowercase versions of original to be used later in my program. When I run the program as it is above the IDE tells me that I must assign upper and lower values before using them.

    I have tried assigning NULL to them both at initialisation, as the IDE suggests, but this resulted in an error. When that failed, I tried assigning original to both. This almost worked, but for some reason meant that all three variables were altered when I assigned upper and lower different values within the if functions. This is a problem, as I need to be able to use upper and lower separately later on. Finally, I tried assigning "ABCDEF" to them both, but of course ran into the issue of an "incompatible pointer to integer assigning to 'string'" error.

    How should I declare upper and lower in order for them to work as intended? Or should I be approaching this completely differently??

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

    [Python][Java-android] OpenCv's 'VideoCapture()' failing to read Pafy urls on my android frontend but works fine on my PC.

    Posted: 22 Jan 2021 12:08 AM PST

    I have a python script that uses OpenCv and Pafy to capture the contents of a youtube video for further processing e.g. object detection. The script is shown below:

    import cv2 import youtube_dl import requests import pafy def car_detection(car_vid_url, frame_gap): cars_xml_url = \ "https://github.com/Brokoth/TrafficAppData/blob/main/Vehicle%20and%20pedestrain%20detection/cars.xml?raw=true" cars_xml_file = requests.get(cars_xml_url).content with open('cars.xml', 'wb') as file: file.write(cars_xml_file) cars_classifier = cv2.CascadeClassifier( 'cars.xml') video = pafy.new(car_vid_url) best = video.getbest() play_url = best.url camera = cv2.VideoCapture(play_url) fps = camera.get(cv2.CAP_PROP_FPS) frame_count = int(camera.get(cv2.CAP_PROP_FRAME_COUNT)) duration = frame_count / fps print(frame_count, ',', fps, ',', duration) frame_number_counter = 0 traffic_density_values = [] while True: ret, img = camera.read() frame_number_counter = frame_number_counter + 1 if img is not None: if frame_number_counter == 1 or frame_number_counter % frame_gap == 0: height, width = img.shape[0:2] img[0:70, 0:width] = [0, 0, 255] cv2.putText(img, 'CAR COUNT:', (10, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 2) cv2.line(img, (0, height - 200), (width, height - 200), (0, 255, 255), 2) blur = cv2.blur(img, (3, 3)) gray = cv2.cvtColor(blur, cv2.COLOR_BGR2GRAY) cars = cars_classifier.detectMultiScale(gray) count = 0 for (x, y, w, h) in cars: count = count + 1 cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2) cv2.putText(img, 'CAR', (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) cv2.putText(img, str(count), (500, 50), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) traffic_density_values.append(count) cv2.imshow('live', img) key = cv2.waitKey(1) if key == 27: break else: break cv2.destroyAllWindows() camera.release() print(traffic_density_values) return traffic_density_values vid_url = \ 'https://www.youtube.com/watch?v=Y1jTEyb3wiI&list=PLxgQHbsjYVOhmhdGps5Fiw16Av3Ni1Kz0&index=22' car_detection(vid_url, 30) 

    This script works perfectly on my desktop where i have OpenCv 4.5.1.18 installed. This means the VideoCapture method works with no error and the rest of the code executes.

    To run this script on my android frontend, I am using Chaquopy. Chaquopy installs its own versions of libraries/packages that it is currently compatible with. This means that it is running OpenCv 4.1.2.30. I believe all other llibraries/packages are consistent version-wise. When I try to execute the python script from the android client, I get the following error:

    2021-01-22 10:46:03.390 15529-15690/Brian.Okoth.trafficapp E/cv::error(): OpenCV(4.1.2) Error: Bad argument (CAP_IMAGES: error, expected '0?[1-9][du]' pattern, got: https://r4---sn-n545gpjvh-ocvz.googlevideo.com/videoplayback?expire=1611323161&ei=uYIKYN-5EtCX1wbvrKDIDQ&ip=41.80.248.198&id=o-AKyJdfXatP-ANcRBkm0rCz1X6ZWyhMQ_5-3NJ2RflETB&itag=22&source=youtube&requiressl=yes&mh=hk&mm=31%2C29&mn=sn-n545gpjvh-ocvz%2Csn-n545gpjvh-hc5e&ms=au%2Crdu&mv=m&mvi=4&pl=19&initcwndbps=461250&vprv=1&mime=video%2Fmp4&ns=rN270fqejWJPdX8gp_L68RYF&ratebypass=yes&dur=10.193&lmt=1471794444030954&mt=1611301252&fvip=6&c=WEB&n=KI1ESyWsHu5UFYI&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRgIhAIS92gPuelvTtFSeRAen_go6OBM8F7zsvfYzrPR8pZJkAiEAgeN2WfyvdgNBYvve1bckk14dYOGNIQeR02Avkch3B8U%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAMZUVdTwNK0CrCn3x2WAjyr5aaLJX_Znq3S_8yd5WGlzAiEAtmo4Kpa-EeCTrDynCbCSJhfNU5pSTFFHIb8qYW_mJcA%3D) in icvExtractPattern, file /home/smith/git/chaquo/python/server/pypi/packages/opencv-pyt 

    It should be noted that the code

    vid_url = \ 'https://www.youtube.com/watch?v=Y1jTEyb3wiI&list=PLxgQHbsjYVOhmhdGps5Fiw16Av3Ni1Kz0&index=22' car_detection(vid_url, 30) 

    is commented out when i run it on the android client since i send user defined parameters from the client to the method. I have confirmed that the parameters are received and are the correct youtube links.

    After commenting out some code, i found that the error occurs at this line specifically:

    camera = cv2.VideoCapture(play_url) 

    I suspect my error is related to the OpenCv version difference but other than that, I have no idea. Any help would be appreciated.

    EDIT

    After some testing with other video sources, i realized that the error isn't limited to youtube links and pafy. Even with raw github links, the error persists.

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

    No comments:

    Post a Comment