๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€
MacOS ็ณป็ปŸ็›ธๅ…ณ็š„ไธœ่ฅฟ
๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€

CLI

bcal, ๅญ—่Š‚่ฎก็ฎ—๏ผŒ่ฝฌๆข

bcal ่ฟ›ๅ…ฅๆˆ–็›ดๆŽฅไฝฟ็”จ $ bcal <expr> ... :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ˜โœ˜โœ˜ 21-07-22 - 15:24:39
โ•ฐโ”€โ  โ ต bcal                                                                     ~/.doom.d
q/double Enter -> quit, ? -> help
bcal> "(5kb+10mb)"
                                10005000 B

            IEC standard (base 2)

                        9.7705078125e+03 KiB
                        9.5415115356e+00 MiB
                        9.3178823590e-03 GiB
                        9.0994944912e-06 TiB

            SI standard (base 10)

                                   10005 kB
                        1.0005000000e+01 MB
                        1.0005000000e-02 GB
                        1.0005000000e-05 TB

ADDRESS
 (d) 10005000
 (h) 0x98aa08
bcal>

ไฝฟ็”จๆ–นๅผ๏ผŒ้‡‡็”จๅ„็ง่กจ่พพๅผๆ–นๅผ๏ผš

  1. ๆ”ฏๆŒๆ•ฐๅญฆ่ฎก็ฎ—

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    
    $ bcal "(5kb+2mb)/3"
    $ bcal "5 tb / 12"
    $ bcal "2.5mb*3"
    โ•ฐโ”€โ  โ ต bcal "2.5mb*3"                                                           ~/.doom.d
    RESULT
                                    7500000 B
    
                IEC standard (base 2)
    
                            7.3242187500e+03 KiB
                            7.1525573730e+00 MiB
                            6.9849193096e-03 GiB
                            6.8212102633e-06 TiB
    
                SI standard (base 10)
    
                                        7500 kB
                            7.5000000000e+00 MB
                            7.5000000000e-03 GB
                            7.5000000000e-06 TB
    
    ADDRESS
    (d) 7500000
    (h) 0x7270e0
    
    $ bcal "(2giB * 2) / (2kib >> 2)"
    โ•ฐโ”€โ  โ ต bcal "(2giB * 2) / (2kib >> 2)"                                          ~/.doom.d
    8388608
  2. ่ฝฌๆˆๅ…ถๅฎƒๆ ผๅผ๏ผŒๅ•ไฝๅคงๅฐๅ†™ๆ•ๆ„Ÿ

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    
     $ bcal 20140115 b
     $ bcal 0x1335053 B
     $ bcal 0xaabbcc kb
     $ bcal 0xdef Gib
    
     โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ” 21-07-22 - 15:39:04
     โ•ฐโ”€โ  โ ต bcal 20140115 b                                                          ~/.doom.d
     UNIT CONVERSION
                                     20140115 B
    
                 IEC standard (base 2)
    
                             1.9668081055e+04 KiB
                             1.9207110405e+01 MiB
                             1.8756943755e-02 GiB
                             1.8317327886e-05 TiB
    
                 SI standard (base 10)
    
                             2.0140115000e+04 kB
                             2.0140115000e+01 MB
                             2.0140115000e-02 GB
                             2.0140115000e-05 TB
    
     ADDRESS
     (d) 20140115
     (h) 0x1335053
    
     LBA:OFFSET (sector size: 0x200)
     (d) 39336:83
     (h) 0x99a8:0x53
  3. ๆŒ‡ๅฎšๅŒบๅ—ๅคงๅฐ

    1
    
     $ bcal 0xaabbcc kb -s 4096
  4. LBA ่ฝฌๆˆ CHS:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    $ bcal -f l500
    $ bcal -f l0x600-18-0x7e
    $ bcal -f l0x300-0x12-0x7e
    
    # result:
    โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ” 21-07-22 - 15:32:44
    โ•ฐโ”€โ  โ ต bcal -f l500                                                             ~/.doom.d
    LBA2CHS
    LBA:500  MAX_HEAD:16  MAX_SECTOR:63
    CHS: (d) 0 7 60, (h) 0x0 0x7 0x3c
  5. CHS ่ฝฌๆˆ LBA

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
     $ bcal -f l500
     $ bcal -f l0x600-18-0x7e
     $ bcal -f l0x300-0x12-0x7e
    
     # result:
     โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ” 21-07-22 - 15:40:28
     โ•ฐโ”€โ  โ ต bcal -f l0x300-0x12-0x7e                                                 ~/.doom.d
     LBA2CHS
     LBA:768  MAX_HEAD:18  MAX_SECTOR:126
     CHS: (d) 0 6 13, (h) 0x0 0x6 0xd
  6. ๆ˜พ็คบไธ€ไธชๆ•ฐๆฎ็š„2่ฟ›ๅˆถ๏ผŒ10 ่ฟ›ๅˆถๅ’Œ 16 ่ฟ›ๅˆถ่กจ็คบๅฝขๅผ

    b (2่ฟ›ๅˆถ), d (ๅ่ฟ›ๅˆถ), h (16่ฟ›ๅˆถ)ใ€‚

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
     $ bcal -c 20140115
     โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ” 21-07-22 - 15:44:32
     โ•ฐโ”€โ  โ ต bcal -c 20140115                                                         ~/.doom.d
     (b) 0b1001100110101000001010011
     (d) 20140115
     (h) 0x1335053
    
     $ bcal -c 0b1001100110101000001010011
     โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ” 21-07-22 - 15:44:14
     โ•ฐโ”€โ  โ ต bcal -c 0b1001100110101000001010011                                      ~/.doom.d
     (b) 0b1001100110101000001010011
     (d) 20140115
     (h) 0x1335053
    
     $ bcal -c 0x1335053
    
     โ•ญโ”€simon at gcl in ~/.doom.d on nativeโœ” 21-07-22 - 15:42:10
     โ•ฐโ”€โ  โ ต bcal -c 0x1335053                                                        ~/.doom.d
     (b) 0b1001100110101000001010011
     (d) 20140115
     (h) 0x1335053

    ไบคไบ’ๆจกๅผ๏ผš

    1
    2
    
     q/double Enter -> quit, ? -> help
     bcal> c 20140115 # ็›ดๆŽฅไฝฟ็”จๅฏนๅบ”็š„้€‰้กน
  7. ๆ‰ง่กŒ bc, ๅœจไบคไบ’ๆจกๅผไธ‹่พ“ๅ…ฅ b

    1
    2
    3
    4
    
     $ bcal -b '3.5 * 2.1 + 5.7'
     bcal> b
     bc vars: scale = 10, ibase = 10, last = r
     bc> 3.5 * 2.1 + 5.7
  8. ็ฎก้“่พ“ๅ…ฅ๏ผŒ็ป“ๆžœ็ป™ bcal ๅค„็†

    1
    2
    
    $ printf '15 kib + 15 gib \n r / 5' | bcal -m
    $ printf '15 + 15 + 2' | bcal -bm
  9. ไปŽๆ–‡ไปถ่Žทๅ–่พ“ๅ…ฅ็ป™ bcal

    1
    2
    3
    4
    
     $ cat expr
     15 gib + 15 kib
     r / 5
     $ bcal -m < expr

