Time for some Lodash action

Please note: Lodash functions may already been implemented on ES6(Ecmascript) so look it up first before commiting. Othwerwise lodash is still a very good utility function for general javascript programming.

I been developing in React for a couple of weeks now and Its starting to make sense to me now. Especially the widely use Redux architecture. As always I ponder if I am doing the right thing or not. One of the questions that pops in my head is.. “There must be a better way of doing this without mocking about?”

I know of lodash but why am I not using it? Well I just need a well written out reference to start. Because to be honest with the VAST libraries available to us, its hard to keep up. Even for an IT person like me and you.

Here as always link to lodash  quick tutorial, the author really made effort for noobs like me to better understand it.

https://colintoh.com/blog/lodash-10-javascript-utility-functions-stop-rewriting

Eloquent helper functions, filters and mutators

I have been looking through the internet how I can make my coding more efficient specially when using Eloquent ORM. Eloquent returns a collection that can be filtered using various helper functions.

I would say how I can make my programming skills be more “functional” instead of the traditional for each loop. Check the link out for using helper functions once collection has been returned.

http://laraveldaily.com/10-less-known-but-awesome-laravel-collections-methods/ 

I will also add Accessors/Mutators basically when you set or access a field value , it will automatically returns a different format. For basic example, $users->firstname original value is “Sarah” if you used an accessor function defined in your model, you can automatically make the value apply any function such as strtolower(value) to make it return lowercase.

I find this link helpful: http://laravel-guide.readthedocs.io/en/latest/eloquent-mutators/#defining-a-mutator 

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");
}).then(function(from_resolve_value{
   // Do anything here
}).catch(function(from_reject_value)){
    // 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 + Y – Deletes a line
Alt + F12 – Opens command line
Alt + J – Go through all same selected words
Alt + left and right – To go through opened documents left or right
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 + T – 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, very useful

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:

http://busypeoples.github.io/post/react-component-lifecycle/

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

https://github.com/buckyroberts/React-Redux-Boilerplate

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.

https://dev.to/svinci/react-js-web-site-example-almost-real-life-like

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:

https://en.wikipedia.org/wiki/ECMAScript

ES6 Features: https://github.com/lukehoban/es6features#modules

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: http://www.edzynda.com/use-laravels-eloquent-orm-outside-of-laravel/ 

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: https://stackoverflow.com/questions/25371871/two-databases-in-eloquent-orm-without-laravel

SQL Server remote access

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

Source: https://stackoverflow.com/questions/11278114/enable-remote-connections-for-sql-server-express-2012

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 (https://webmasters.stackexchange.com/questions/16297/which-comes-first-dns-or-name-servers 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.

OR

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

Source: https://serverfault.com/questions/149509/changing-domain-name-dns-to-redirect-web-traffic-to-one-server-and-leave-mail-t

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. domain.com -> 118.123.9.12

MX records – for email service that only points to domain name. eg mail.domain.com -> 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:
CNAME https://www.web24.com.au/tutorials/cname-records-used

What is ‘@’ record used for:
http://forums.devshed.com/dns-36/mean-setting-dns-settings-636502.html

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.

2017 © Ideas, designs and algorithms