Press "Enter" to skip to content

Moar Weekend Shenanigans – FunFunFunction #23


good Monday morning I am mvj and this is

fun fun function today we are going to

continue the weekend project hack that I

started a couple of weeks ago you can

find the first episode there it was

actually not my intent to make that kind

of episode and I to be perfectly honest

I completely hated that episode when I

uploaded it I generally aim for 12

minutes and the episode turned out to be

30 minutes I didn’t succeed in

completing a hack it didn’t tell a

cohesive story it didn’t have a neat

script like theirs was basically a lot

of things about it that was wrong but if

God it got such a great response and

yeah

that’s the thing about YouTube videos

there almost seems to be an inverse

relationship between what videos I think

will be successful and what videos are

successful in in reality well what’s

good about that last video so went back

and looked at the comments and DA and

the video and try to figure out what

what did I accidentally create here when

you look at that episode it captures

what programming really is what it

really feels like and what’s nice about

it really

yet you’re creating something and you

run into problems and you hammer your

head against him until you solve them

slowly but surely something’s starting

to take form it almost has the same feel

to it like the let’s play format that

gamer youtubers use the problem is that

the episodes get very long it took ages

to edit the last video and I don’t

really know how I’m supposed to make

this work so that is the objective of

this episode is to try to figure that

out we need to experiment with this a

little bit to find the format and I also

I’m not scripted this I’m just going to

try to let it flow I will edit this

heavily but I will try to give you I

will not try to hide the errors

I make as much so let’s just jump into

it uh so this project is this is a very

common problem for me now I’m jumping

into some code here it was several weeks

since I did this project I was looking

at this code I did I did I did go back

and watch the last episode but then I

really helped because I seem to have

written some code some code here that

was not there in the last episode so I

have coded some stuff here since the

last episode yeah and this is this is

quite a normal problem in programming

that you’re jumping into code and you

don’t know what who the hell wrote this

and then you look at the gate name

and say oh it was me I just don’t

remember it this is why I often try to

keep a log of what I’m doing and git

commits are great or I often feel like I

need something more granular than that

so I try to keep a work log let’s do

that okay okay work log and I often tend

to I like to write down a current goal

to keep myself focused on what I’m doing

so sometimes I get the impulse to do

error factoring or try to oh we should

pull in this library but if it doesn’t

help you on your way to your goal that

is actually just a diversion or busy

work so I tend to when I feel like oh I

want to refactor this I say to myself

yes you are allowed to do that but only

after you have completed your current

goal and you can use that cleanup or

refactoring as a kind of reward for

completing a goal so what the hell is

our current goal I don’t we’re making

something with this button we’re

creating a Pomodoro timer eventually but

that seems like a very big ol I want

something that we can reasonably

complete today maybe so what about

I don’t know okay let’s think I’m tired

a a make a make a make a there sometimes

when you’re writing it’s just a good

idea to write stuff out we want to press

the button and have the server log out

the number of the phone that was pressed

BAM right that is a goal so our current

goal is to press the button here one of

these four and have the server log out

the number of the button that was

pressed that was that is our goal that

is realistic it’s achievable it’s

unambiguous so last time I put our

server up on Google cloud and since the

Google cloud will cost you a little bit

of money I actually just deleted that

cluster after I made the video so today

we are going to spin that up again

that’s our first objective so that we

are back where we were last time so I’m

writing that in the work log okay let’s

get going let’s get the server back up

again okay how do I create a cluster I

think that I have this in this curl dot

txt file I’m gonna just change this to

something more descriptive like notes no

cuddling what I’m gonna name it if this

was a Twitter stream I would probably

ask the chat but I don’t have any goals

squiggles that’s fine

all right so I think g-cloud content

this one I think that I will paste this

one and see okay

see yes creating cluster Oh this took

some time before uh I will probably go

do something oh it’s done okay so we

need to deploy the server on Google

cloud do some googling deploy coober

these JSON Oh No didn’t find anything G

