Categories
Musing

Management and Programming?

Right now, I do a) business development, b) project management and c) programming. This is quite a new role to me. Previously I am more focused and rarely do things outside of coding (I am using programming and coding interchangeably today).

Actually I am quite frustrated with this. If I am focused on coding, it means that I can show my work in terms of screens created or problems solved.

But for project management and business development, you can’t show much except the business you bring in and the gantt charts you’ve created. Since I am doing those three at the same time, my “show of productivity” are divided into three and since it’s hard for human (me) to be in the flow to work, actually the amount of code I generated have dramatically reduced compared to the previous 3 months.

This is something new to me.

And it’s a good challenge.

I learned a lot on how to budget (time and money), how to do the business side of IT (I have created tender as well) as well as to juggle these tasks. The higher you go, the more you have to manage it properly or you will succumb to busyness and not productive.

Let’s do more and learn more this year.

Categories
Musing

Happy New Year!

What’s the best way to start a new year for a geek other than coding at night? Tonight I practiced coding in Python by tackling a problems that I got from Project Euler’s archives. You can view the first 2 problems I solved in my Github.

Since it’s already a new year, so what’s my wishes this year?

Well, I have some wishes such as:

  1. I wish to build and have my own simple SaaS running
  2. Make Makna.online and Kokotiam self-sustaining
  3. Take care of my body and my mind better
  4. Create a Programming Course. I haven’t decided which language yet though (PHP? Laravel? Vue? React? Or Python? Swift? Java? Or something else?)

Anyway, let us all wish for a better future ahead! 

Happy New Year all!

Categories
Programming

How to Install PIP and CodeIntel on Mac OS Mojave

Mojave has its own  Python installed already. Just run this inside your Terminal :

python --version 

and you will see that there is a version installed.

So all you had to do to install PIP if you already have installed Python is by typing this:

sudo easy_install pip

and you will have installed PIP after that. I use PIP to Install CodeIntel.

To Install CodeIntel, remember to put Sudo in front of the command.

sudo pip install -U CodeIntel

Categories
Programming

What’s The Best Way to Learn New Framework?

By doing.

As simple as that.

For example, I don’t know the difference between Bootstrap 3 and 4.

So I created a project based on Bootstrap 4.

A simple dictionary website for people to find meaning of a word.

Basically it’s a place for people to search for meaning of a word in Malay.

To make it better, I also use Google Translate API to grab meaning in English and insert it into the DB. So it doesn’t have to query Google Translate all the time. It only query it one time and then I insert it into the DB.

The second time people visit the same page, the page won’t call Google Translate API again. Just have to query the database. I use MySQL for this project.

I originally use Vue with Axios for this website. Vue is after all the hottest thing right now. I first used it in one of the take-home coding interview and it seems quite interesting to use.

But the moment I saw the website in Google Index, it seems that Google doesn’t really crawl all the links inside.

So I turned back to using vanilla HTML website again.

I need to figure out a way how to make a Google-friendly Javascript-based website before I use Vue again.

At the website I also implemented a simple search suggestion using Bootstrap Typeahead so people can know what’s in the database before they click Cari.

As you can see, there are a lot of things that I am doing on the website under the hood. It’s pretty simple website, sure. But it means that I can learn how to use Bootstrap 4, Vue and Axios.

That’s how we can learn how to use a new programming framework — by using it. Every framework is a little bit different and the best way to learn about it is to implement it yourself.

So have a look at Makna Perkataan and tell me what you think!

Categories
Programming

Playing Around Creating Tinder Swipe Effect

This is just me trying to play around creating a swipe effect like Tinder.

Categories
Musing

My Silliest Mistake So Far (Maybe?)

My boss asked me to create a survey form for people to fill in and we can know how students feel and what kind of improvements that can be done in the university.

So I literally did that.

I created a form, a database, the script and all… just to create a survey form.

A waste of time.

There are a lot of system out there that are better than what I attempted to do. They already went through trials and errors and have improvised based on suggestions by their users.

I should have surveyed the market first through and through.

When there are so many survey tools out there. And there’s even an open source tool to do survey.

I can use Google Forms, or Survey Monkey and I achieve the same thing.

I use Metronic Admin Template to create this. And for the code, I use PHP.

Always survey and see what the market has. Or else you probably will miss what others have made that can make your life easier.

Categories
Programming

First Time Live Coding

So I’ve uploaded a video of me coding. The first time I have ever recorded it. You can see the video below.

Well it’s not really “live”, but rather, me recording it and then upload it to YouTube.

Categories
Programming

Thinking About Microservices Architecture

