Tuesday, 18 December 2018

jQuery Validation

var validator = $("#signupform").validate({
    rules: {
        firstname: "required",
        lastname: "required",
        username: {
            required: true,
            minlength: 2,
            remote: "users.php"
    messages: {
        firstname: "Enter your firstname",
        lastname: "Enter your lastname",
        username: {
            required: "Enter a username",
            minlength: jQuery.format("Enter at least {0} characters"),
            remote: jQuery.format("{0} is already in use")
Example of custom message error


Thursday, 18 October 2018

Problems Encountered During Cloning


Laravel server 500

Laragon Virtual Host Restart

Sunday, 5 August 2018

Codeigniter - fetch_class( ) and fetch_method ( )

It looks like the following is working in CI 2.1.0
To get the name of the controller in CodeIgniter:
To get the name of the method in CodeIgniter:
Are these methods consider private? Should they be documented if they are public?

Thursday, 2 August 2018

site_url and base_url

Oftently or occasionally way of using site_url and base_url variable

1. site_url

when including inside of "application" folder dealing with accessing view and controllers in codeigniter

2. base_url

when to include assets like js, css and images file from root project folder

Visual Code (Goto Definition) using Php IntelliSense

files > preferences > settings

In user settings :

    "php.validate.executablePath": "C:\\wamp64\\bin\\php\\php7.2.4\\php.exe",
    "php.executablePath": "C:\\wamp64\\bin\\php\\php7.2.4\\php.exe"

Friday, 13 July 2018

array_push() merging multiple array

That's because you're adding a non-object to the last element of the array.
Here i suppose you get an array of objects with the name property
$competition_all = Competition::all();
Here you add a key=>value pair to the last element of the objects array
$newCompete = array('name'=>'Others');
array_push($competition_all, $newCompete);
Here you walk through the array of objects and when it comes to the last element the "$competition_games->name" has no name property
foreach ($competition_all as $competition_games) {
            $this->competition_games[$competition_games->name] = $competition_games->name;
Try something like including a stdclass for it like :
$newCompete = new StdClass();
$newCompete->name = 'Others';
array_push($competition_all, $newCompete);

Merging into New Laravel Collection

resources :


Wednesday, 11 July 2018

Interview Training

connect mysql from cli :

cd  "C:\wamp64\bin\mysql\mysql5.7.21\bin"

C:\wamp64\bin\mysql\mysql5.7.21\bin > mysql.exe -u root

Microsoft .Net  utilities :

1. Entity Framework
2. LinQ .(Net Integrated Query)

Thursday, 14 June 2018

Check if empty in collection

When using ->get() you cannot simply use any of the below:
if (empty($result)) { }
if (!$result) { }
if ($result) { }
Because if you dd($result); you'll notice an instance of Illuminate\Support\Collection is always returned, even when there are no results. Essentially what you're checking is $a = new stdClass; if ($a) { ... } which will always return true.
To determine if there are any results you can do any of the following:
if ($result->first()) { } 
if (!$result->isEmpty()) { }
if ($result->count()) { }
if (count($result)) { }

Monday, 7 May 2018

Date Format to Template and Validation

At Validation

  'dob' => 'required|date_format:"d/m/Y"|before:"2006-01-01"',

At View Template

  {{$submissions->created_at->format("F d, Y")}}


1. https://stackoverflow.com/questions/32080734/laravel-validation-date-does-not-match-the-format?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

2. http://php.net/manual/en/function.date.php

3. https://stackoverflow.com/questions/24441395/how-to-change-default-format-at-created-at-and-updated-at-value-laravel?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

Saturday, 5 May 2018

Return Old Input After Validation

From Controller (UserController)

  $validator = Validator::make($request->all(), [
          'first_name' => 'required|max:100',
          'last_name' => 'required|max:100',
          'gender' => 'required|numeric',
          'dob' => 'required|date|before:"2006-01-01"',
          'email' => 'required|email',
          'mobile' => 'required|numeric',
          'street' => 'required|max:255',
          'city' => 'required|alpha|max:20',
          'state' => 'required|numeric',
          'post_code' => 'required|numeric',
      ], $messages);

      if ($validator->fails()) {
          return redirect()->back()

Thursday, 3 May 2018

Laravel Custom Login Validation

   public function __construct()

  * Get the failed login response instance.
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\RedirectResponse
  protected function sendFailedLoginResponse(Request $request)
      $errors = [$this->username() => trans('auth.failed')];
      // Load user from database
      $user = \App\User::where($this->username(), $request->{$this->username()})->first();
        $errors = ['email' => 'Invalid Email. Please try again'];
        // Check if user was successfully loaded, that the password matches
        // and active is not 1. If so, override the default error message.
        if (!Hash::check($request->password, $user->password)) {
            $errors = ['password' => 'Invalid Password. Please Try again'];


      if ($request->expectsJson()) {
          return response()->json($errors, 422);
      return redirect()->back()
          ->withInput($request->only($this->username(), 'remember'))

Reference :


Monday, 30 April 2018

Redirected after Login or Register

in Login Controller, it was located under Illuminate\Foundation\Auth\AuthenticatesUsers;

then change this function to :

     * The user has been authenticated.
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
    protected function authenticated(Request $request, $user)
      return redirect('/admin');

while for Register Controller, it was located under Illuminate\Foundation\Auth\RegistersUsers;

then change this function to : 

     * The user has been registered.
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
    protected function registered(Request $request, $user)
        return redirect('/admin');

however RegisterController has a constant variable   protected $redirectTo = '/home'; which you can just change their value to your target url.




Saturday, 28 April 2018

Friday, 27 April 2018

Merging Input Request

Often you want to pass value for input type hidden, this can be submitted by merging with another form request to the controller



Wednesday, 25 April 2018

Layer 1 - Physical Layer

Ethernet and Ethernet based cables to make L1 connection happer.


- speeds , cap
- including unshielding twisted-pair (utp) , shielding twisted copper (stp)
- twisting cables minimize the effect of EMI from outside sources
- twisting cables lessens the amount of EMI from going out from cable itself.
- stp easily damaged and cost more
- fibre optic is cost more from copper cable
- have a maximum cable of 100 meters
- switching between ethernet speeds and capabilities would be not problem because
ethernet has standards as below.

copper based standards :
- regularly runs at 10 Mbps
- IEEE name :  10BASE-T
- fast ethernet, clocking at 100Mbps, IEEE name standard is 802.3u (100Base-T)
- normal Ethernet and fast Ethernet use only two pair  of wires out of the four available
- Gigabit Ethernet, bringing 1000Mbps, IEEE name stnadard 802.3ab (1000Base-T)
- while gigabit ethernet use all four pair of wires in the cable
- 10 Gig Ethernet runs at 10Gbps, IEEE name standard is 802.3an (10GBase-T)

the fibre optic standard :
- fiber standards jump right to Gigabit Ethernet, running at 1000Mbps
- network admins call it 1000Base-LX, while IEEE standard is 802.3z

Cable Types 

Crossover and straight through cabling
- for the host to switch connections, we'll need straight through cables, so named because the wires in the cable run straight from a particular pin at the host end to the same numbered pin at the switch end.

-whilst switch to swith connection using crossover cable since transmit ports and receive port needed to be different at one end pin.

- Auto MDI-X  (Automatic Medium-Dependent Interface Crossover), eventually cisco switch got automatic discover cable if newly straight-through cable were set up between two switch. You need to set cisco switch port, set speed, duplex and mdix to auto that port.

**auto mdi-x formula*
same device = crossovercable
not same type of devices = straight-through cable

SW1(config)#int fast 0/1
SW1(config-if)#speed auto
SW1(config-if) #duplex auto
SW1(config-if)#mdix ?
auto Enable automatic MDI crossover detection on this interface
SW1(config-if)#mdix auto

Ethernet Header

Preamble | Start Frame Delimiter (SFD) | Dest. MAC Address | Source MAC Address | Protocol Type

1. Preamble : A seven-byte set of alternating ones and zeroes 10101010, repeated seven times. Used for clock synchronization.

2. SFD : One-byte field set to 10101011, used to indicate preamble's end and that the destination MAC address will immediately follow.

3. Destination MAC Address : The frame's destination.

4. Source MAC address : The frame's  source

5. Protocol Type : Can be IPV4 protocol and occasionally IPV6.

Ethernet Trailer

1. Frame Check Sequence (FCS)
- strictly for error detection, 
2. Cyclic Redundancy Check ( a complex mathematical operation )
- sender arrives at a value by running a cyclic redundancy check against the data contained in the frame, resulting in a numeric value. that value is placed into FCS and the frame is then transmitted.
- the recepient of the frame will run the same CRC against frame's data and compares the answer to that contained in incoming CRC. if the compared values are the same, the frame is non-corrupt and life goes on. otherwise the frame is corrupted and will be discarded.


Also known as single collision domain.
Now to prevent the loss of data and time associated with collisions, Carrier Sense Multiple Access
with collision detection (CSMA/CD) was developed. Here's the CSMA/CD process:

1. before sending data, a host will check to see if any other host is already sending data.

2. if that check reveals another host is sending data, the host backs off for a few miliseconds before it listens to the same wire again. If no one's sending data, the host sends the data signal.

3. if 2 PCs happen to send data at the exact time after listening to the wire, the voltage on the wire itself changes, signaling to the hosts that a data collision has occured.

4. The PCs that sent the data will generate a jam signal, indicating to other hosts that data should not be transmitted at this time.

Disadvatages of hub :

1. high level of delay sensitivity when handling voice and video traffic. (one big collision domain)

2. every single time a host connected to this hub sends a broadcast, every other host on that hub will receive a copy of that broadcast. there is no other way to limit the scope of the broadcast and preventing the unnecessary spreading (propagation) of a broadcast through network.

Quick Review

1. hubs give us one collision domain consisting of all connected hosts, one broadcast domain containing those same hosts, and allow only one host to transmit a time.

2. bridges allow us to logically segment the network and to lessen the size of collision domains, but do nothing to segment broadcast domains.

3. switches bring us one-host collision domains and the capability to logically segment the broadcast domain, although that's not done by defa  ult.

Monday, 23 April 2018

CSS - Simple Hover Effects Button

You can add some animation that capture user attention when they hovering buttons (may applied on cards)

Reference :


Inherit "keyword" css reference

<!DOCTYPE html>
span {
    color: blue;
    border: 1px solid black;
.extra span {
    color: inherit;

Here is <span>a span element</span> which is blue, as span elements are set to be.

<div class="extra" style="color:green">
Here is <span>a span element</span> which is green, because it inherits from its parent.

<div style="color:red">
Here is <span>a span element</span> which is blue, as span elements are set to be.