JavaScript

Passing an Object to a Function in JavaScript:


No Comments

So while learning about how objects behave in javaScript, I came across an issue that had me stumped for a bit. I understood object creation, the syntax was pretty straight forward, and stepping away from procedural programming into thinking in terms of complex objects with multiple properties that act as one unit was a really cool change of mindset.

So in this example let’s say we are looking for a vintage automobile with the criteria that it must be pre-1960, with 10,000 miles or less: we will create a variable named taxi that is an object with these properties:

var taxi = {
make: “Webville Motors”,
model: “Taxi”,
year: 1955,
color: “yellow”,
passengers: 4,
convertaible: false,
mileage: 281341,
started: false
};

We’ll want to run it through a conditional test to determine if it fits our criteria. Let’s make a function called prequal that takes the object as a parameter and runs some if else conditionals returning a boolean value like so:

function prequal(car) {
if (car.mileage > 10000) {
return false;
} else if (car.year > 1960) {
return false;
}
return true;
}

The important part (and the part that stumped me) was that the object passed to the function in this case was called car instead of taxi! The reason we’d want to call it car is because we may want to pass several similar car objects up to the function, with all of them having different properties.

So let’s save the value the function returns to a variable called worthALook. (note that the taxi object reference is in the prequal parameter, not literally the object taxi) Then, using another if/else statement, we’ll log to the console a string, concatenating the object properties in there as well.

var worthALook = prequal(taxi);
if (worthALook) {
console.log(“You gotta check out this ” + taxi.make + ” ” + taxi.model);
} else {
console.log(“You should really pass on the ” + taxi.make + ” ” + taxi.model);
}

The main take-away is this:
When passing an object up to a function as a parameter you can use an object name that can refer to all your objects. This was the first thing in the “Head First JavaScript” series that had me stumped and I had to go back and pull out of the chapter why the object taxi/car can be called using the name car instead of taxi.

Uncategorized

Re-Focus


2 Comments
credit https://www.calvarybaptist.ca/

After making the decision to pursue building my knowledge in computer programming last November; first by learning Python, then web development starting with the basics (html, css, JavaScript) I find myself losing steam. Everyone has an excuse as to why they should settle for less than they set out to achieve and that always bothered me, so I’ve decided pen out some of my frustrations here.

For me it basically stems from a LACK OF FOCUS, having 3 young kids at home with me, living rurally and taking care of a house undergoing renovations there are no limit to the distractions that pull my focus away from what I am doing. The Key here is that everyone gets sidetracked, everyone loses focus and momentum, but it’s those few that are able to RE-FOCUS quickly who succeed in their endeavors.

Ask yourself WHY would I choose to re-focus? – Your WHY will determine weather you get back on that horse and wagon or not so you better figure that out! My reason why I’m building software and tech skills is because at the age of 32 I don’t want to have to take a job that is physical/dangerous to do, or work for less than I know that I am worth. (And I love computer programming!) I know this will take some time to build a good enough portfolio to be taken seriously and I am willing to put in that time!

Outdoors

Family Campfire Lunch


No Comments

Family Campfire Lunch

I love spending time in the woods. Or the alpine. Or pretty much anywhere that’s surrounded by nature. I find that being outside, especially alone, can be a very trans-formative/introspective experience. However, if you have a wife and kids like me, who don’t yet know that they like the outdoors, you pretty much have to drag them out of the house, away from the screen or the kitchen and force them to be around nature. I’m not even joking, they just don’t feel the pull to the outdoors like I do. Then, after they have had some fresh air and calmed down, and once they’ve gotten over the necessary abduction, they wind up having a really fun time.

This was one of those fun times. Last summer I spent a few nights out on the property camping in the forest under a tarp and small log shelter. Because it was so close to my house I was able to take my time building it and had a lot of gear there including a camping ‘cot’ and my old acoustic guitar. This was mostly a warm up for my first solo trip I did later in the fall where I was a long hike/bushwhack away from the nearest logging road. (read more about that trip in the post below entitled “Real Outdoors”)

