Javascript: Promise and Closure

So been seeing these two pops up in the Javascript world, and finally gave it time to study what they are.

Closure , basically a term in Javascript where a value in a function is retained. This is when you pass a value to a function and the function itself is returned. The value that you pass to the main function gets stored inside the sub-function. And when its finally time to call the returned (function), every variables stored is kept. See the link below for more information, and skip to 10:00 to actually see whats happening.

Promise a new concept, and only available from EcmaScript 2015 or ES6. It is an object that receives a function with 2 parameters, a resolve and  reject function parameters. Then use the “.then(function(return_from_resove){})” when the promise call the “resolve(pass))” inside it, the “then” will be triggered according to what was called. It is like a true or false ,and to promise to return true or to return false. You use “catch(function(){})” chaining when “reject()” is invoke. Here is a quick snippet of the promise:

let promise = new Promise(function(resolve,reject){
       if(true) resolve("anything");
       else if(false) reject("anything");
   // Do anything here
    // Do anything here

Below are excellent video explaining how it works.

WebStorm/PHPStorm Useful Shortcuts

I have decided to try WebStorm and PhpStorm by JetBrains. I assumed these 2 editors have similar shortcut functionality. Here are my most used shortcuts when developing. This is for my reference only and of course anyone who would like to use this reference, feel free to do so.

Ctrl + click to go the function or variable definition.
Ctrl + W – selection grow and select inside tags and braces
Ctrl + Alt + Right | Navigate forward
Ctrl + Alt + Left | Navigate back
Ctrl + Shift + Backspace | Navigate to last edit location
Ctrl + Alt + J – on selected can be wrap with tag or anything.
Ctrl + ] / [   – Move to code block end/start
Ctrl + N | Go to class
Ctrl + Shift + N | Go to file
Alt + Drag to block select and put your caret or selection in multiple places.
Shift + Shift – looks for files, action and search everywhere
Ctrl + Backspace – deletes the line
Ctrl + Shift + Backspace – where ever you had your last edit will take you to that point.

I started learning React

I have finally gotten to the point where its time for me to dive in to what everybody these days are buzzing about. The Javascript world of front end development. I wanted to learn VUE.js first but knowing how React is just a view I can implement them with any systems available and flexibility is the name of my game.

I love how Im able to implement the things that I know already, for example using PHP and MySQL and just making them work. I have already dived into PHP Frameworks such as Laravel and micro-frameworks plus I got a little bit of taste of Webpack which Im glad I did. There so many dependencies and tools out there that we have to get into that mindset that they are there to make our development a little easier.

Okay here are the links that help me understand how React world works. If you are beginner in React I suggest to start on this one:

Also you might want to have a read about the life cycle of the react components:

And also you might to use this boiler plate to examine the code to have a feel of whats going on.

By the way Redux/Flux is sort of like an architecture for building react web apps. Maybe similar to MVC architecture but of course there are others out there but in this scenario will stick with the popular ones.

Once you brushed up and like have a firm grasp on react, you might want to do some more example and readings. Heres a good example of one.

Links of course is credit to the Author , I wouldnt have the knowledge I have now without them.


Javascript Galore ECMAScript

I have been using javascript on my day to day development but never really tried to analyze the standardization of things and the separation between versions over the years.

This is to remind myself that javascript has evolved to a really mature scripting language for the browser. Also a reminder when somebody says ES6 it actually means EcmaScript2015, just minus the number by 1 for example ES7 means Ecmascript2016.

Here below are some reading materials especially new features every iteration:

ES6 Features:

Love at first Laravel Eloquent

Its been a while since I posted been a month it seems?

Well I have been doing a lot of developing and I just love Laravel’s Eloquent component. When doing small web applications, you dont wanna go full Laravel on that stuff. You would wanna just go small like Lumen small, when I say Lumen like micro-framework Lumen. Laravel is a full blown framework, if you just want a small application you can never go wrong with a micro-framework, there are a lot out there. Im currently working on Slim 2 Framework although very old, I needed it to support really old PHP 5.2.

I have learned alot, on my first month on the job. Namely composer and Im using alot of package manager lately. NPM and bower front end development stuff. But anyways I would like to share you links on how to make ORM Eloquent and using 2 databases without Laravel altogether.

First is how to use Eloquent ORM on your own project follow this link: 

Then how to use 2 database connections, this is really big if you are using SQL Server and MySql hand on hand you need to be able to switch between your eloquent database. Follow link:

SQL Server remote access

I just found a gem of a post in how to make Sql Server talk to anyone in your network!


I will definitely go back to this everytime I want access to a database in our network.

Basically, this will show us how to set up SQL Server so that any program on the network is allowed access to its content given they have the right user access to it. It has something to do with enabling Sql Server browser and enabling TCP/IP connection.

Understanding DNS, Nameservers and Record types

Are you a web developer, who mainly focuses on developing your application? Do you only just update your nameserver and point to your hosting company at the registry and think everything will just work with no hiccups and go on your business coding? If yes then dont be that developer as I was.

Nameservers comes first! 

You have to understand this bit to understand everything else in the DNS realm ( link to the article) .  I have spent my night trying to uncover this puzzle basically there is 2 entities that you will likely come across when dealing with DNS, the Domain Registry(where you bought your domain) and your Web Host DNS manager(your webhost).

When you change your nameservers to your new hosting, you are basically saying to delegate all DNS records to that server thus allowing your new web host to handle your DNS or RR(Resource Records). Your Domain Registry will be free of responsibility when it comes to other records you have on it. I am saying the A , AAAA, MX records etc. These records will now be handled by your web host dns manager.

Very important if you have existing RR in your domain registry make sure you leave them be until you actually know whats happening and make sure you read this blog post before committing. So what you can do is to copy all your resource records from your original DNS to your hosting company, which to be honest is I dont like doing because a lot things can go awry when you get it wrong and will take time for it to get right.


Create an A record for your to point to the IP address of your hosting company. Then create an MX record for that to point to your current DNS, then do the rest for every RR you have, that includes FTP, SFTP sub-domains.


So there you have it! If you are wondering what those records do here is a quick rundown below.

A records – translate domain name to IP address eg. ->

MX records – for email service that only points to domain name. eg -> A record.

CNAME record – an alias to another name record or domain name.

AAAA record – A record but points to IPv6 instead of IPv4

More info:

What is ‘@’ record used for:

Windows: Do everything with shortcuts!

When working on your chosen OS, we tend to do repetitive work using our mouse. The time to move the mouse to the direction of the icon you wanna click is more effort than pressing 2 to 3 keystroke on the keyboard. So what do someone like us lazy people do to make this effortless and hopefully avoid injury to our hands in the future? Shortcuts! Here I will list my most used chores on windows that I often find doing.

Changing Explorer View
CTRL + SHIFT + 1 Extra Large
CTRL + SHIFT + 2 Large Icons
CTRL + SHIFT + 3 Medium Icons
CTRL + SHIFT + 4 Small Icons
CTRL + SHIFT + 5 List
CTRL + SHIFT + 6 Details
CTRL + SHIFT + 7 Tiles
CTRL + SHIFT + 8 Content

Using RUN command with WIN + R key:
cmd  To open cmd line.
start + . Type this comment to open current working folder in windows explorer
Press win key , type cmd press ctrl + shift + enter Run as administrator.
services.msc  Open services window
control  Open control panel
ncpa.cpl  Open network connections
regedit Registry Editor
shift + F10 To display right click on any object selected
appwiz.cpl Very handy to open Add/Remove program

Open CMD on any window explorer open:
alt + d and type cmd This will open command line in that folder

Editing Text
shift + up or down – To select whole line or below line.
shift + home or end – to select from cursor left and right, very useful

Navigating Windows Explorer
F6 Very handy to navigate to different elements of the window like the left panel to get the drive you want
alt + DMove focus to the address bar and select current path.
ctrl + N Open new window on the same folder
Alt + Right Arrow Go forward.
Alt + Left Arrow Go back.

Paper sizes people!

Okay I just added a new category on my blog. Hello Printing! This is due to the fact that I have started in a new role and its an Industry that I have never dealt with before!

For most part its a marketing business that deals with all sort of things pertaining to the subject. And majority of the company deals with marketing print jobs such as flyers, brochures, letterheads, invoices etc. Mainly direct mails!

One thing you will want to know are of course the ‘stocks’ as the commercial term for papers!

Anyways first off you will definitely want to familiarize yourself with paper! We all know about A4 and A3 sizes but never really thought about what the numbering means. And to be honest I would never in my programming experience ever think about this stuff, but to effectively do my job there, I gotta to know this otherwise Im just shooting blanks!

In summary A letter is actually a standardize ISO 216(International Organization of Standardization) for paper. And there is a B which isn’t widely used but mostly good for posters, then there is the C, which I did not know anything about! Envelopes!

So if you are ever lost with the measurements and terms when it comes to paper sizes come back to this page and here is the link to make you come back home. And yes I am talking to myself here.

Below the link to paper sizes and a very informative website indeed:

Credit and big thanks to the author.

PS: You might also want to know about RA or SRA papers such as SRA3 for A3, these are untrimmed papers for cutting A3 bleeds but that is another post altogether!

Untrimmed Raw Format (RA and SRA)

Port forwarding and Software Update Implementation

Port Forwarding
I was trying to set up remote access to my router from outside world(I have done it before) and have access to network drive and for the love of me, could not seem to get it to work.

It is so easy for a long time of not doing it and understanding how they all work, your way of thinking just shifts and completely throw you off balance. You know how they work and such but you just need that one sentence to explain it all until… I only needed to see one picture.

Simple illustration of how port forwarding works.

And everything just became clear and smooth sailing!

Software Update Implementation
As you write software and programs and such, you think how do they actually perform an update onto itself, so I went and ask Google. Its actually pretty basic in terms of step by step process, although if you are only making a small simple program sometimes the technology you are using have it figured out for you.

Just like program in C#.NET, they have the ClickOnce installer where you can upload your package to a server and have it check by the computer if you have the latest version of the application. You can either go that way or a  more traditional route.

Have a separate process in your program that checks the server if you have the latest version installed, and allow the program to download the new version. Then ask the user to install the new version or have it closed and let the updater do the job for you by replacing all necessary files. An will run the newly updated program to continue.

For more information about this topic:

2017 © Ideas, designs and algorithms