Power of Eloquence

Working with CSV file using NodeJS

| Comments

I worked with CSV data some years back and I’m always curious to know how well NodeJS handles CSV filesystem in the backend compare with the likes of Java, .NET, Ruby or PHP environments.

As it turns out, I figured you can do things with it in the smallest possible way, by importing the following modules.

let fs = require('fs');
let fastcsv = require('fast-csv');

We have the fast-csv module to handle the CSV data(especially if it’s fairly large dataset thus the chosen module has to be performant-driven) when reading it from the FileStream input like so.

let readableStreamInput = fs.createReadStream('./some-csv-table.csv');
let csvData = [];

fastcsv
    .fromStream(readableStreamInput, {headers: true})
    .on('data', (data) => {
      let rowData = {};

      Object.keys(data).forEach(current_key => {
         rowData[current_key] = data[current_key]
      });

      csvData.push(rowData);

    }).on('end', () => {
      console.log('csvData', csvData);
      console.log('total rows of table', csvData.length);
    })

Know your algorithms and data structures - in any language

| Comments

Not long ago, I spent a month learning the basics on how algorithms and data structures work and their practical use in our daily programming lives for a recent job application for one of the top software companies down under.

In the first place, I never truly appreciate how and why they are important to learn. After working with some startups, agencies and consulting firms for several years, a lot of things I did in my previous work never once find one or two things that data structures and algorithms would come in handy when solving difficult business problems. The mere thought of having to know them is nothing more but boring computer science fundamentals which bear no relevance in today’s modern computing age where technologies are evolving at rapid pace. With today’s computers’ raw computing power such as CPU, memory and speed took care by technology vendors that make such great advances, we never need to worry about making optimizations in our code.

My lingering thoughts on the forefront of web development in 2017 (and beyond)

| Comments

It’s been some time I wrote any post content on my blog. I thought, now, it would be good time to delve into it and share my today’s trail of thoughts how the year 2017 has fared so far this year.

Especially what it means to be in web development of today (and tomorrow).

Having worked as an engineer in web/software for past 5 years or so, I’ve witnessed and observed an amazing churn of events that bring up a plethora of technologies which help us software craftsmen, engineers and designers to drive innovation forward and beyond - by leaps and bounds. Be they come from front-end tech stack, APIs services, back-end, databases, cloud environment etc, etc. Each of these technical aspects has evolved well over time. But - more particularly - it’s the front-end community that’s evolving at an incredible speed of light.

Understanding Ruby Self (Part 2)

| Comments

From my previous post, I discussed the purpose of using self in Ruby and how Ruby object’s scope will change in any given point of its running time. Here I’m writing to illustrate the examples further.

Supposed we have a hypothetical anti-virus scanning software we’re building. The anti-virus software will have the following preventative features that will keep your computer safe from Internet viruses.

And thus to define this class in Ruby, we do the following.

#!/usr/bin/ruby

class VirusScanner
    attr_accessor: list_of_known_viruses
    attr_accessor: list_of_files

    def update(new_list_of_viruses)
        list_of_known_viruses = new_list_of_viruses
    end

    def print_virus_list
        puts list_of_known_viruses
    end

    def scan(directory_to_scan)

        list_of_files = Dir[File.join(directory_to_scan, '**', '*')].reject{|p| File.directory? p}

        while(list_of_files) do |each_file|
            check_for_virus(each_file)
        end
    end

    def check_for_virus(file)
       for a_virus in list_of_known_viruses do
          a_virus
          file.ftype(a)=="file"
       end
    end

end

virusscanner = VirusScanner.new

Getting down with PhoneGap/Cordova(Part 2)

| Comments

And now we’re on the second part of the building mobile apps.

In this part 2 of the series, here I will guide you to why we need persistent storage and which storage technologies should we oughta used for making storing data.

Persistent storage is simply a mean way to keep the state of the data onto computing hardware device, throughout its operating life, without worrying about how it could be become obsolete or corrupted during its stages to be saved upon the device.

When build typical CRUD apps, it’s atypical to think data votality is a must consideration when designing reliable storage capacity that maintains its state.

In this example, since we’re using Javascript-based mobile framework to build our Bizdirectory app, I have the following front-end stack options we could utilise

A) WebSQL

WebSQL is a web page APi for storing database into the browser calling its very own SQL database APIs, which is basically the SQLite database. This gives the developers a bit of flavour how you can neatly write SQL query functions as you would with any traditional relational databases such MS SQL Server or Oracle 10g databases.

The key here is that many common web browser vendors are offering the developers ability to performing data operations within their respective browsers such that you wouldn’t need to think of using backend-service at all. It’s a convenience for front-end to whip up couple of quick sql code on the fly without worrying too much about what’s foreign key care going to be.

Getting down with PhoneGap/Cordova(Part 1)

| Comments

On the first things that any good front end devs love to do when spending time to perfect their front-end craft is be on the lookout for other cool front-end technologies that make best mobile web apps.

There’s certainly been no shortage of good ones out there.

I’m using PhoneGap(also known as Cordova) as the good starting guide for building mobile apps.

Personally, I fell that it’s best starting point for beginning aspiring mobile developers in getting their teeth sink for getting mobile apps up and running, without much in-depth knowledge of mobile languages such as Objective-C and Swift. By accomplishing this, you will get the better feel how you can build great apps using the current knowledge level of your Javascript, HTML and CSS before you decide to take on other mobile app frameworks such as Ionic and Nativescript that I keep hearing so much from the mobile app community.

Tools I use for development

Understanding Ruby Self (Part 1)

| Comments

When really working with scripting object-oriented programming languages such as Ruby, I’d find it’s important get yourself grounded in knowing full grasp of the concepts of class and/or object.

To recap these words, basic understanding required behind these two words is this.

In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions, methods).

From memory of studying computer science several years ago in Java, I remembered along the lines that an object is an instance of the class. Thus the object carries all the initialization of state information within the classes. Many object-oriented programming languages therefore share this route and Ruby is no different.

My first Hello World Post

| Comments

Beginining my first technical blog.

What better way to share my write up a few samples of my favourite programming languages I was exposed to learning years ago since building my first family computer 20 years ago.

Java

Hello World - helloworld.java
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World"); } }

C/C++

Hello World - helloworld.cc
#include <iostream.h> main() { printf("Hello, World!"); }

C#

Hello World - helloworld.cs
public class Hello1 { public static void Main() { System.Console.WriteLine("Hello, World!"); } }