It took about a day to set up the camp and the first thing I needed were some logs for a ridgepole and walls. Thankfully there are plenty of trembling aspen, small ones only 12-15 feet high, all over our property that were the perfect size. After building the camp I cut some firewood with a chainsaw which doubled as beautifying the property by removing all the unattractive blow-down that littered the woods (It also prevents forest fires from spreading along the forest floor). I stayed the night there alone, playing guitar, throwing axes and knives, and just having myself a good ol’ time before passing out on my comfy cot for the night.

The next day my wife and kids joined me for a nice cup of coffee and campfire lunch. We had eggs and sausages, taquitos, pizza pops, and s’mores for dessert. I had to comb along the immediate area removing any thorns and spiky sticks since my kids are like 3 feet tall and came out in shorts. We had a great time and my oldest daughter, who is 8 years old, helped out by hand-sawing some firewood. Then she wanted to do some carving but I said “no, not without some thick leather gloves”. All in all the kids had a great time even with some thorns in their legs, they did good.

Outdoors, Uncategorized

Real Outdoors


No Comments

From time to time one simply has to get away from everything especially technology. Doing a solo trip into the frozen wilderness without access to screens (other than a phone for photos and emergencies, not that it was too helpful as the batteries and battery bank were depleted instantly from the cold!) and distractions really helps me think and be alone with just my thoughts. We always seem to be filling out minds with all sorts of junk but are too afraid of just being alone, silent and still.  

This image has an empty alt attribute; its file name is img_1967.jpg
This is what my camp area looked like the day before
This image has an empty alt attribute; its file name is img_1988.jpg
This is what it looked like during

The hike in went well, it was only a little over an hour hike into the woods, but with a heavy pack (I packed WAY too much food just to be safe!) it was still quite the jaunt for someone a little huskier like myself. My challenge to myself was to do this trip alone with no tent or cook stove. This allowed me an opportunity to build an awesome tarp shelter and do lots of campfire cooking!

I arrived at my camp location making lots of noise and a little nervous for the night to come, since there are LOTS of bears around here. They would probably be hibernating by now and not want to bother me anyways but hey -I’m a wimp. I had tree-planted down this logging road earlier in the year and we ran into black bears on multiple occasions. I had left my home early enough because I knew once there it would be a race against time to get the necessary firewood, fire -pit, shelter, and firewood shelter. Luckily I am wise like Yoda because everything that could go wrong with the weather did. It rained the whole way in and I got soaked. Then it turned into snow as I was trying to get a fire going with whatever wood and tinder I could find that hadn’t been thoroughly drenched. I wound up lighting my fire under a large chunk of slash leftover from logging. It barely got going since huge snowflakes were consistently quenching it’s flames.

This image has an empty alt attribute; its file name is img_1978.jpg
All-Important fire!

I had to think fast and gather some hemlock boughs with lots of needle coverage to make a little roof above the fire so I could keep it going, not to mention getting some hot coals going for dinner. By now I am starving. I am a 250 pound attempting-to-be-strongman and I eat A-LOT of food under normal conditions. Time for a quick snack; a couple of 3-cheese pizza pops!!(I swear I’m not 14!) They were the best I’ve ever tasted and made my hands a little less shaky from hunger. (I picked them because I could just wrap them up in tinfoil and toss them on the coals)

I still had to set up the rest of the shelter and most of my gear is soaked now like I am. I decided on a lean to with the tarp folded over the ground, then up onto some posts I had cut and pounded into the ground with an added cross-beam. Once set up and with some of my gear drying under it, I got back to cutting firewood. I would need much more since I planned on having an all night fire. I switched out the dry boughs covering the fire with some ice and snow covered ones and put them down on my tarp floor for an insulating ground layer, then laid down the ‘space-blanket’ followed by my sleeping bag and another space-blanket for total warmth at night. It was badly needed since it dropped to -15 Celsius (5 Fahrenheit).

This image has an empty alt attribute; its file name is img_1985.jpg
My finished campsite

