*** mulbah has quit (Ping timeout: 480 seconds) | 01:36 | |
scooper | Good evening Shmohamud | 01:39 |
---|---|---|
mulbah07_ | Hello scooper | 01:40 |
scooper | Good morning mulbah | 01:40 |
scooper | Shmohamud | 01:40 |
scooper | you didn't give your feedback on the JS book I send you | 01:41 |
*** shmohamud has quit (Remote host closed the connection) | 01:43 | |
shmohamud | Hello scooper | 01:43 |
shmohamud | Hello mulbah | 01:43 |
shmohamud | Scooper I haven't had a chance to take a look but I promise to this weekend. | 01:44 |
mulbah | Hello shmohamud | 01:44 |
shmohamud | Mulbah do you want to join our Javascript session? We're starting from the fundamentals | 01:44 |
mulbah | everyday | 01:45 |
shmohamud | perfect | 01:45 |
shmohamud | Scooper, are you ready? | 01:45 |
scooper | +1 | 01:45 |
shmohamud | Mulbah, how much JS do you know? | 01:45 |
mulbah | none | 01:45 |
shmohamud | Ok, how much Python do you know? | 01:45 |
shmohamud | Scooper, do you know how to write a for loop in javascript? | 01:46 |
mulbah | well I can say some | 01:46 |
scooper | let me give it a try, before I do let me say something first | 01:46 |
shmohamud | Ok, can you write me a for loop in python that prints numbers 1 to 101? | 01:46 |
shmohamud | ^ mulbah | 01:47 |
shmohamud | +1 scooper | 01:47 |
mulbah | me | 01:47 |
shmohamud | yes, write can you write a for loop in python that prints numbers from 1 to 101? | 01:48 |
scooper | I m using the console to write my JS code and it can be frustrate because the console is just like the shell code I now save | 01:48 |
mulbah | yeah | 01:48 |
scooper | only it run so I might be a little bit smooth making sure to rewrite my code every time I make a mistake in the console.. | 01:49 |
shmohamud | what's wrong with the console scooper? | 01:49 |
shmohamud | I don't get the issue | 01:49 |
scooper | I mean | 01:50 |
shmohamud | Mulbah - please write it | 01:50 |
mulbah | for i in range (1, 102): | 01:50 |
mulbah | print(i) | 01:50 |
shmohamud | good job Mulbah. | 01:50 |
scooper | I m using the console to write my JS code. Since it's not an IDE I might be a little bit slow | 01:50 |
scooper | Because I m trying to make sure I get the rightful result before posting it here with you.... | 01:51 |
shmohamud | Can you write me a python function called reverse_string that reverses all the characters in a string. The signature should be reverse_string(str) and it should print the reversed string | 01:51 |
mulbah | Thanks shmohamud | 01:51 |
shmohamud | ^ mulbah | 01:51 |
mulbah | yeah | 01:51 |
shmohamud | Got it Scooper, take your time, code is not something to rush, it's better to be slow and careful. | 01:52 |
scooper | Are you ready now??? | 01:52 |
scooper | what the question was??? | 01:53 |
shmohamud | The console will be good practice because it forces you to learn the syntax without aid | 01:53 |
shmohamud | Scooper, I want you to write me a function declaration in JS. Call it helloWorld and have it print "Hello World" | 01:53 |
scooper | ok | 01:54 |
mulbah | shmohamud it's everyday your carry on this teaching | 01:54 |
shmohamud | I'm available everyday we just have to find a time that works for everyone | 01:55 |
mulbah | as for me I'm available anytime | 01:56 |
mulbah | so another question there for me | 01:56 |
shmohamud | Ok, during Saturday meeting lets make an agenda item to find a time that works for everyone who wants to learn JS | 01:56 |
mulbah | That will be more helpful for the web develop team | 01:58 |
shmohamud | definitely | 02:01 |
scooper | function helloWorld(message);{ | 02:01 |
scooper | console.log("Hello World") | 02:01 |
scooper | } | 02:01 |
scooper | helloWorld(): | 02:01 |
scooper | this code is giving me error | 02:01 |
shmohamud | should there be a semicolon after the (message)? | 02:01 |
scooper | that is only thing my brain can produce right now | 02:01 |
shmohamud | you're very close | 02:01 |
scooper | hmmmm | 02:02 |
scooper | let me try again | 02:02 |
shmohamud | also, what is the error message saying? Can you write it here? | 02:02 |
scooper | function helloWorld(message){ | 02:04 |
scooper | console.log("Hello World") | 02:04 |
scooper | } | 02:04 |
scooper | helloWorld(); | 02:04 |
scooper | VM607:2 Hello World | 02:04 |
scooper | undefined | 02:04 |
scooper | thanks a run now | 02:04 |
shmohamud | any errors? | 02:04 |
scooper | no | 02:04 |
scooper | it run | 02:04 |
shmohamud | do you see something that should be removed from the function definition? | 02:04 |
scooper | no | 02:05 |
shmohamud | There's a golden rule in programming "no unused variables" | 02:05 |
scooper | but | 02:05 |
shmohamud | If you don't need a variable/parameter, don't declare it. Do you see any unused parameters in your function? | 02:05 |
scooper | "message" | 02:06 |
scooper | will my function still run if I remove message?? | 02:06 |
shmohamud | well, are you using message anywhere in the function? | 02:06 |
scooper | from my python point of view, I m using message as a parameter | 02:07 |
shmohamud | but are you using it anywhere in the function? | 02:08 |
scooper | that why I had "message" after the function was defind | 02:08 |
scooper | yes | 02:08 |
shmohamud | Where are you using message in the function? | 02:08 |
scooper | I m using message as an alien for "Hello World" | 02:09 |
shmohamud | What line are you actually using it though? | 02:09 |
shmohamud | ...... | 02:09 |
scooper | console.log(here) | 02:10 |
scooper | in the parenthesis | 02:10 |
shmohamud | But you wrote "Hello World" you don't put "message" in there... | 02:10 |
scooper | Shmohamud | 02:10 |
shmohamud | console.log(message) is different from console.log("Hello World") - do you see that? | 02:10 |
scooper | I mean message is serving as a parameter why "Hello World" which is a string is serving as an argument | 02:11 |
scooper | just like python, when you declare a function with a paremeter you need to put in an argument when it being call | 02:12 |
scooper | that is the logic I was using here too | 02:12 |
shmohamud | So here's the thing | 02:14 |
shmohamud | you're correct, message is a parameter | 02:15 |
shmohamud | when you call the function, did you call it with "Hello World" as the message or did you call it with no arguments? | 02:15 |
scooper | I called the function by it name which happen to be "helloWorld" | 02:17 |
shmohamud | ok, but helloWorld("Hello World") is different from helloWorld() right? One of them isn't called with any argument. Do you see that? | 02:17 |
scooper | Ok I understand what you mean now | 02:18 |
shmohamud | Explain what I mean in your own words | 02:18 |
scooper | you are to say I didn't put the value of "hellWorld(); in the parenthesis when I call the function right?? | 02:19 |
scooper | you are trying to say | 02:20 |
shmohamud | yes, and do you see why message is not needed? | 02:20 |
scooper | yes | 02:20 |
shmohamud | why not? | 02:20 |
scooper | because the func didn't have an argument when it was call | 02:21 |
shmohamud | yes, that's one way to understand it. | 02:23 |
shmohamud | But even simpler: we're not using message so we don't need to have it as a parameter/argument | 02:24 |
shmohamud | In programming, you want to only declare parameters if you _use_ them | 02:24 |
shmohamud | So, can you remove message parameter and run it and let me know if it breaks? | 02:25 |
scooper | ok | 02:25 |
shmohamud | mulbah you there? | 02:26 |
scooper | function helloWorld(){ | 02:27 |
scooper | console.log("Hello World") | 02:27 |
scooper | } | 02:27 |
scooper | helloWorld(); | 02:27 |
scooper | VM349:2 Hello World | 02:27 |
scooper | undefined | 02:27 |
shmohamud | Scooper I've got to go | 02:29 |
scooper | OK thanks | 02:29 |
shmohamud | For homework, write me a JS function that uses a parameter (message) and prints _that_ message out instead of hard coding "Hello World | 02:29 |
scooper | it' was wonderful learning with you today | 02:30 |
shmohamud | Talk to you soon. | 02:30 |
shmohamud | Wonderful learning with you too :D | 02:30 |
scooper | ok.. | 02:30 |
scooper | ACTION signing out for now | 02:31 |
mulbah | yeah | 02:32 |
mulbah | I'm here | 02:32 |
*** scooper has quit (Quit: Leaving) | 02:33 | |
mulbah | shmohamud I'm here | 02:34 |
*** shmohamud has quit (Remote host closed the connection) | 02:35 | |
*** mulbah has quit (Ping timeout: 480 seconds) | 02:49 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 03:05 | |
*** shmohamud has quit (Remote host closed the connection) | 04:40 | |
superoo_-_ | https://www.youtube.com/watch?v=sqSA-SY5Hro | 06:03 |
superoo_-_ | These rich men north of Richmond | 06:03 |
superoo_-_ | Lord knows they all just wanna have total control | 06:03 |
superoo_-_ | Wanna know what you think, wanna know what you do | 06:03 |
superoo_-_ | And they don’t think you know, but I know that you do | 06:03 |
superoo_-_ | ‘Cause your dollar ain’t shit and it’s taxed to no end | 06:03 |
superoo_-_ | ‘Cause of rich men north of Richmond | 06:03 |
superoo_-_ | irc.supernets.org #superbowl | 06:03 |
superoo_-_ | superoo_-_ LittleWebster | 06:03 |
*** superoo_-_ has left #novawebdev (Glined: User has been banned from the network.) | 06:03 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 06:49 | |
Gap | Hello jeff | 09:55 |
Gap | sorry for the i didn't been around for like month, it's was because i have lot to study. It was because since we started C programming for the past three month i full with stress malloc and pointer, other project but hopefully next month i'll focus to finish everything in the gasp sheet, please | 10:00 |
*** tboimah has quit (Quit: Leaving) | 10:41 | |
*** fkoikoi has quit (Ping timeout: 480 seconds) | 10:54 | |
*** shmohamud has quit (Ping timeout: 480 seconds) | 11:50 | |
mulbah | Good morning Mr. Cole | 13:06 |
ubuntourist | hi mulbah | 13:06 |
ubuntourist | How are you feeling? | 13:06 |
mulbah | Good now and you | 13:07 |
ubuntourist | I got a vaccine and... an infection from the vaccine. (I have been getting shots regularly all of my life without any ill effects, but now twice I have contracted cellulitis. | 13:08 |
ubuntourist | So, at 10:00 my time, I need to take a very short break to swallow my antibiotics.) | 13:09 |
mulbah | I'm sorry for that Mr. Cole | 13:09 |
mulbah | Alright | 13:09 |
ubuntourist | But, it seems to be clearing up quickly. | 13:09 |
ubuntourist | Anyway, have you been reading the IRC logs to see what we've been up to? | 13:10 |
ubuntourist | Also, has tboimah been sharing the e-mails about presenting for Jeff's class? | 13:11 |
mulbah | Jeff said that will not be necessary we can continue with our study | 13:12 |
ubuntourist | jelkner gives me mxed messages... OK, never mind then. (He had been interested in both "tmate" and "script" / "scriptreplay" I thought.) | 13:14 |
mulbah | https://irclogs.novawebdevelopment.org/%23novawebdev/2023-10-03.log.html | 13:14 |
ubuntourist | Thanks. | 13:14 |
ubuntourist | So. A few sessions ago, I typed a short Bash program for tboimah, but I accidentally made a mistake. | 13:15 |
ubuntourist | Instead of fixing it, I worked with tboimah to get him to find and fix the problem himself. | 13:16 |
ubuntourist | Are you caught up with that and did you understand the mistake and the correction? | 13:16 |
ubuntourist | (If not, it's a very short bit of code and we can do it together..) | 13:16 |
mulbah | no | 13:17 |
ubuntourist | OK, liet's redo it. | 13:17 |
mulbah | sure | 13:18 |
ubuntourist | ssh 74Er6XBZDrhMMHHenAFHkLuVv@lon1.tmate.io | 13:18 |
ubuntourist | One thing I did not mention to tboimah but you can share it with him: | 13:20 |
ubuntourist | We talked about "permissions" and making a program "executable" with setting the "x" permission, you remember. | 13:20 |
mulbah | yeah | 13:21 |
mulbah | I remember | 13:21 |
ubuntourist | When the "x" is set, the filename is displayed in green. (That's not universal, but we've been talking about ~/.profile | 13:22 |
ubuntourist | ns ~/.bashrc and how there are standard default templates in /etc/skel for new users. | 13:22 |
ubuntourist | Somewhere in those files are the instructions that say "print executable filenames in green when the ls command is used.) | 13:23 |
ubuntourist | Anway, "oops" is a short Bash program. But it does not contain the special "shebang" comment at the top | 13:23 |
ubuntourist | that would let the operating system know "Oh! It is for Bash to read, not Python, or some other interpreter". | 13:24 |
ubuntourist | Also, the execution bit -- the "x" -- is not set. | 13:24 |
ubuntourist | But, like Python, we can put a command before the filename in order to run it even without the "shebang" or the executable "x" set. | 13:25 |
ubuntourist | The command "source" means "Interpret the following argument as a Bash program". And there is an alias for "source". It is simply a period. | 13:27 |
ubuntourist | (I could have typed ". oops" or "source oops" or | 13:28 |
ubuntourist | I could have changed the permission to add "x" and inserted a line at the top of the file "#!/bin/bash" and then to run, type "oops" without period or "source") | 13:29 |
ubuntourist | OK. | 13:29 |
ubuntourist | Onward. Just looking at the screen without touching your keyboard, can you see what's wrong? (You do not need to | 13:30 |
Gap | hi can you please tell me what sort of project you guys working on, i have been away for a while | 13:30 |
ubuntourist | scroll or type anything. All the information you need is on the screen.) | 13:30 |
ubuntourist | Gap, this is a separate group: This is just me, tboimah and mulbah. | 13:31 |
ubuntourist | Gap, we'te not working on any projects. We're studying systems administration. | 13:32 |
Gap | oh i though it's was for the python people | 13:32 |
Gap | sorry for the inconvienene | 13:33 |
ubuntourist | mulbah, it's not the same as a python script but it is quite similar, and you should be able to see parallels | 13:33 |
ubuntourist | that may help you identify the problem. | 13:34 |
tboimah | Hello Guys sorry i am late | 13:34 |
ubuntourist | tboimah, hi. My medication is workiing and I'm feeling better than monday. | 13:34 |
tboimah | wow! that good to hear | 13:35 |
ubuntourist | tboimah, We're reviewing "oops" -- the mistake you fixed with my mistake last time. | 13:35 |
tboimah | Ahhh okay | 13:35 |
ubuntourist | I am waiting for mulbah to study and respond. | 13:35 |
Gap | @tboimah what's new can you please give me update regardless of my absent for a while | 13:36 |
tboimah | No bad news bro | 13:36 |
tboimah | But you can massage me privately because ubuntourist, mulbah and I are having class here. | 13:37 |
ubuntourist | We're on the server, but please don't type anything into the screen or resize the screen. I want to keep | 13:37 |
Gap | the sever your opened for me have not been going through, i try sorting the link on crome but haven't connecting to the site | 13:38 |
ubuntourist | what is present displaying as is and resizing messes with it.. | 13:38 |
Gap | @https://git.mcssliberia.org | 13:38 |
Gap | is this link wrong or what | 13:38 |
ubuntourist | ACTION is waiting for mulbah to say something... | 13:40 |
mulbah | Mr. Cole I'm not understanding the error | 13:40 |
ubuntourist | OK. So let's take it one line at a time. Can you explain the parts of the first line? Think about it the same way you would think about | 13:41 |
ubuntourist | Python's equivalent line. | 13:41 |
mulbah | okay | 13:43 |
ubuntourist | (We're looking at the five lines that I showed with "cat oops". "oops" is the 5-line Bash program. So the first line of that is what we're looking at.) | 13:43 |
mulbah | "filename" is an interable in python | 13:45 |
mulbah | so its say | 13:45 |
ubuntourist | Good. It is an iterable in Bash too. | 13:46 |
mulbah | make filename refare to everything in * | 13:46 |
mulbah | "refer" | 13:47 |
ubuntourist | Actually, let me correct that: "filename" isn't the iterable in either. But the "for" loop "iterates" over an iterable. | 13:47 |
ubuntourist | The "*" is the iterable here. But your analysis is correct so far. | 13:47 |
ubuntourist | In Bash, indentation doesn't matter. So for the "block" of the Bash "for" loop, you need to surround it with "do" and "done" | 13:48 |
ubuntourist | (I did not need to indent my code, it is just more readable that way.) | 13:49 |
ubuntourist | So, you've got a "for" that is iterating over all files (with the "*" wildcard). What next? | 13:49 |
ubuntourist | (You can skip the "do" and "done" because I've just explained that they are only there to mark the start and end of the block.) | 13:51 |
mulbah | print "The next line will print a filename" | 13:52 |
mulbah | That is in python | 13:52 |
mulbah | but for bash | 13:52 |
mulbah | you say echo | 13:53 |
ubuntourist | Yep. (In Python you'd change the "echo" to "print" and use "(...)". Exactly right.) | 13:53 |
ubuntourist | Next line.... | 13:53 |
mulbah | it says | 13:53 |
mulbah | $ means end of line right? | 13:55 |
mulbah | i this it should have been: "echo i$ | 13:56 |
*** Gap has quit (Ping timeout: 480 seconds) | 13:56 | |
ubuntourist | Unfortunately, this is why there is so much to remember that you need great notes for yourself. "$" means end of line when | 13:56 |
ubuntourist | we are working wiht regular expressions. Here, we are not, and "$" means something else... | 13:56 |
ubuntourist | ACTION takes a very short break to swallow pills... | 13:57 |
ubuntourist | ACTION is back | 13:59 |
mulbah | To be real i don't know it mean here | 13:59 |
mulbah | the $ | 14:00 |
ubuntourist | Go way back to when we were playing around with "export ..." | 14:00 |
ubuntourist | (and "printenv") | 14:01 |
ubuntourist | Remember that there was another way to say "~" or "/home/mulbah/" ... | 14:01 |
ubuntourist | (Also remember that "oops" is BROKEN. We're trying to fix a mistake that I accidentally made.) | 14:03 |
mulbah | oh I think the $ refer to the home directory | 14:04 |
ubuntourist | mulbah, not by itself... but you're going in the right direction. | 14:04 |
ubuntourist | OK. Stop a minute, and tell me what you think the output of my program SHOULD be. | 14:05 |
ubuntourist | Don't think about how to fix it, think about what is displayed when I run it, and why it is not doing what it says it will do. | 14:05 |
ubuntourist | What is missing from the output? | 14:06 |
mulbah | It will print "The next line will print a filename" and the home directory | 14:06 |
ubuntourist | I'm going to type a new one.... Watch. | 14:07 |
ubuntourist | What went wrong? | 14:08 |
mulbah | echo print the line four times | 14:09 |
mulbah | because of 1, 2, 3, 4 | 14:09 |
ubuntourist | But it said it was going to print a number... It did not print any numbers.... Why not? | 14:10 |
ubuntourist | What is wrong with the python code on the screen? | 14:11 |
mulbah | because you didn't echo something | 14:12 |
mulbah | or print something | 14:12 |
ubuntourist | What is wrong with the Bash code on the screen? | 14:12 |
tboimah | ubuntourist should i answer the question so that we can move on | 14:13 |
ubuntourist | tboimah, I'd prefer you did not. | 14:13 |
mulbah | echo filename | 14:13 |
ubuntourist | mulbah, close, but missing one character. | 14:14 |
tboimah | Okay i am waiting | 14:14 |
mulbah | echo "filename" | 14:14 |
ubuntourist | mulbah, Nope. That will just print the word "filename". | 14:14 |
ubuntourist | tboimah, (I have had to repeat things for you in the past. It is better for each person to come to their own understanding, so that it will be retained.) | 14:15 |
tboimah | sure | 14:15 |
mulbah | for filename in * | 14:16 |
mulbah | do | 14:16 |
mulbah | echo "filename" | 14:16 |
mulbah | echo $i | 14:16 |
mulbah | done | 14:16 |
ubuntourist | Why did the code I just ran not print any numbers? | 14:17 |
mulbah | because you didn't tell it to print something | 14:18 |
mulbah | or echo "something" | 14:19 |
ubuntourist | In Bash, we need a special way to refer to variables that we use, after we define them... | 14:20 |
ubuntourist | OK, tboimah go ahead. | 14:20 |
tboimah | okay the code is not print number because echo $i is undefine | 14:21 |
mulbah | echo $filename | 14:21 |
ubuntourist | mulbah, you got there. | 14:21 |
tboimah | it should have been echo $ something | 14:22 |
ubuntourist | BINGO | 14:22 |
tboimah | instead of echo $i | 14:22 |
ubuntourist | In Bash you can create environment variables a few different ways, similar to Python. | 14:23 |
mulbah | I remember when you said that there is special way to refer to variables | 14:23 |
ubuntourist | (Except that sometimes you cannot use spaces.) | 14:23 |
*** shmohamud has quit (Remote host closed the connection) | 14:23 | |
ubuntourist | So "for blablabla in ..." creates a vaariable named blablablah but to use it, you need the $ prefix. | 14:24 |
ubuntourist | So, I know tboimah was pastiently sitting while we were eating up time, but we're going to rush on to that script and README that I made. | 14:25 |
tboimah | okay | 14:25 |
ubuntourist | We have this ugly bit of code... | 14:26 |
ubuntourist | for filename in $(locate ly | \ | 14:26 |
ubuntourist | grep "\.ly$" | \ | 14:26 |
ubuntourist | grep kjcole | \ | 14:26 |
ubuntourist | egrep -v "(/\.|FrayedKnotArts|engraving|rosegarden|_lilypond|sphinx-notes|\ | 14:26 |
ubuntourist | 2.24.2)"); | 14:26 |
ubuntourist | at the start of the thing we left off woring on. | 14:27 |
ubuntourist | Quick review: I was searching for all of the files that ended with the file extension ".ly" | 14:27 |
ubuntourist | Well, but I only wanted files owned by me. | 14:28 |
ubuntourist | And I only wanted files that I created myself, not files that I downloaded from | 14:28 |
ubuntourist | somewhere else. So, there were directories to eliminate. | 14:28 |
ubuntourist | We constructed an elaborite set of filters: | 14:29 |
ubuntourist | locate ly | grep "\.ly$" | 14:29 |
ubuntourist | creates a quick list of files with "ly" anywhere in the name -- like "plymoth" but then filters that list | 14:30 |
ubuntourist | for anything that ends with ".ly" | 14:30 |
ubuntourist | then we added a filter to only find lines with ly ending with .ly that also had "kjcole" somewhere in them. | 14:31 |
ubuntourist | then we filtered out a bunch of files using the fancier "egrep". The "-v" eliminates matches. | 14:32 |
ubuntourist | So DON'T match any lines that have "/." -- hidden directories, or "FrayedKnotArts" or "engraving" or "rosegarden" or ... etc, etc. | 14:33 |
ubuntourist | Now... here's where it gets interesting: | 14:34 |
ubuntourist | We've created an iterable... Its's a big long list of files, one filename per line. | 14:34 |
ubuntourist | The power of the the Bash $ -- wihich is different from the regular expression $ -- comes in. | 14:35 |
ubuntourist | This is IMORTANT! | 14:35 |
ubuntourist | We can wrap a command, or a set of commands inside of $( ... ) and the results become an iterable list !!! | 14:36 |
ubuntourist | WRITE THAT DOWN somewhere! It's what we have been working up to very slowly. | 14:36 |
ubuntourist | ACTION needs a quick bathroom break. Think about what I just wrote and either ask questions or explain it back to me in your own words. | 14:38 |
ubuntourist | but write done wihen finished so you don't type over each other.. | 14:38 |
ubuntourist | ACTION is back again. | 14:41 |
ubuntourist | ACTION waits for thoughts, questions, etc. but will say a little bit more | 14:43 |
mulbah | well no question | 14:44 |
ubuntourist | Think of piped commands as people working together, like in a game, or farming, or building something together.. | 14:44 |
ubuntourist | each person does part of a task and hands the "product" to the next person to do the next task. | 14:45 |
ubuntourist | So we have "locate" which quickly searches a database (that must be periodically updated with "sudo updatedb") full of filenames. | 14:45 |
ubuntourist | It produces a list, which is handed off to grep, which shortens the list, and to grep again and again each time narrowing the list. | 14:46 |
ubuntourist | Together $(locate ... | grep ... | grep ... | egrep ...) is the whole "product". Each player did their own part. | 14:47 |
ubuntourist | (And we're not limited to locate and grep. Any program that produces output in a format that can be used as input by some other | 14:48 |
ubuntourist | program can be used in this way.) | 14:48 |
ubuntourist | Now its: | 14:48 |
ubuntourist | for variable in $(locate ... | grep ... | grep ... | egrep ...) | 14:49 |
ubuntourist | So, we can take each file name from the filtered list and act on it. | 14:49 |
ubuntourist | We could ... rename each file in the list, or delete each file in the list, or open them one by one in nano, so that we could | 14:50 |
ubuntourist | edit them by hand. | 14:50 |
ubuntourist | Suppose you had a group of students, they each created a report in a file. The teacher has told all of the students | 14:52 |
ubuntourist | that they can choose whatever filename they want, but it must end with ".txt" And maybe the file name should include the date. | 14:52 |
ubuntourist | So, /home/tboimah/readme-2023-10-06.txt and /home/mulbah/homework-2022-05-27.txt and /home/tboimah/x-2021-12-15-hello.txt | 14:54 |
ubuntourist | all match. | 14:54 |
ubuntourist | And there are 30 more files or 100 more files like that. | 14:55 |
ubuntourist | Now, you want to read them, one by one. You could create a complex filter and a for loop, | 14:55 |
ubuntourist | and run each one through "most" | 14:55 |
ubuntourist | each would open and you could read. When you type "Q" to quit "most", the next file from the iterable list would | 14:56 |
ubuntourist | be selected and opened. | 14:56 |
ubuntourist | This is an invredibly important concept for systems administrators (and others). | 14:57 |
ubuntourist | HOMEWORK: Contiinue with your readings. (I mentioned on Monday that I think we're somewhere around chapters 11 and 13, | 14:57 |
ubuntourist | but I am skipping the chapter on the "vi" editor. because I prefer other editors. You should read that on your own and ask Jeff | 14:59 |
ubuntourist | questions about "vi" beccause it is his favorite editor. | 14:59 |
ubuntourist | OTHER HOMEWORK: Try creating small Bash scripts with $( ... | ... | ... ) iterables in a "for" loop, | 15:00 |
tboimah | okay | 15:00 |
*** tboimah has quit (Quit: Leaving) | 15:00 | |
ubuntourist | Your book should be moving that direction. You may need to skip ahead in the book to get to it. | 15:00 |
ubuntourist | But the book has much of this in it. | 15:01 |
ubuntourist | Bye for now! | 15:01 |
mulbah | okay | 15:02 |
mulbah | Thanks for the teaching today | 15:02 |
mulbah | get well soon | 15:02 |
*** ubuntourist has quit (Quit: Leaving) | 15:03 | |
*** mulbah has quit (Ping timeout: 480 seconds) | 15:50 | |
*** shmohamud has quit (Remote host closed the connection) | 19:43 | |
scooper | Hello Shmohamud | 19:55 |
shmohamud | Hi Scooper | 19:56 |
shmohamud | are you ready for today's lesson? | 19:56 |
scooper | yes | 19:56 |
scooper | before we begin | 19:57 |
shmohamud | Let's start with some review. Write me a function declaration helloWorld that prints out "Hello World" | 19:57 |
scooper | can we set a fix time on meeting here | 19:57 |
shmohamud | yes, Monday through Friday at 8:30PM works for me | 19:57 |
scooper | ok | 19:57 |
shmohamud | Today I finished work early so I could log on | 19:58 |
shmohamud | usually I will not finish work early | 19:58 |
scooper | function helloWord(){ | 20:00 |
scooper | console.log("Hello World") | 20:00 |
scooper | } | 20:00 |
scooper | helloWorld(); | 20:00 |
shmohamud | Beautiful | 20:01 |
shmohamud | Why didn't you add the message parameter like last time? | 20:01 |
scooper | because you said | 20:02 |
scooper | every variable that is use in a most have a role | 20:02 |
shmohamud | Yes, exactly. We weren't using the message parameter so it is bad practice to include it in the function | 20:03 |
shmohamud | Now, can you rewrite the function to accept a name parameter, and print "Hello {name}"? | 20:03 |
scooper | let me give a shot | 20:04 |
scooper | function person(name){ | 20:06 |
scooper | console.log("Welcome " + name) | 20:06 |
scooper | } | 20:06 |
scooper | person("Shmohamud") | 20:06 |
shmohamud | close | 20:06 |
shmohamud | I asked you to rewrite the function with the same name. So keep helloWorld(name) | 20:07 |
scooper | ok | 20:07 |
shmohamud | And I also asked the console to log "Hello " + name" | 20:07 |
shmohamud | with programming, you must read requirements carefully. Much of the solution to a problem comes from deeply understanding the problem to begin with | 20:08 |
shmohamud | that's why I'm being hard on you now, so you build the right habits as a professional programmer | 20:09 |
scooper | unction helloWorld(name){ | 20:09 |
scooper | console.log("Hello " + name) | 20:09 |
scooper | } | 20:09 |
scooper | helloWord("Shmohamud"); | 20:09 |
shmohamud | Perfect | 20:09 |
shmohamud | Ok, so now we know about function declarations and we learned to never include unused variables in a function definition | 20:10 |
shmohamud | There are two other ways to define functions in javascript | 20:10 |
shmohamud | const helloWorld = () => console.log("Hello World") | 20:11 |
shmohamud | that's called an arrow function | 20:11 |
scooper | arrow funcntion | 20:11 |
shmohamud | yes | 20:11 |
shmohamud | the above is also called an arrow function expression | 20:13 |
shmohamud | because we declare the function name and set it equal to the function itself. Does that make sense? | 20:13 |
scooper | yes but question | 20:14 |
shmohamud | yes | 20:14 |
scooper | As for variable declaration in js we have let, var const and it have it difference between. is the a difference between the three function definition?? | 20:15 |
shmohamud | Great question! | 20:16 |
shmohamud | Yes, there's a difference | 20:16 |
shmohamud | But it's a bit complicated. | 20:16 |
scooper | ok | 20:16 |
shmohamud | Arrow functions do not "hoist" which means anywhere in the program (even before declaring it) you can call that function | 20:17 |
shmohamud | Function declarations are "hoisted" which means you can use them before or after they're declared. | 20:17 |
shmohamud | Remember usually programs are just a series of steps and the code is read from top to bottom of the script | 20:17 |
shmohamud | There are other differences but even I have to review to remember them. What's important for now, though, is to understand the syntax and be able to declare both types of functions | 20:18 |
scooper | ok | 20:18 |
shmohamud | Ok, can you write me an arrow function that takes two parameters(a, b) and adds them and then prints the result to the console? | 20:19 |
scooper | let me try | 20:20 |
shmohamud | use this syntax: () => { */do something /*} | 20:20 |
shmohamud | the curly brackets are required for arrow functions if you want to have multiple statements inside | 20:20 |
shmohamud | the function body | 20:20 |
sysadmin_ | I m receiving syntax error | 20:27 |
shmohamud | ok, can you write the error here so we can resolve it? | 20:27 |
shmohamud | It's important you learn how to read error messages properly, so we'll start going through error messages together. | 20:28 |
shmohamud | Syntax error means something about the code isn't following JS syntax, but it should have "unexpected token :" or something like that | 20:28 |
sysadmin_ | Uncaught SyntaxError: redeclaration of var helloWorld | 20:28 |
sysadmin_ | <anonymous> debugger eval code:1 | 20:28 |
sysadmin_ | please wait | 20:29 |
shmohamud | redeclaration is a new error for me | 20:29 |
shmohamud | Ok, take your time | 20:29 |
sysadmin_ | let figure | 20:29 |
*** scooper has quit (Ping timeout: 480 seconds) | 20:32 | |
sysadmin_ | Uncaught SyntaxError: redeclaration of var helloWorld | 20:34 |
shmohamud | can you share the code here? | 20:35 |
scooper | const helloWorld = (a,b) =>{ | 20:36 |
scooper | consolo.log(a,b) | 20:36 |
scooper | } | 20:36 |
scooper | helloWord(8+3); | 20:36 |
shmohamud | the function is correct except when you call it and when you log it | 20:37 |
shmohamud | I asked you to add them together inside the function, not to pass 11 (8+3) to the function | 20:37 |
shmohamud | Can you rewrite the function and make sure to pass two arguments to it (a, b)? | 20:38 |
shmohamud | also can you change the name from helloWorld to something related to what we're doing inside the function? | 20:38 |
scooper | ok | 20:38 |
scooper | I can for now | 20:41 |
scooper | I have but still I m unable to solve that challenge | 20:41 |
shmohamud | what challenge? | 20:42 |
scooper | the instruction you give me | 20:42 |
shmohamud | Ok, would you like me to walk you through it? | 20:42 |
scooper | yes | 20:42 |
shmohamud | Ok, so I asked you to write a function that takes in two parameters (a, b) and console.log the sum (a + b) | 20:43 |
shmohamud | I'll call it addTwoNumbers = (a, b) => { console.log(a + b) } | 20:43 |
shmohamud | can you try that and call it with two numbers and let me know if it works | 20:43 |
scooper | it run but I got NaN | 20:45 |
scooper | const addTwoNumbers = (a,b) =>{ | 20:46 |
scooper | console.log(a + b) | 20:46 |
scooper | } | 20:46 |
scooper | addTwoNumbers(4 + 2); | 20:46 |
shmohamud | How many parameters do we declare in the function? | 20:46 |
scooper | TWO | 20:46 |
shmohamud | How many are you calling it with? | 20:46 |
scooper | Two 4 & 2 | 20:47 |
shmohamud | Are you sure you're calling it with two? | 20:47 |
scooper | yes | 20:47 |
shmohamud | In fact you're calling it with one argument because (4 + 2) will become (6) | 20:48 |
shmohamud | So you get NaN because you're adding 6 + undefined | 20:48 |
shmohamud | does that make sense? | 20:48 |
scooper | hmmmm | 20:48 |
scooper | sound strange... | 20:48 |
shmohamud | this is important. Do you see what I mean by you're actually only passing one argument, because 4+2 becomes 6 | 20:49 |
shmohamud | ? | 20:49 |
scooper | Shmohamud | 20:50 |
scooper | I m sorry to say this timing is not really working for me.... I usually done still up till 8pm due to that I m feeling sleepy...... | 20:51 |
shmohamud | That's fine, when is a better time for you? | 20:51 |
scooper | I appreciate the effort here but can we adjust the time please..... | 20:51 |
shmohamud | yes we can adjust the time | 20:52 |
scooper | can we take 4-5pm my time??? or 3:00 am my time?? | 20:52 |
shmohamud | I'm working 4-5pm your time but I can probably do 30m sessions during work | 20:53 |
shmohamud | You mean 12-1pm EST time (my time) right? | 20:54 |
scooper | yes | 20:54 |
shmohamud | i can meet you during that time during the week | 20:54 |
scooper | I m appealing because my body have gotten use to early sleep | 20:55 |
scooper | and waking up early | 20:55 |
shmohamud | that's understandable, I don't want to throw off your routine | 20:55 |
shmohamud | Let's plan on meeting 12-1pm Monday through Friday. Just message me on WhatsApp if you can't make it | 20:55 |
scooper | Ok thanks for understanding | 20:56 |
shmohamud | of couse | 20:56 |
shmohamud | of course * | 20:56 |
scooper | Mean while I wil read on Arrow function and come back with a better performance next time | 20:56 |
scooper | did you see the book now??? | 20:56 |
shmohamud | That sounds good. I haven't seen the book yet | 20:56 |
scooper | it three minutes to 9:00pm on my side | 20:57 |
scooper | can I go to bed now | 20:57 |
shmohamud | Yes, sleep well and we'll continue on arrow functions Monday | 20:58 |
scooper | OK thanks | 20:58 |
scooper | ACTION signing out | 20:58 |
*** scooper has quit (Quit: Leaving) | 20:58 | |
*** shmohamud has quit (None) | 20:58 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!