In the past 2 weeks I was so busy with many things. Had an interview with a well known media company. It was the longest interview process that I ever had.  and I was busy finishing a system I’m developing and collecting data for the green system here.

Right now, at AiU, I have to think a lot about how to implement IoT solution. How the overall of the architecture looks like.

And I chose microservice architecture.

From microservices.io:

Microservices – also known as the microservice architecture – is an architectural style that structures an application as a collection of loosely coupled services, which implement business capabilities. The microservice architecture enables the continuous delivery/deployment of large, complex applications. It also enables an organization to evolve its technology stack.

Why do I choose microservices architecture?

At AIU, I won’t be connecting just one type of device (the switch), but I’ll be connecting with the door and the solar, the battery and the grid.

I don’t like a single point of failure even though using just one system may make the system easier to make.

Another challenge that I have is that all these devices “speak” different languages. One is Java, another is C++ and another… Microsoft Access.

Since I have to connect to multiple types of devices with multiple languages at the same time, I doubt that a monolithic architecture is a good way to integrate all these devices.

From Wikipedia, monolithic applications are:

In software engineering, a monolithic application describes a single-tiered software application in which the user interface and data access code are combined into a single program from a single platform.

Drawbacks of Microservices Architecture

  1. To debug is quite hard. You have to write all the loggings for all the different services and it may have different languages
  2. Consumes more time to develop than a monolithic one. Each type of devices has its own so-called “controllers”. Instead of one big one that manages everything.

Pros of Microservices Architecture

  1. Easier to add new functions. If I wanted to add new function to the smart switch like scheduling, I just whip open the smart switch controller’s project, I can add that function.
  2. Know exactly what’s going on – instead of guessing, I know which device caused problem. Can’t get the data from solar panel, OK it’s autoswitch controller’s problem. I can debug from there.

Microservices is not a silver bullet to me. It’s just that I felt that using this architecture is the best for this situation of mine.

Categories
Musing

How Hacker News Will Affect Your Site?

I have never expected that this little blog of mine will reach the 1st page of Hacker News.

I dreamed of it. How wonderful it would be if I just reached the 1st page of Hacker News… but I never think that I’ll get to the 1st page.

Just out of curiosity, I submitted the post I wrote few months back to Hacker News. It’s basically a place where startup people read whatever happening in the startup world.

And a few minutes after I went away from my laptop to watch TV, I refreshed my blog.

And it’s Error 500.

And MySQL is down.

Ops. Oh oh.

Then I realised: my site IS trending up in Hacker News.

I’m elated. Electrified is the right word I guess?

So many people want to see what the fuss is all about the blog post but it’s not up?

So how do I get my site back up running again?

And… I did a classic mistake that many made.

I did not activate caching plugin.

Nope. I did not even download it.

What a foolish mistake to make.

I thought of enabling it, but I never bothered to download it in the first place.

I opened the Hacker News link and saw so many people bashing me. (Right now most of the comments have been deleted).

Damn.

I tried rebooting my droplet (I use DigitalOcean)… but it didn’t help much. There is just so many people coming in, even when I restarted it, the MySQL service instantly crashed.

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

No matter how many times I restarted it, the service keeps on failing.

Since I’m unable to get the site up running as usual, I do what I can do: put a placeholder page until I get everything up and running again.

So, I opened up Google cache (thanks Google!) and copied and pasted the article in a HTML file that I did in a haste. Bad formatting and all. Ah, just put it up so that at least people can see it when they opened the blog.

Instead of being greeted by server 500 error, I greet visitors who is coming to my blog with this ugly looking HTML page.

That’s a quite good lesson to learn. I need to have a static site as a failover just in case your WordPress site is down.

I mean, who knows, right? Especially with a small blog that is running on 512MB VM.

Oh well, that’s a start. At least it will free the MySQL from having to serve the people, right?

I waited a bit.

I restarted the droplet again and tried to enter the admin panel again.

Yeay! I can enter the admin panel!

But usually it will crash in just a few seconds after I entered it.

It’s not successful but at least it’s a start.

I replaced the front page with the same HTML and managed to get to the Plugins page.

I added WP Fastest Cache and tweaked some settings.

After that I asked around for advice. I spammed Malaysian Open Source (Sumber Terbuka Malaysia) Telegram group and my friends for any advice they can give for someone in my situation.

One of the tips given by members of that group is I can just use CDN provided by Cloudflare for free. Why, in God green earth did I forgot about that?

That’s the next thing that I did.

I signed up for Cloudflare, followed the instruction, changed the nameservers to Cloudflare’s and also searched for Cloudflare plugin for WP if it exists. (It did, and it is developed by Cloudflare team).

By now, this blog was routinely restarted again and again.

