Javascript’s call, apply and bind methods

Javascrip's apply, call and bind methods

I’ve been mulling over getting this post up for a while now – simply because functions are a big deal in Javascript. Javascript functions are packed with so many properties, methods and it’s fundamental nature requires some quality time in understanding its features.

There are a few things to keep in mind when dealing with Javascripts call(), apply, and bind methods()

  • call(), apply() and bind() are three methods every function has access too
  • bind() creates a copy of the function object in question
  • call(), apply() and bind() methods are methods that allow an object to point to a different ‘this’ variable when invoked.
  • Common patterns used in conjunction with call(), apply() and bind() are function borrowing and function currying.

Continue reading “Javascript’s call, apply and bind methods”

Importing sql database using the command line

Importing sql database using the command line

This is definitely worth a post. Just when I want to disregard this utility as trivial – every now and then I get a consulting gig where I need to run a full backup – yes of everything, files, database, the works. You see, sometimes I get a task that isn’t as black and white as it may seem at first glance – something is a bit unconventional, but you know – there is nothing wrong with that. Sites come in all shapes and sizes, in all sorts of architectures. It’s good to get exposed to a variety even really weird ones. Look I’d rather poke around a dev site over production no matter how tempting it is – I’ve seen way too many sites go down in my life time, it’s not worth the gamble. I tell every junior developer – the first thing you should do is create a back up. First thing you should do. Then you can show off your programming skills later and you know – be that “rockstar” developer you were meant to be.

Continue reading “Importing sql database using the command line”

Javascript’s defer vs async attribute

Javascript’s defer vs async attribute

Flashbacks of vanilla javascript cloud my mind – back when we didn’t have Jquery. All we had was Javascripts’ event listener method to detect whether the entire DOM was loaded before scripts were fired off.

Why was this necessary though? Well, if you’re a developer you very well know – page speed. And back in those days, programmers weren’t so mindful of placing external javascript files – the head section, footer and I’ve seen some sprinkled throughout the body. Not optimal at all – this can have huge negative implications in terms of functionality and speed.

Continue reading “Javascript’s defer vs async attribute”

Fixing a network 404 error using typeof

Fixing a network 404 error using typeof

Javascript’s typeof operator is an essential debugging tool that many young programmers often miss. Countless times I’ve run into situations where my program wasn’t working because either my variable was unnoticeably coerced or I was just completely unaware of a data type. As mentioned in a previous post – a season programmer should know their data types! Another thing a seasoned programmer ought to know is to prevent themselves from being too arrogant – yes, we need help and using the “typeof” operator is there to the rescue.

Continue reading “Fixing a network 404 error using typeof”

Data Structures & Algorithms II

Data Structures & Algorithms II

This is part || of Data Structures & Algorithms using Javascript. I would like to give credit to freeCodeCamp.org for their series of videos covering this topic.

In part I we started off with a simply defining a few data types – an array and a string for storing data in memory. Then we used a “for-loop” to access and manipulate our data structures. Finally we came up with a sequence of steps to test whether a word was a palindrome or not. In part II now, were going to wrap up all that code into what we call a function object.

Functions are a powerful data structure encapsulating your algorithms. Functions also are a good example of “DRY” – Don’t Repeat Yourself.

Continue reading “Data Structures & Algorithms II”

Data Structures and Algorithms in Javascript – Stacks

Data Structures and Algorithms 1 - Stacks

Javascript is a language most developers either overestimate or underestimate – whatever the case, this is what makes Javascript special. Javascript is a dynamic language, it’s abstract and for this reason also prone to instability. Javascript in the last decade has provided developers with a place for inventiveness and innovation.

Lately I’ve been immersing myself into mathematics, physics, chemistry, philosophy and even linguistics. I found my premise to still hold true – that the universe is at a state of decay, of disorder, and mutation. It’s exactly because of mutation that we are able to manage disorder and chaos, so in a sense we are constantly trying to keep up with ourselves as we simultaneously and inevitably push forward into the future.

Continue reading “Data Structures and Algorithms in Javascript – Stacks”

WPEngine, Nginx and htaccess

WPEngine, Nginx and htaccess

Redirects can get hairy sometimes – sometimes you get a nice clean canvas of directives, sometimes it’s messy and undocumented. Whatever the case, you’re dealing with an .htaccess file. One wrong move and you can crash your site
or worse yet a clients site. So before anything else make sure you have FTP access and you create a back up of their existing .htaccess file. Don’t even be tempted to do it through Yoast – even though they allow you to edit the .htaccess file right through WordPress. I’ve seen it happen and it isn’t worth it.

So you’ve got the .htaccess file – you’re going down line by line. It can look like a jungle at times – you’ll see caching stuff, some 301 redirects, some permission stuff.

Continue reading “WPEngine, Nginx and htaccess”

The Genesis Framework

The Genesis Framework

I’ve been running into the WordPress Genesis theme as of late. It’s not your standard wordpress theme when it comes to modifying template files. Genesis is actually a framework, that would be a better way to describe it. Genesis frameworks extend their functionality, allowing developers to customize their WordPress site.

The Genesis framework is built by Studio Press – I’m quite impressed with their work actually, it sounds like a solid framework I just need to learn more about it. So I dove right in – I scoured the internet for some learning material and a good list came up. This can only take you so far though – the best way to really learn is actually do it yourself, so that’s what I’m gonna do.

Continue reading “The Genesis Framework”

A Framework Author’s Case Against Frameworks

A Framework Author’s Case Against Frameworks

It’s the year 3018 for a programmer these days, yeah a 1000 years from now is what it feels like when my proclivities now involve constantly digesting new information not in seconds, but in hertz. Now hertz is the unit of measure we use to measure frequency. Since frequency is measured in cycles per second, one hertz equals one cycle per second. Where am I going with all this? Well what I’m really trying to say is that as we add more abstraction or more information to a particular thing, the more unnecessarily complicated it gets – and in some ways this ‘thing’ actually starts to become increasingly unstable.

This post is nice and light actually, it was an arbitrary find while I undergoing my usual subconscious bombardment of various programming concepts – namely, data structures, control structures and machine language. In this video A Framework Author’s Case Against Frameworks, Adrian Holovaty, the creator of Django gives a high level example of how frameworks can further complicate things for a developer.

Continue reading “A Framework Author’s Case Against Frameworks”

UNIX: Making Computers Easier To Use

UNIX: Making Computers Easier To Use

This post is a video review based on UNIX: Making Computers Easier To Use — AT&T Archives film from 1982, Bell Laboratories. Just like its titled thats how Unix came to life. Without its creators – Dennis Ritchie and colleague Ken Thompson, computers would not be better off with the Unix operating system. I was continuing the endless journey with programming in C but I stumbled upon one of those classics.

You would think these two brainiacs would be in some garage coding dungeon but nope, Unix was born at Bell Labs. I could just imagine both of them staying in late and hacking on some code. Well, that’s exactly what they did and now we have iOS, MacOS, Linux and Android – which all power a lot of devices we have today.

Continue reading “UNIX: Making Computers Easier To Use”