Nix

install:

NixOS - NixOS Linux

Nix on macOS, Made Easy - ็ŸฅไนŽ

MacOS Nix Setup (an alternative to Homebrew)

$ curl -L https://nixos.org/nix/install | sh

ๆ–ฐ็ณป็ปŸไธ่ƒฝๅฎ‰่ฃ…้—ฎ้ข˜๏ผŒๆ— ๆƒ้™ๅˆ›ๅปบ /nix

$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume

Creating volume and mountpoint /nix.

     ------------------------------------------------------------------
    | This installer will create a volume for the nix store and        |
    | configure it to mount at /nix.  Follow these steps to uninstall. |
     ------------------------------------------------------------------

  1. Remove the entry from fstab using 'sudo vifs'
  2. Destroy the data volume using 'diskutil apfs deleteVolume'
  3. Remove the 'nix' line from /etc/synthetic.conf or the file

  ...

Installation finished!  To ensure that the necessary environment
variables are set, either log in again, or type

  . /Users/simon/.nix-profile/etc/profile.d/nix.sh

in your shell.

ๅฎŒๆˆไน‹ๅŽ๏ผš

# simon @ gcl in ~ [20:18:32]
$ nix
Usage: nix <COMMAND> <FLAGS>... <ARGS>...

Common flags:
      --debug                  enable debug output
      --help                   show usage information
      --help-config            show configuration options
      --no-net                 disable substituters and consider all previously downloaded files up-to-date
      --option <NAME> <VALUE>  set a Nix configuration option (overriding nix.conf)
  -L, --print-build-logs       print full build logs on stderr
      --quiet                  decrease verbosity level
  -v, --verbose                increase verbosity level
      --version                show version information

