I amnotpartoftodaywithmymycommuted, whichisrarebecauseoftenstartlikemuted.
Andittakesmeaboutfiveminutestorealisethat.
Andthenthe 1st 5 minutesofsilence.
Buttoday I'm actuallyspeakingtoyou.
It's Friday.
I amlookingforwardtothisweekend.
Um, yeah, there's nodoubtaboutthat.
Butthat's notwhatyou'reherefor.
It's been a longweek.
Retire.
Therewasalready a livestreamtodaywithguestsandfeelinsane, which I will.
Youmentioned.
I mean, imaginingitnow, but I'm backtocontinuethethreadsoflastweekearlierthisMonday.
Let's see.
Sorry.
LetmegettheShattchickengoinghere.
Allright, soHi.
Who's literallyreadyyet?
Soletmeopenup a Webbrowser.
I'm completelyunpreparedforthisinas I alwaysam.
Like, I can't evengetmyWebbrowsertoopen.
Thisishowunprepared I am.
Soif I liveinlowlater, I don't wanttotrysafari.
Thankyou.
Um, if I gotothisYouTubechannelcalledtheCodingTrain.
There's anupcominglivestreamandonerightnow.
That's interesting, butthisiswhat I wantedtoreferto.
Sothismorningthislivestreamhappenedthismorning, whichwasAh, Lifestream, sponsoredbySpell, whichis a cloudcomputingservice, andguestNabeelHussaintrained A L S T M neuralnetwork, whichis a kindofneuralnetworkthat's wellsuitedforsequencestrainedmodelon a text.
Sotextfromanauthorthis, inthiscase a rapperwasusedsonglyricswereusedatthemodelwastrained.
Myguessistheeditedversionbelike 35 or 40 minutesorsomethinglikethatonRuiinthechatroom, weregamerwhowaswatchingme, myothergentlethat I willnotmentionthesecretlaptop.
Andwordsjustkeptcomingbecause I'm livestreamingand I feellikeif I'd stoptalkingwillbesilence.
Butwhatwouldbetheworstthingaboutsilence?
Allright, thatwasgoodlittlemoments.
Silencethere.
Haveyourefreshed?
Howdoyoufeel?
I'm tryingtodecideifthismakessensetobe a codingchallengelikemastodons.
Image, bahtprocessingimageboughtwiththings I loveaboutthisexamplethat I'm goingtodotodayisitbringssomanythingstogether, bringstogether a P eyesandnodeandjavascript a synchronous I'm gonnause a sinkand a weightwhichislikeyeseightjobscriptsintextandprocessingandcreatingimagesandshellscriptingAlsomanypiecestogetherintooneproject.
Theprojectthat I'm goingtobuildis a projectthatstartswith a processingsketch.
Let's see, ourrecentthisversionofprocessing I haveis, um, 3.4.
Itmakes a Thisismyonestartovermypoorguestswhocomeheretodo a guestvideo.
I don't letthemliketheydon't startoverlike 15 timeslikemeAsif I wasn't doingthislife.
Hello.
Inthisvideo I'm goingtomake a potand I'm goingtomakeitimage.
But I'm veryexcitedaboutthisprojectbecauseitpullstogether a wholelotofdifferentthings.
I amgoingtouseprocessinggeneratedimage.
I'm goingtousenodetoextocallprocessingtogeneratetheimagethatyouknowtotalktothe a p i andthe a p I.
It's massiton.
Soonethingyoumightwanttodois I'llreferyoutoallofmy a tutorial.
Siri's aboutthebasicsofmaking a massiveon, but I willstartlargelyfromscratchhere.
But I amgoing.
I'vealreadygotmy A p I keysand I alreadyhaveimportedandinstalledthisnodepackagecalledMastertondot a p I andthisdotenvypackagethatthatloadsmy a p I keysforme.
Sothatisstuffthat I'vedoneinanothervideo.
Ifyouwanttoseethat a linktothatinthevideodescription.
But I'm justgonnagetstarted.
Sowhatisthefirstthingthat I wantto D'ohOkay, let's gotoSothisismyinspirationTreebought, madebyAlexDubocfornationalboughtmakingmonth.
Umand I amgoingthiotrytorecreatethis.
Treeswon't benearlyasnice.
Sothefirstthing I wannadois I wanttouseprocessing.
I don't haveto.
I couldfindsomenotepackagethatdoesdrawingorgeneratesanimagespgwhatever.
But I loveprocessing.
It's myhappyplace.
And I'm prettysure I couldgetprostitutegeneratedtree.
I don't evenhaveto, like, writethecodeforthisbecause I havebefore I'm justgonnagoTwoexamples, right?
Isn't itinheresomewhere.
Topicssimulate.
No, no, no.
Okay, I'llbebackin a second.
I cameback.
I founditunderfractalsand L Systemstree.
Well, look.
RecursivetreebyDanielSheafMonThisismyThisis a recursivetree, andas I movethemouse, itchangestheangle.
Solet's alterthiscode a littlebit.
Let's saythatwedon't careabout a framerateandlet's notlet's havetheangleberandombetweenzeroandtwopi.
Butwhat I'm goingtodois I'm goingtopromiseif I whichis a word, apparentlypromiseif I I'm goingtolookatthis.
I musthavegoogledthisanothertime.
Listentothis.
Verycommonbyusingjava, notjob.
Sorry.
Thenodepackageyoutillsonodepackageyoutillif I golookatyoutill, umandactuallyjustwanttobehere.
Thereis a promiseif I youtildotpromiseIf I Sowhat I couldactuallydois I cansay, uh, constUtilequalsrequireyoutillandthen I cansayAh, youtildotpromiseIf I had a weirdwordWell, whathappensif I promiseif I myselfthisSonowthisrequirechildprocessedexactfunctionnolongeruses a callbackNowuses a promise.
Andwhatdoesthatmean?
Thatmeans I cansayGodthenAndwhatevertheresulttheresponses I canconsolelogthatresponseAndthen I canalsocatchanyerrorwhen I canconsoledoterrorthaterror.
Butinsteadofsaying a callbackbasicallyhavethiscallbackthathappensinDoctorand I'm alsousingtheaerosyntax, thearrowsyntaxis a nicewayofshortofshorthanding.
This I'm gettingtheresponseistheargumenttothecallbackand I'm consoleloggingit.
Soifyouwanttoknowmoreaboutthosethings, I have a wholeplaylistaboutpromisesAnnaand a videoaboutthearrowfunctionthatyoucouldgoandlookat.
Thisisthebasicidea.
Thisis a littlebitofanadvancedvideoherewithnotadvance, butjust I'm usingkindofmoderndramascriptstuffyouconsider, like, threeyearsagomodern.
Ifyoudon't knowwhatmasteredonisthat I saythisalready.
I'vegot a wholesetofvideosdescribingthat.
I mean, youcouldgobackandlook, but I wanttosomehowpostittothisparticularboughtthecodingtrain.
Butokay, sonow, inordertodothat, I needto I needtolookupthefunctionsinthemasteron a p I.
So I'm usingthismasteredon a p I knowedpackage.
Andif I gohere, I canlookandseethatithasmasteredongetMasterDonpost.
Sothisiswhat I wantMassonpost.
Here's thething.
I didn't realizethiswhen I mademyothervideosaboutmasterDonbecauseitsayspathparametersandcallback.
Butguesswhat?
Thissupportspromises.
So I actuallygoingtodothiswithout a callbackwithpromises.
I'm goingtobreakthisout.
Didn't theysay I wasgoingtouse a sinkingawaitwasgonnawriteitwithjustthat, But I think I havetostart a littlebit.
I have a littlebitfurtherwiththefullpromises, syntaxthat I'm gonnacleanitupwith a second.
Wait a second.
Sonowthere's nosemicolonthere.
Sonowwhat I wanttodois I wanttobasicallysaythis.
I wanttoposttheimage, and I wanttoreturnthisbecauseifthisreturns a promise, guesswhat I gettodo.
I gettosaydotthenresponseandhaveanotherfunction.
Right?
Sothisistheideaofchainingpromisesandthisiswhat, intheory, I mean, basically, thewholetheoryofthisistoavoidcallback.
Hellandreally, wejustdidpromises.
Well, it's allhell.
Buteventuallywewillfloatintotheclouds, and I feellikewe'relikebutterfliesonwingsorsomething.
I don't know.
Okay, soif I returnthepostthat I wanttodowhenthat's doneSo I'm excusingthiscommandwhenthat's done, thendothisvetandthenwhenthenextpromisesdone, thendothis.
Sowhatdo I need?
YourThepath?
Sothefirstthing I need, what's weirdaboutandactuallyitmightbeworthjusttaking a minuteto, like, rightthestepsout, it'llmakeitmoreclear.
I wanttoexactprocessing.
That's oneThen, too, I wanttouploadimageandthenthree I wanttotoot.
Allright, Sowhat?
Thisisthesamethingfortothetwitter a p I Itdoesn't workthatyoujustifyouwant a tweetanimage, youdon't justsimplysendyourtweetalongwiththeimage, youhavetofirstuploadthemedia, getthatpathtothemedia, andthenyoucantweetwiththatmediareference.
Sothiswillactuallyreturn, and i d forthemedia.
Andthenaslongas I attachedthe i d tothis.
Sothiscreatesoutput, Doc.
PNG.
Thiscreatesan I d andthenusethat i d hereandthen I'm done.
Sosomebodywhoisblindedwithlowvisionwasusing a screenreaderinsteadofseeingthisimagewouldactuallyhearthisdescription.
So I wouldsay, a randomlygeneratedfractaltree.
Oh, and I wanttogetThisis I'm gonnasayconstangleequalsresponsedotStandardoutuhuh, with, umandthenwhen I needtousemynewthingthat I alwaysusenow, whichis, uh, templateliberalsforstringswithangle.
Whynotgowiththispromisechainthingsishow I woulddoit.
ProbablythenOh, no.
Andthenall I needtodoisreturnOnemorepromise.
So I'm alsogonnasayconstantparameters.
Now I wanttodo I needtolookatthe a p I for, umforwhat?
Post, butjuststatuses.
Um, Sothisiswhere, as I'm lookinglooking, looking, looking, looking, Um, actually, I needtolookfor a p i V onestatusissorry.
Oh, I failed.
Doit.
Maybe I wantto.
Maybe I should, like, actuallynowrewritethis.
Using a thing.
Gonnawait.
I'm gonnadothat.
I'm gonnadothat.
I'm gonnadothat.
I'm gonnadothat.
I'm gonnagofromwhere I printedthisout.
Nowthenextstepwouldbefortousethis I d Andthenactually, intheintheinthisresponse, right?
I exactexecutethecommand.
I uploadtheimage.
Andthen I shouldbesayingreturn m dotpostagainand I'm goingtostatusis I shouldsayreturn m dotpostagain, and I'm goingthiothepath I'm goingtoHisstatusissothisiswhat I shouldbedoing, but I can't resist.
Doyouseehowthisis?
I mean, it's great.
It's kindofnice.
Startthepromisechain.
Thendothisreturn a newpromise.
Thendothisreturn a newpromise.
Andifanyeverhappensanywherehere, catch.
Sowhynot?
Butthisisthethingthisisnow.
Thereis a way.
Thereis a newwayformetowriteallofthisinwhatfeelsMaursequentialmoresynchronous, infact, withlesskindofindentationandbracketsandstuffandthatisusingthis a sinkandawaitsintech.
Sowhat I'm actuallygoingtodois I'm goingtowrite a function.
I'm goingtocallit a tutororjusttwo, and I'm goingtomodifythisfunctionwiththekeyword a sink.
Thismeansthisisanasynchronousfunction.
Thisisindicatingtojobscript.
Thisis a featureof E s eightnewfeatureofjobscriptThat's indicatingthatthisfunctionwillbehandled a synchronouslyandalwaysalways, alwaysreturn a promise, anditwillautomagically.
Itwillbasicallyautomaticallyreturnthatproblem.
Sowe'lllookatthatleader.
Howdoesthatsoinotherwords, Butthis I wanttodothesamething, Likewhat I wanttodohereis I wanttosayexact, executethecommand, right.
Thesearethesteps.
Andthen I wanttosaypostthemedia, postthemedia.
Thenicethingaboutusingthesyntaxis I don't havetoseparateitoutwiththesechainingthesedotvents.
Soif I have a bunchofasynchronousthings, if I packagethemalltogetherinanasynchronousfunction, I canwritethemsequentiallyaslineafterlineafterlineandessentially, umand, youknow, I'm gonnahavesomeotherpramshere, Sothisisbasically I gettowriteitlikethis.
Now, I needtodostuffinbetween.
That's thething.
Like, forexample, thisreturns a response, andthenwhat I wanttodoisgettheangleandcreatethestream.
Sothisgoeshere.
Sothisismysteponehope.
Um, thisismystepone, right?
Executeprocessing.
Lookit.
It's justexactlylikethis.
Now I havemysteptwowhere I needtocreatetheseparametersthataregettingpassedin, andbytheway, I don't havetomake a separatevariable.
Couldbeembeddedrightinhere, butit's justsortoflike a littlebitforledgeability.