cloud oh here’s something

cube CTL create F and then it’s where is

it cuber new t stop json does this work

yes I think it did let’s close this so

what we did here was that this

kubernetes top JSON is the file that

describes how the cluster should look on

kubernetes or this part of the cluster

so this is kind of a server description

sort of don’t know if this work though

let’s say cube CTL get RC so this gives

us a list of replication controllers and

replication controls in kubernetes is

that is the stuff that control servers

and like and the service and cells are

called pods so we can do cube CTL get

po4 pods and that seems to be like you

see here that it has status running

there all right so this is good but we

need to expose it to the Internet as

no of course I don’t I’m just gonna go

now

okay look at how red my nose is there

I’ve been outside walking cube CTL

expose and I explosive replication

there this work you must provide oh I

need to expel it that it’s an

eradication controller cool it’s exposed

just copy this so that I have it in my

squiggles here so this is to me this is

very typical of how I do development

there is some detail about something

that you forgot kind of how you did and

your brain helps you figure out sort of

too old I think I made a note of that

there I think I made a video of that

there or perhaps that colleague of mine

mentioned something about that kind of I

probably should have her things are

immense it’s all over the place and you

need to figure stuff out even when there

is proper documentation it’s often hard

to navigate that documentation or to

find exactly what you need so you need

to get this process and this feel about

figuring things out I think that we now

can just do cube CTL get service seven

still and now this should have an

external IP which so we should be able

all right because we don’t know if this

works because it doesn’t output anything

but it might do it in the logs what I

mean by not outputting anything is that

the we’re posting here to event right

and it’s received here and we are yes

console logging the body out but we’re

not actually sending anything to the

response so to see if this work we need

to check out the logs of this this pod

here this one so to do that I’m gonna

copy paste that and we’ve cube CTL logs

yes exactly here body world and that is

what we sent here like a hello world and

we’re reading it over here so now we are

back at where we started in the last

video yay all right so where were we

let’s go back to the the work log and

remind ourselves so the current goal and

said we want to press the button

and have the server log out the number

of the button that was pressed right

we have server I think that the next

step is to let to just make the button

call server just anything just just have

a button do something sub goal get the

button calling the server somehow I

think I added this here

this service hook dot JSON I don’t know

what this is against that this is

probably okay there’s an IP here I guess

that this is the IP of the old cluster

and it calls

slurp and it posts some things here I

think that this is the kind of a web

hook thing that is uploaded to the SPARC

cloud which will then call the our

cluster they unlike kubernetes cluster

yeah so let’s see we need to log into

the SPARC cloud where it’s not even

Sparrer

no it’s 400 they’re not called spark

dashboard perhaps yes this is our

dashboard okay we have the photon the q2

waffle right this looks good

gonna try to plug this in I need to get

a USB extension cable because my

computer is down there in order for the

fan not to make too much noise to the

mine wait I realize I don’t need a USB

extension cord because this is Wi-Fi

connected this one is just for power so

I can just connect it to my monitor nope

that doesn’t work I don’t think that the

things are so hard you know what I do

own I own this USB battery yeah that

ain’t is cool so what this thing does

now is that it downloads the from the

software from the from the cloud and

downloaded it and run it it’s pretty

cool so you deploy things as long as

these things have Wi-Fi you can deploy

things new firmware to them over the

cloud this was great before so I guess

that the blue box means that they are

online maybe okay cool so our pewter

waffle is now online that seems like

what we have named this so how do I edit

the code and is run

on this thing Oh a click here maybe

build yes this is it ok so I have made

some stuff here there’s a lot of are

this lot of stuff here this is not nice

code

okay I’ll partially implement this

actually thank you former MP J I ok tell

me I think that if we look at this loop

here yeah we see that I have

so if button on at one half sorry

Swedish it’s pressed the then the LED is

supposed to come on and then it’s going

to delay for 500 milliseconds and then

it’s going to publish the button press

event here button press with one and 60

something and private ok and then we