In addition, most configuration settings can be overriden using '--<name> <value>'.
Boolean settings can be overriden using '--<name>' or '--no-<name>'. See 'nix
--help-config' for a list of configuration settings.

Available commands:
  add-to-store     add a path to the Nix store
  build            build a derivation or fetch a store path
  cat-nar          print the contents of a file inside a NAR file
  cat-store        print the contents of a store file on stdout
  copy             copy paths between Nix stores
  copy-sigs        copy path signatures from substituters (like binary caches)
  doctor           check your system for potential problems
  dump-path        dump a store path to stdout (in NAR format)
  edit             open the Nix expression of a Nix package in $EDITOR
  eval             evaluate a Nix expression
  hash-file        print cryptographic hash of a regular file
  hash-path        print cryptographic hash of the NAR serialisation of a path
  log              show the build log of the specified packages or paths, if available
  ls-nar           show information about the contents of a NAR file
  ls-store         show information about a store path
  optimise-store   replace identical files in the store by hard links
  path-info        query information about store paths
  ping-store       test whether a store can be opened
  repl             start an interactive environment for evaluating Nix expressions
  run              run a shell in which the specified packages are available
  search           query available packages
  show-config      show the Nix configuration
  show-derivation  show the contents of a store derivation
  sign-paths       sign the specified paths
  to-base16        convert a hash to base-16 representation
  to-base32        convert a hash to base-32 representation
  to-base64        convert a hash to base-64 representation
  to-sri           convert a hash to SRI representation
  upgrade-nix      upgrade Nix to the latest stable version
  verify           verify the integrity of store paths
  why-depends      show why a package has another package in its closure

Note: this program is EXPERIMENTAL and subject to change.

ๅฎ‰่ฃ… nix-darwin:

1
2
nix-build https://github.com/LnL7/nix-darwin/archive/master.tar.gz -A installer
./result/bin/darwin-installer

้…็ฝฎ๏ผš /Users/simon/.nixpkgs/darwin-configuration.nix

{ config, pkgs, ... }:

{
  # List packages installed in system profile. To search by name, run: $ nix-env -qaP | grep wget
  environment.systemPackages =
    [ pkgs.vim
    ];

  # Use a custom configuration.nix location. $ darwin-rebuild switch -I
  # darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix environment.darwinConfig =
  # "$HOME/.config/nixpkgs/darwin/configuration.nix";

  # Auto upgrade nix package and the daemon service. services.nix-daemon.enable = true;
  # nix.package = pkgs.nix;

  # Create /etc/bashrc that loads the nix-darwin environment.
  programs.zsh.enable = true; # default shell on catalina
  # programs.fish.enable = true;

  # Used for backwards compatibility, please read the changelog before changing. $ darwin-rebuild
  # changelog
  system.stateVersion = 4;
}

้…็ฝฎๆ–‡ไปถๆฏๆฌกไฟฎๆ”นไน‹ๅŽ่ฆๆ‰ง่กŒ darwin-rebuild switch ็”Ÿๆ•ˆใ€‚

ๆ›ดๆ–ฐๅŒ…: nix-channel --update

awesome tools

https://github.com/jaywcjlove/awesome-mac/blob/master/README-zh.md

example:

1
2
<div id="test"></div>
<script src="/path/to/test.js"></script>

Share VPN

Parallel Desktop - Ubuntu share the VPN of host computer.

