Categories
Deployment Learning

Introduction to Terraform

As I’m going to be interviewing for a job that works on this platform, I’ve decided to read up on what Terraform is (as well as Nomad, but that’s for another post). This is actually something I’ve wanted to explore for awhile now, but haven’t had a good reason to get into it yet.

Terraform is very similar to AWS’s CloudFormation, which is basically Infrastructure as Code. However, the main advantage is that Terraform is platform agnostic, which means that I am able to use the same tool to deploy on multiple, different cloud providers. The catch however, is that the code is obviously different because services are different on different providers. Terraform basically just provides the platform/tool to manage it all in one place, but it’s way more powerful than that.

After watching a few talks and going through some documentation, the concept makes a lot of sense, and it might actually be pretty easy for me to deploy my own projects through this. Even though it would be a little pointless to use such a tool to deploy a single instance, hah.

I’ve watched two talks about Terraform so far.

I gotta say, my mind is a little overloaded right now. But I am very impressed with how he managed to bring up an entire infrastructure across different platforms and region in <10mins. It’s also amazing that by SSH-ing into the bastion host, he was able to have access to all nodes across different regions, and schedule services to launch on them without switching regions. (thanks to the VPN)

I am excited to see what type of projects I could test deploy with this new tool.

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
Development Optimization

Landing Page

Even though there are exams and what not, a geek can still eek out a little bit of time here and there for passion projects. It used to be blogger hosting all of my blog posts but ever since switching over to WordPress, I now have a “free” domain waiting to be used.

www.lordofgeeks.com

I finally created a portfolio site for myself, even though I’m not quite sure what to put on it yet. In fact, most of it is still work in progress but I thought it would make more sense to have this rather than a page that isn’t working at all.

Since there are only 3 pages, I wrote it entirely in HTML, hoping to convert it to some form of static NodeJS page in the future. However, I’ve employed all the new techniques I’ve recently, as well as some concepts that I’ve learnt in school.

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.

Categories
Deployment Docker

Automated Torrenting Configuration using Docker

I was sick of downloading my shows manually, it actually takes up quite a bit of time especially if you add them up over the years. Before I had my server set up, I was running Deluge with the YaRSS2 plugin which works wonderfully well as long as my computer was turned on. (kind of a power hog)

http://dev.deluge-torrent.org/wiki/Plugins/YaRSS2

But since I have a low-power server now, I can let it run 24/7 without worries. Here’s my experience with it.

Diagram of current setup