There is a scenario where you need to test on iPhone and debug on local.

Oops … we all hate the safari bug !

First is firewall

Click left panel ‘Advanced Setting’

It will open fire wall screen


Why I might do this?

You are on SSH remote login to your Mac to make a user for your colleague.

How you do this?

The dscl command.

dscl .

I prefer interactive session so that I don’t need to prefix anything with sudo dscl . The dot mean ‘here’ at this machine. Here is the step.

sudo dscl .
cd /Users
create user-2
create user-2 UserShell /bin/zsh
create user-2 PrimaryGroupID 20
create user-2 NFSHomeDirectory /Users/user-2
create user-2 UniqueID 502
passwd user-2

For NFSHomeDirectory is home directory, you can create and give perm by

sudo mkdir /Users/user-2
sudo chome user-2:staff /Users/user-2

For PrimaryGroupID , the default for staff is…


Got this error after changing machine and docker-compose up

Meaning this might be issue from different Docker version.

Trailing Slash

Found the problem is from trailing slash, so change docker-compose.yml

-      - ./sftp:/home/user-upload/                                                                                                                                                                     +      - ./sftp:/home/user-upload

Change from user-upload/ to user-upload make this work

Hope this help !


Since url.parse and querystring.parse is deprecated here and here at least since last LTS version 14.

The doc doesn’t suggest alternatives, so I study and found the standard alternative here below:

First on URL

Legacy is url.parse

> url.parse('https://developer.mozilla.org/en-US/docs/Web/API/URL')Url {…


When working with internal services through LAN, we have some problem that we cannot connect to the outside world which we normally connect by Wifi.

Scenario — Expect Result

When going to internal server e.g. the ip 10.200.10.20 use LAN

Otherwise go through Wi-fi

See the interface in my machine with ifconfig

en0 Wifi
en5 LAN

We will config this behavior with route command

Removing LAN default Gateway

Open System Preference > Network

Seeing the LAN tab.

  1. Fill the Red if it is required for your internal services.
  2. Remove the default gateway in Green

Adding gateway

sudo route -n add -host <target_host_ip> <gateway_ip>// Example
sudo route -n add -host 10.200.10.20…

Warning: this is not secure at all, only for testing things out.

Step 1: Create User/pass

and also the home directory for this user

sudo useradd my-temp-user
sudo passwd my-temp-user
sudo mkdir /home/my-temp-user// Grant perm
sudo chgrp my-temp-user /home/my-temp-user
sudo chown my-temp-user /home/my-temp-user

Step 2: Enable password login in SSHD

sudo vim /etc/ssh/sshd_config

Looking for this line, change it from no to yes

PasswordAuthentication yes

Then restart it to take effect

sudo systemctl restart sshd

Step 3: Done test login with the new user

ssh my-temp-user@10.1.2.3

Bingo now we logged in with the new user


Here is the full error thrown from http-proxy-middleware

[HPM] Error occurred while proxying request localhost:3000/foo to http://localhost:3009/ [ECONNRESET](https://nodejs.org/api/errors.html#errors_common_system_errors)

Causes

TLDR;

When sending client --> proxy --> API server

Proxy transform body to JS object and it try to proxy that JS object so it fails.

HTTP is plain text protocol it accept ‘string’ as a body.

https://github.com/chimurai/http-proxy-middleware/issues/171

Solution

Transform that parsed JS object back to JSON string i.e.

[Client]        [Proxy in]    [Proxy out]     [API server]
JSON string --> JS Object --> JSON String --> JS Object

You can do that by adding a hook supported by http-proxy-middleware lib.

options.onProxyReq = (proxyReq, req…

We will learn by making the below layout.

The layout

5 Mins

Grid is the layout structured by row x column.

We specify how many row and column by setting

  1. grid-column-template
  2. grid-row-template

Grid layout is set at the parent (just like flex).

One equal cell is specify by 1fr.

.parent {
display: grid;
grid-column-template: 1fr 1fr;
grid-row-template: 1fr 1fr;
}

For 2x2 grid, the counting work like this:

  1  2  3 <-- column 1,2,3
1 ------- <-- row 1
| | |
2 ------- <-- row 2
| | |
3 ------- <-- row 3

Then we specify the grid start and end by…


Mobile

Most of the time flexbox and other CSS solve the problem.

However, consider the case when the layout should look like this on mobile.

And this view below for desktop.


Credit: wikipedia

Gotchas

File need to end with \n Blank line

Space

Bash need space to evaluate. Thing that look usual in other language can be syntax error in bash.

ERROR command x not found
x = 5
PASS, NO SPACE
x=5

The for loop is separated by space too.

for i in "${arr[@]}"; do; echo $i; doneWork just like
for i in 1 2 3 "foo" "bar"; do; echo $i; done
for i in {1..100}; do; echo $i; done

Compare String vs Int

For number, Bash does not have <,>,<=,>= but rather -lt, -gt, -le, -ge

For string, Bash use =, != for comparing. …

tanut aran

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store