Ubuntu -> ่ฎพ็ฝฎ -> ็ฝ‘็ปœ -> VPN: Network Proxy, ็ฝ‘็ปœไปฃ็†๏ผš

http/https, socks proxy:

IP: ๅฎฟไธปๆœบ็š„ IP๏ผŒๆŽจ่้…็ฝฎๆˆ้™ๆ€IPใ€‚

PORT: ไปฃ็†ๅทฅๅ…ท็š„็ซฏๅฃๅท๏ผŒๆฏ”ๅฆ‚๏ผš clashX ็š„ 7890/7891

ๅฎŒไบ†ไน‹ๅŽ่ฟ˜่ฆๅœจไปฃ็ ๅทฅๅ…ท้‚ฃๅ…่ฎธไธ‹ๅฑ€ๅŸŸ็ฝ‘่ฟžๆŽฅ๏ผš

/img/tmp/clashx-allow-lan.png

็ช—ๅฃ็ฎก็†

ubuntu

ไฟฎๆ”นๅฎถ็›ฎๅฝ•ๅ’Œไธปๆœบๅ

ๅ‡่ฎพๅฝ“ๅ‰ๅๅญ—ไธบ parallels (ๅฎ‰่ฃ…่™šๆ‹Ÿๆœบ็š„ๆ—ถๅ€™้ป˜่ฎคๆ˜ฏ่ฟ™ไธช), ๅฐ†ๅŸบไฟฎๆ”นไธบ๏ผš simon

  1. $ su , ๅˆ‡ๆข root

  2. $ passwd <user>, ไฟฎๆ”นๅฏ†็ 

  3. $ reboot, ้‡ๅฏ

  4. $ su

  5. $ vim /etc/passwd, ๆ‰พๅˆฐ parallels ้‚ฃไธ€่กŒ๏ผŒ ๅชไฟฎๆ”น็”จๆˆทๅไธบ simon๏ผŒๅ…ถๅฎƒไธ่ฆๅŠจ

  6. $ vim /etc/shadow, ๆ‰พๅˆฐ parallels ้‚ฃไธ€่กŒ๏ผŒๅŒๆ ทๅชไฟฎๆ”น็”จๆˆทๅไธบ simon

  7. $ vim /etc/group, ๆ‰พๅˆฐๆ‰€ๆœ‰็š„ parallels, ไฝฟ็”จ :%s/parallels/simon/g ๅ…จๅฑ€ๆ›ฟๆข

  8. $ reboot, ้‡ๅฏ

  9. $ vim /etc/hostname ไฟฎๆ”นๆˆๆƒณ่ฆ็š„ไธปๆœบๅ

  10. $ vim /etc/passwd ๆ‰พๅˆฐ simon ้‚ฃไธ€่กŒ(่ฟ™้‡Œ็”จๆˆทๅๅทฒ็ป็ป่ฟ‡ไธŠ้ข็š„ไฟฎๆ”นๆˆไบ† simon)๏ผŒ ไฟฎๆ”น็›ฎๅฝ•ๅ

  11. $ cd /home

  12. $ mv parallels simon, ไฟฎๆ”นๅฎถ็›ฎๅฝ•ๅๅญ—

  13. $ reboot, OK.

ๅฏ่ƒฝ็š„้—ฎ้ข˜๏ผˆๆˆ‘ๆฒก้‡ๅˆฐ๏ผ‰๏ผšไฟฎๆ”นไธป็›ฎๅฝ•ๅๆ—ถๅ€™๏ผŒๅชไฟฎๆ”นไบ† /etc/password ่€Œๆฒกๆœ‰็ป™ /home/parallels ้‡ๅ‘ฝๅ๏ผŒๅฏผ่‡ดๅผ€ๆœบๅŽไธ€็›ด็™ป้™†่›ค้ขๅพช็Žฏใ€‚

่งฃ ๏ผš Ctrl+Alt+[F1~F6] ็™ป้™†ๅŽ็›ดๆŽฅไฟฎๆ”น /home/parallels, ้‡ๅฏใ€‚

Ctrl+Alt+F7 ่ฟ›ๅ…ฅๅ›พๅฝขๆจกๅผใ€‚