have the exact same thing here button to

and also 60 here 6 here 60 here I don’t

know what six years but it seems like we

have a partial implementation of this

and the button has died just doesn’t I

think that the battery doesn’t realize

that this is actually pulling any power

because I suppose of this just also

milpa or it just doesn’t tell this thing

that it’s charging

I don’t know but either way after a

while it will just shut itself off so I

need to actually do the thing with the

I swear to God that I’m not sponsored by

IKEA but these things really good stuff

I fixed it I am outside waiting on the

train because I need to go into the city

because my monitor died during the

recording and it won’t come back up so I

need to buy a new monitor I kid you not

this is not staged this makes me very

grumpy of course and part of me wants to

just say don’t buy Adele because you

need quality tools that you can rely on

but when it comes down to it this is

really just what the universe is like

things break down it’s a mess and being

a developer or any creative professional

or any any person making things for

other people means that we we deal with

these things so that others won’t have

to do that is our job so my job is to go

to town get new monitor and continue

shooting

I have approximately 45 minutes before

the last electronic store behind now

poses no need to hurry I literally just

walked in and took the first monitor

with that looks easy to carry took a lot

and we are back with a functioning

monitor this service hook here I think

that we can do

Oh particle IO let’s find out what this

I need to find out again what my public

IP s of kubernetes keeps ETL I get

service s let’s paste that in here the

web hook of the particle IO see if we

can why not how to create these oh I

just do particle web hook create service

okay cool

interesting I’ll press the button here

and cube CTL get you see what logs looks

cube CTL yet oh oh we’re there okay

interesting so what did what we did was

this service hook is kind of like most

web hooks if you familiar with them that

specifies an IP that it calls to and a

port Inanna endpoint what type of

request is gonna post and what and what

value so this is a spark event name a

spark event value and then the spark

core i d– so okay so what is this this

is okay so i guess that this this here

corresponds to this here and the value

were here yes going to be the it’s a

button pressing button three they come

from our code in the spark particle i/o

so if I switch to the particle build

here that is sent from this particle

publish here so particle publish will go

to the particle cloud and then it will

send that on defined into whatever is

defined in the service web hook here and

it will send on this jss JSON blob so

it’s takes the spark event name from the

from the publish the publish call here

and spark event value and also welds on

the source the spark core ID and the

spark core ID I think that a

we go to the dashboard the particle

dashboard will see that it’s this right

this and this is the same and that will

later allow us to send send stuff back

to the to the photon so I guess that

this is mission accomplished our current

goal was to press the button and have

the server log out the number of the

button that was Preston we that’s

exactly what we did

so when I press something you know what

we can tail the logs if I do like know

if I plan an f2 the logs comin and

kubernetes it will follow the log so if

I press the button now am am nice so

this is a really good step on the way I

think that I’m just gonna admit it so we

have get status whoops oh nothing is

basically committed I am going to add

Jason I’m not gonna add the squiggles

we’re gonna the code itself and we’re

not gonna work log either and I’m just

gonna do it kind of dirty commit here we

IP WIP that’s 4 stands for work in

progress and I’m gonna get push em PJ

master just so that it’s saved this is

not a way that I like to work on more

serious projects but this is a week in

hack and we’re not too concerned with

get message history alright so that’s it

for today so we made a little bit more

progress today we actually we actually

accomplished what we set out to do this

time which was to press the button have

the server log out the number of the

button that was press much thanks to my

former self that obviously did this a

couple of weeks ago there’s a lot of

mess here

that I would like to clean up maybe we

uh we will we will do that next time but

I think I want to make a bit more

progress before we go into the cleaning

anything well let’s hope that my screen

doesn’t break next time we might get

some more coding in next time oh I’m

still struggling with getting his let’s

code session to work I really want them

to work he will just have to bear with

me well like I experiment with this I

promise they will eventually become

awesome I don’t promise that really

anyway I am mpj this is fun fun function until next Monday morning stay curious

Please follow and like us: