IT Daily Documentation

Use ssh-agent to save ssh passphrase in Window 10

Ref: https://stackoverflow.com/a/52113739

Ref: https://stackoverflow.com/a/18683544

Problem: When using SSH to connect other server, I don’t want to type passphrase everytime:)

For Windows 10 you need PowerShell to active ssh-agent in order to save passphrase.

Solution: First use Administrator right to open PowerShell (Windows PowerShell).

Then enter below command to active ssh-agent:

local Administrator PowerShell 
Set-Service ssh-agent -StnartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent

Then now you can add the key file (My file store in C:\Users\user.ssh\id_rsa), it will prompt a message to obtain the passphrase.

ssh-add C:\Users\user.ssh\id_rsa
(Enter your passphrase)

Eventually, ssh-agent will store your passphrase now. You can also enter

ssh-add -l

to check out the record.

Update npm on Windows 10

ref:https://stackoverflow.com/a/31520672

Problem: Want to deploy node.js, but npm is too old.

Solution: Run PowerShell as Administrator (search “PowerShell”, right click and select Run as Administrator)

then run below command

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade

Detect tag removed using jQuery

Problem: Want to detect a tag like <div>, when it removed, do something.

Solution: Based on this answer, we can use on’ to detect event like‘remove’:

keep in mind that you must add jQuery (v1.9.1 or above) and jQuery UI -(v1.10.2 or above) scripts in it.

For example, I want to detect a tag with class name “test”:

<div class="test">already to vanish</div>

in the jQuery script part, add below code:

$(".test").on("remove", function () {
    alert("Element was removed, do something");
})

Form submit not working due to hidden required field

Problem: As the title stated, the form submit function not working because of the required field that user forgot to fill, and the field itself is hidden like below code:

<input type="hidden" required name="form_field"  >

so the solution will be adding the value into that hidden value.

Remove duplicate after union two collections in Laravel 5

Problem: Having two collections/MySQL query results and combine them using union():

$result1->union($result2);

then want to remove all duplicate on that union result.

Solution: using unique() to remove duplicates. You can add a parameter like unique(‘id’) to specifically remove which tag name. Example:

$result1 = $result1->unique()->values()->all();

Remember to assign it to a variable or else it will remain the same.

Can’t access the website due to permission cause by SELinux

Problem: The folder permission all ready to set the appropriate one (744, etc). but still can not access some page, or some of the pages can not access due to permission denied.

Solution: use chcon -t httpd_sys_rw_content_t folder/ -R, replace folder/ with your folder

chcon -t httpd_sys_rw_content_t folder/ -R

Change localhost to correct domain path in Laravel

Problem: when resetting password or go to other routes, the path should no longer be a localhost but my new domain name. Still, the domain from URL is localhost.

Update .env file to update Laravel domain name

Solution: Update .env file, from APP_URL=http://localhost to APP_URL=https://yourdomain.com

and remember to clean config setting by enter below command:

php artisan config:clear
Close Bitnami banner
Bitnami