I wish I was able to take more photos to help explain my firewood processing and cooking etc. But I was literally running from one thing to the next without much time for photography anyways and the cold was killing my batteries too, like I said earlier. I would head into the woods looking for dead wood (it was all soaked and frozen regardless) and cut 6-10 foot logs that I dragged into my splitting area. I pounded 2 aluminum spikes at opposing angles so I could set my log in it and cut quickly with my bow saw into small 14 inch pieces. Once I had a good pile going or was too tired of cutting I would switch and start splitting them into kindling sized pieces with my hatchet so that they would be easier to preserve, and work with a smaller fire. I had leveled off the top of the same log for a flat surface to split on too.

That view tho!
My dinner and glove drying setup
A rock stool with wool skin
coffee pot on cutting board heating by the fire

My days routine typically consisted of waking up around 7 which is a little late but I needed the extra sleep after having very cold nights with not too much actual sleeping. I could finally take a pee, get my shoes, wool and hoodie on and get a fire going which was a challenge as it was hard to keep everything other than a tiny bit of tinder dry. Once it was really crackling I would head down the icy ravine that led to fresh creek water which wasn’t completely frozen over yet. Coffee was the reward for said journey and was enjoyed almost in pure ecstasy because I was finally warming and waking up. After I had downed 2 cups or so I would get a breakfast of eggs and meat or a can of beans cooking. After eating I would process firewood all day, and make one or two items for my shelter if I had the time. Like hanging pegs to dry clothes on, or a small table for prepping food. I liked to start dinner while I had a little light because it took so long to do everything. Throughout the day I would be drinking coffee, oval-teen, and tea!

In summary, it was a real challenge to go into the woods in early winter in the Canadian Rockies with no tent or cook stove. Being exposed to the elements especially the harsh cold and hunger is a great way to appreciate the luxuries in our homes and in society that we take for granted. It really makes you realize how vulnerable we are and if it wasn’t for all our systems and basic technologies most people probably would not survive.

Uncategorized

One with Nature


No Comments

I thought this quick video was really satisfying to watch. Going into the woods to fend for yourself with all really primitive tools and old equipment… Really cool. I have been watching those types of survival videos for some time now and I should actually upload some photos of my wilderness survival camp I camped at a few weeks ago. It really grounded me and made me think about what my priorities are and what direction I would like to steer my life.

Uncategorized

Software Development


No Comments

Follow my Journey on YouTube!

I’m just starting out but the next ones will have better lighting/quality

Hi there, I’m John McKirdy and I’m starting the long process of building up the hefty portfolio that is required to get into the software development/ computer sciences business. Ha ha Its def gonna be a long run! I had always been interested in coding but was never really motivated to do anything about it. That has changed over the last few months and I am now intent on diving into this as a hobby, then hopefully, a career.

Not knowing where to start can always be a bit of a problem when undertaking a task such as this. I mean I don’t even write anything anymore let alone come up with all the content and learn these new languages all at once. But one step at a time…. First I learned some Python. Enough to get an easy little text game going which I should eventually get connected to this site. I do try to break into more complex bits of code too and go beyond what my comfort coding levels are. But now WordPress is distracting me from this since it would be a quicker way to level up to actually getting paid for something in the Comp Sci/ SoftwareDev. space. And so that is what I have been doing this past week. All the while of coarse completing my reno that I am using as an example for this Test Site. Signing off now — But this reminds me, I should try to update this blog every week, so 3 months from now I will have a happy little archive sitting there.

Uncategorized

Background


No Comments

A little while ago, while doing a solo camping/survival trip, I realized that I have always been passionate about computers and how they work, yet I had not developed that passion into anything of substance or into something that could lead to a career. So I decided to remedy that by diving head-first into the Python programming language. I had done programming in high school but no one was there to push me to learn the harder parts of it; as it was, most of the IT class were happy just doing typing games and learning basic computer apps which were very popular (PowerPoint, Excel, Word, ect). So now, 12 years after I graduated high school I finally started the deep dive into Information Technology!