Categories
Learning

VueJS > React for smaller projects

Holy crap it has been 3 months since I last wrote something. I guess in the midst of being busy I lost the feel/drive to keep this updated.

Well, apart from those 2 short posts about Javascript, a whole lot has happened. Firstly, I gave up on using ReactJS for my capstone project. There’s a list of reasons, but I gave up mainly for 2 reasons.

  1. It takes too much time to develop something simple with it
  2. No boilerplate/templating within the framework means that it’s fast, but also means that I have to write a lot of native JS over and over again

Those 2 reasons, combined with the complexity of scaling with React correctly according to best practices got my head into such a spiral that it’s simply not worth the effort.

Instead I went with VueJS under the recommendation of my friend. And I gotta say, I managed to code with it way faster than React. Simply because there is a ton of templating code that reduces the amount of pure JS I need to write for simple things like looping. A v-for loop is much easier than a map function, where I have to deal with the type of objects and data type.

Side note: Set up a new server at my gf house. First time I’ve set up a physical server that I have access to somewhere else other than my own home. I don’t know what I can do with it yet, but it felt awesome because I felt that my knowledge is applicable in places apart from my own setup.

Categories
Learning

Immutability

So this is a concept that I have known for a while but have not been sure why it’s such a good idea. After going through a few documents and watching a 30 min talk I think I have a better understanding of what it’s all about.

Basically, you do not want your object to mutate. Because when you are not sure what has changed. For example,

let A = 1;
doSmth(A);
console.log(A); // What is A here?

It totally depends on what the function does and it is difficult to track how the values have changed over time. The library that I read up on was immutableJS, this library uses a Directed Acyclic Graph internally to represent the values internally. It makes sense because DAG will never point to a node causing a completed graph. The implementation is cool but shall not go into that.

So basically, the benefit of using an immutable data structure is that it allows me to compare between two objects much more efficiently. Because of the way DAG works, it can answer the question of “what changed?” very quickly. You can ensure that updating a variable do not cause weird bugs in a different portion of your application, because it’s not the “same” variable.

If it seems a bit confusing, it’s because it is and I’m dying. To the point where I actually need to write things down like these to remember what the hell I’ve been learning.

Till the next puzzle piece.

Categories
Learning

Redux: action creators

Because of the sheer amount of information that I’ve been researching on lately, I need to write it down somewhere before I forget all the shit that I’ve learnt.

Action creator is best used with the container-component pattern (smart/dumb). Basically the action creator separates the responsibility of creating the action within the component itself when you need to dispatch the action. Instead, you split it away as a function, and call it whenever you require to use it.

This is why it’s great to use this with mapDispatchToProps because it just works well together and you’re just passing a function from the smart to dumb.

Categories
Deployment Learning

Backup for WordPress

Backups are essential to any systems. Especially if it’s data that cannot be easily downloaded again, like a blog. Even though I should really employ a system-wide backup for my server, I’m still finding the most cost-effective and efficient way of making it happen.

Categories
Learning Optimization

Optimizing wordpress

When the entire WordPress multisite installation runs off a really tiny server, I have to use pretty much every single tip and trick I know in order to keep it on an acceptable performance level (while being secure).

These are the 4 techniques I used to optimize my WordPress installation.

  1. CDN (Cloudflare)
  2. Caching (WP Supercache)
  3. Jetpack
  4. AMP

If there’s anything that I missed out, please let me know and I’ll test it out.

Categories
Deployment Learning Security

Cloudflare CDN

In my attempts to get a valid SSL certificate for this site, I ended up cheating a little and making use of Cloudflare to do the securing for me instead.

Getting it set up was pretty straightforward, though I ran into some issues as I wasn’t familiar with Cloudflare’s infrastructure. I managed to set up a full SSL encryption as shown in the diagram below.

First, point my DNS NS records to Cloudflare, then generate the keypair on Cloudflare, import them into my server then update the Nginx config file to point to those keys. And everything just automagically become secured with TLS just like that. Made a few more optimizations on to minify JS/CSS/HTML as well as enforcing HTTPS for all of my sub-domains. Worked like a freaking charm.

SSL was my main concern when I decided used Cloudflare, but even on the free-tier there is basic protection against DDOS attacks, and my content will be cached closer to any visitors. This provides a nice boost in performance which is noticeable; it also provides a good boost in security, helping my tiny server stay available, just in case.

In the midst of working on this, I ended up optimizing the site at the same time, it should feel a lot more responsive now. In the next post, I’ll write about the tweaks I made to make WordPress run a lot faster.

Categories
Learning Security

Journey to security

I’m transitioning to the security industry, since it’s an area that I do not have much experience in, this will be a brand new journey and I would pretty much have to learn everything from the ground up.

Hence, I’ve decided to start a new category for Security and Learning to document all the things that I’m learning along the way.

I’ll also attempt to develop some mini-applications in order to test all the concepts that I’ve learnt. Let’s see how this will go.

Estimated deadline: 31st December 2017. Let’s do this.