I remembered using MySQL tuner to optimize an exam system that I helped configure and run for my current workplace (Albukhary International University).

So I used it on my blog.

But the sad part is I am running on the lowest plan so most of the suggestions are plain useless. I can’t use it.

I asked myself, can I just upgrade the droplet for a while? The RAM and the CPU just for a little while when the going gets tough?

It turns out that I can do it in DigitalOcean!

So yeah, what I do was, I powered off the droplet and then, I increase the CPU and RAM only. I use the $20/month option.

It’s getting smoother now.

I boot up the droplet and immediately feel the responsiveness of the blog. Right now I am able to browse the admin panel without having the dreaded server 500 error.

So right now, it’s a combination of caching, CDN and just a raw horsepower from bigger CPU and RAM.

How was the traffic, really?

The traffic surge from being in the Hacker News will last for 1 or 2 days.

But you may get new links from unexpected places. Other blogs linking to you or people shared it through their social media account.

So you may get residual traffic from other websites too.

For example, I do get traffic from Reddit.

That’s good for SEO I guess. Google always love links. Lots of it, especially.

For someone who is accustomed with not being seen by anyone, scaling is hard. I have never expected my site to serve thousands of users in under few minutes.

After the fact

After all the dust has settled, I read all the comments at Hacker News that I linked in the first paragraph. A lots of comments… and there are some good advices too!

One of the advice given is to use load testing tool. One of the tools linked is Loader.io. I have never encountered this before, so maybe the next time I ever send my article to Hacker News, I’ll try to use this service first and see how it goes.

And I want to say thanks to all the tips given by members of Open Source Malaysia Telegram group. Another thing that they did was they also told me if my site was down from their sides, which is good. At least I have a realtime feedback of what’s going on from another visitor point of view.

I also want to thank a friend who proofread my blog post few hours after the blog post was hit by Hacker News effect. Or else, the article would read even worse.

Some of the plugins that I mentioned above but too lazy to link to can be easily searched from WordPress Add New Plugin page.

Categories
Musing

What I’ve Learned So Far As a Programmer?

Previously I wrote about how I learned programming. My history with programming.

So today, I would like to share with you what I learned so far as a programmer. Actually most of the lessons I learned in the past 2 years made me realize that I learned more in the past 2 years than many of the years before.

  • Try to learn a new programming language every year

… or at least “dive deep” into learning all features of the language you already know right now

This is important. One of the things I learned this 2 years is that you have to learn something new every year in order to keep up to date. It doesn’t necessarily mastering a new language, but at least try it so that you will be able to expand your understanding of how to program things.

  • Library can come and can go in less than one year…

But language usually lives much longer.

Usually this means that the library is not maintained anymore. This happens when there’s only one maintainer. This usually happened in Android where there are rapid changes from one version to another.

Language on the other hand usually have multiple contributors or maintainers. So they usually lived longer.

  • Learn to learn quickly

This got to be the most important thing I have ever learned. The faster I learn, the more I will be able to create.

Learning quickly is probably one of the single biggest multiplier effect that I can have in finishing project I’m involved in.

  • Try to know exactly what you don’t know…

So that you’ll be able to quickly find a solution for that.

When you are able to learn quickly, you will be able to know what you don’t know. And it become sort of a loop. You’ll be able to know what you want to look for in Google.

  • It doesn’t matter if you don’t know algorithms…

But it doesn’t hurt to learn about it (because it might help you in the future).

This is important. Usually you don’t use algorithm in programming a system but if it’s something that will scale fast, your understanding of algorithm might be useful.

  • Identify exactly what you’re weak at…

And see if you could try to fix your weakness in your understanding of software engineering.

In self-help world you will hear people talk about focus on your strength but in order to develop a technical skill, you need to identify exactly what you are weak at.

For me, I am weak at algorithm because I don’t have a formal engineering background. I come from an information field where I learned mostly about records and library.

  • Break project down into manageable bits

To me, basically a project = big problem statement.

Sometimes you don’t need to do any programming if you have another way to solve that problem.

So you have to break it down into something that you understand. For instance if you want to make a simple archiving system, what do you need?

Obviously you would need a database. a way to create a record, to modify and delete it which is the standard CRUD thing to do.

So by breaking things down into smaller and smaller piece, you will be able to to code it and make the functions required to solve that big problem statement.

I guess that’s all for now. What I’ve learned so far in programming. Obviously I will have more things to learn in the future.

Until next time!

THE BIGGEST LESSON I LEARNED TODAY

Don’t forget to turn on your caching plugin and CDN. I submitted this blog post to Hacker News and this website can’t be accessed.

And I HOPE it won’t crash right after I wrote this. I hope! Haha.