Blog.PUIUP.NET

It's just my notes, or not?

[Solved] Issued certificate has expired. (client certificate problem)

Problem: $ wget https://www.openssl.org
...
ERROR: cannot verify www.openssl.org's certificate, issued by '/C=US/O=Let\'s Encrypt/CN=R3':
  Issued certificate has expired.
$ curl https://www.openssl.org
curl: (60) SSL certificate problem: certificate has expired

Fix:

1. Run
 $ sudo dpkg-reconfigure ca-certificates
2. Select 'ask'

3. Uncheck items below (use Space key to remove the *)
 - AddTrust_External_Root
 - DST_Root_CA_X3

4. Tab and OK

[Solved] npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'

Problem: when install an npm package in global.
you@computer:~/path $ npm install -g (package)
npm WARN checkPermissions Missing write access to /usr/local/lib
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib' }
...

Solution: configure npm to use a different directory for global installation.

1.Create a directory for global installation: $ mkdir ~/.npm-global 2.Configure npm to use the new directory path: npm config set prefix '~/.npm-global' 3.Add the directory to $PATH in the ~/.profile: echo 'export PATH="~/.npm-global/bin:$PATH"' >> ~/.profile 4.Update your system variables: source ~/.profile Test: Download a package globally without using sudo. npm install -g (something) If it still shows permission error (mac os), run: sudo chown -R $USER ~/.npm-global

[Solved] Docker - failed to start daemon: error initializing graphdriver

Somehow after updating packages, docker won't start anymore.
Trying to start the daemon, it fails.
pi@raspberrypi:~ $ sudo systemctl start docker.service
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.

Trying to run it manually, it terminates and shows an error:
pi@raspberrypi:~ $ sudo dockerd
INFO[...] Starting up
...
...
failed to start daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: overlay2, devicemapper; Please cleanup or explicitly choose storage driver (-s )
We found the problem. It looks like it could not decide it's own storage driver. There are 'overlay2' and 'devicemapper' to choose from.
From Docker's official website [link], the 'overlay2' is recommended.

Let's try to force it to use this one by adding this parameter to the command: "-s overlay2"
pi@raspberrypi:~ $ sudo dockerd -s overlay2
OR use a more readable version: "--storage-driver=overlay2".
pi@raspberrypi:~ $ sudo dockerd --storage-driver=overlay2
INFO[...] Starting up
...
...
INFO[...] Daemon has completed initialization
INFO[...] API listen on /var/run/docker.sock
Now it works.
Press [Ctrl-c] to exit.

We know how to fix it.

TL;DR: We just need to add the parameter to the service script
pi@raspberrypi:~ $ sudo vi /lib/systemd/system/docker.service
Look for a line with "ExecStart" append "--storage-driver=overlay2" to the line, so it looks like this:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --storage-driver=overlay2

Then reload the configuration and start the service
pi@raspberrypi:~ $ sudo systemctl daemon-reload
pi@raspberrypi:~ $ sudo systemctl start docker.service

UDOO NEO - Device Tree Editor - Headless start

No VNC needed

1. ssh to udoo and run 'sudo /opt/dtweb/dtweb-headless.sh'

2. open browser to udoo with port 7533

3. reboot udoo after finish

NS-3 simulation time

  • To get current simulation time:
    ns3::Time mytime = Simulation::Now();

  • To get Time from human time unit
    ns3::Time mytime = Seconds(1.0)

    OR
    ns3::Time mytime = MilliSeconds(1000)

    OR
    ns3::Time mytime = MicroSeconds(1000000)

    OR
    ns3::Time mytime = NanoSeconds(1000000000)

  • To convert the Time to human time unit:
    double seconds = mytime.GetSeconds();

    OR
    int64_t ms = mytime.GetMilliSeconds();

    OR
    int64_t us = mytime.GetMicroSeconds();

    OR
    int64_t ns = mytime.GetNanoSeconds();

Twisted Pairs Ethernet Cables: Categories and Shielding

TP: Twisted Pairs. The wires inside the cable are twisted together.
Cat: Stands for "category".

Twisted Pairs Cables

Type Description Pros. Cons.
UTP Unshielded Twisted Pairs.
No foil or braided shielding.
  • Cheap
  • Flexible
  • Lower signal quality
  • Vulnerability for crosstalk
STP Shielded Twisted Pairs.
Has braided shielding to reduce noise and improve connection quality.
  • Versatile
  • Strong
  • Flexible
  • Bulky
  • More expensive
  • 70-90% of shielding coverage depends on the braid formation.
FTP Foiled Twisted Pairs.
Has foil shielding to reduce noise and improve connection quality.
  • 100% of shielding coverage
  • Lighter than braid
  • Cheaper than braid
  • Less durable than braid
  • Less flex than braid

Cable Category Standard

Category Shielding Max Transmission Speed
(at 100 meters)
Max Bandwidth Note
Cat 5 UTP 100 Mbps 100 MHz Obsolete.
Cat 5e UTP, F/UTP, U/FTP 1 Gbps 100 MHz Common cheap cable.
e = enhanced.
Cat 6 UTP, F/UTP, U/FTP 1 Gbps 250 MHz 10 Gbps up to 55 meters.
Cat 6a UTP, F/UTP, U/FTP, S/FTP 10 Gbps 500 MHz a = augmented.
Cat 7 S/FTP, F/FTP 10 Gbps 600 MHz Not TIA/EIA standard.
GG45 connector
Cat 7a S/FTP, F/FTP 10 Gbps 1,000Mhz Not TIA/EIA standard.
100 Gbps up to 15 meters.
40 Gbps up to 50 meters.
Cat 8/8.1 F/UTP, U/FTP 10 Gbps 2,000Mhz For data center.
Short cable, less than 30-36m.
40 Gbps up to 30m.
RJ45 connector.
Cat 8.2 S/FTP, F/FTP 10 Gbps 2,000Mhz Same as 8.1.
GG45 connector.

tmux - Quick Command Reference

Session

- Start a default Session (with 1 window and 1 pane)
$ tmux
- Start a Session with a custom name
$ tmux new -s <session_name>
- Detach from the current session
Ctrl-b d
- Detach a Session (can choose which Session to detach)
Ctrl-b D
- List all Session
$ tmux ls
- Resume a Session
$ tmux attach -t <session_name>
- Rename a Session
$ tmux rename-session -t <old_name> <new_name>

Window

- New Window (with 1 pane)
Ctrl-b c
- Move to the next Window
Ctrl-b n
- Move to the previous Window
Ctrl-b p
- Move to a Window by number
Ctrl-b <number>
- Rename the current Window
Ctrl-b ,
- Kill the current Window
Ctrl-b &

Pane

- New Pane on the right
Ctrl-b %
- New Pane on the bottom
Ctrl-b “
- Move to Pane
Ctrl-b <arrow key>
- Resize Pane
Ctrl-b Ctrl-<arrow key>
- Maximize Pane (toggle)
Ctrl-b z
- End the current Pane (shell exit)
Ctrl-d
  OR
$ exit
- Kill the current Pane
Ctrl-b x

Other

- List of tmux command
Ctrl-b ?
- Enter scrollback mode
Ctrl-b [
  OR
Ctrl-b PgUp
- Exit scrollback mode
q