Skip to content

Instantly share code, notes, and snippets.

@dstrbad
dstrbad / macOS Internals.md
Created May 7, 2023 10:51 — forked from kconner/macOS Internals.md
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

#!/bin/bash
IP="192.168.1.22"
SUBJECT_CA="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=CA/CN=$IP"
SUBJECT_SERVER="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Server/CN=$IP"
SUBJECT_CLIENT="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Client/CN=$IP"
function generate_CA () {
echo "$SUBJECT_CA"
openssl req -x509 -nodes -sha256 -newkey rsa:2048 -subj "$SUBJECT_CA" -days 365 -keyout ca.key -out ca.crt
@dstrbad
dstrbad / install-configure-letsencrypt.sh
Created June 12, 2021 10:03 — forked from craigvantonder/install-configure-letsencrypt.md
Install and configure LetsEncrypt on Ubuntu Server 14.04 & 16.04 (Apache)
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04
# Download the Let’s Encrypt Client
cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto
# Set Up the SSL Certificate
Average: 0 9 0.00 0.14 0.00 0.24 0.14 - ksoftirqd/0
Average: 0 10 0.00 0.17 0.00 0.35 0.17 - rcu_preempt
Average: 0 530 0.00 0.03 0.00 0.00 0.03 - jbd2/mmcblk1p1-
Average: 0 785 0.00 0.07 0.00 0.21 0.07 - haveged
Average: 0 818 0.03 0.00 0.00 0.00 0.03 - connmand
Average: 0 821 4.64 4.47 0.00 0.00 9.12 - kubelet
Average: 0 1416 0.14 0.07 0.00 0.03 0.21 - fail2ban-server
Average: 0 1760 0.42 0.69 0.00 0.35 1.11 - kube-proxy
Average: 0 3436 1.70 0.90 0.00 0.00 2.60 - containerd
Average: 0 4274 0.07 0.03 0.00 0.07 0.10 - systemd-journal
debian@bbb-test:~$ sudo perf stat -e task-clock,cycles,instructions,branches,branch-misses,instructions,cache-misses,cache-references
^C
Performance counter stats for 'system wide':
16,203.12 msec task-clock # 1.000 CPUs utilized
4,332,572,389 cycles # 267393.223 GHz (71.42%)
911,023,486 instructions # 0.21 insn per cycle (71.40%)
98,098,648 branches # 6054350.923 M/sec (71.41%)
30,116,184 branch-misses # 30.70% of all branches (71.44%)
885,259,275 instructions # 0.20 insn per cycle (71.45%)
GODEBUG=gctrace=1,schedtrace=1000
gc 80 @1195.750s 0%: 0.070+217+0.19 ms clock, 0.070+57/63/59+0.19 ms cpu, 24->24->12 MB, 25 MB goal, 1 P
SCHED 1196345ms: gomaxprocs=1 idleprocs=1 threads=18 spinningthreads=0 idlethreads=6 runqueue=0 [0]
debian@bbb-test:~$ wget http://127.0.0.1:10248/debug/pprof/profile?seconds=120
debian@bbb-test:~$ wget http://127.0.0.1:10248/debug/pprof/trace?seconds=120
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
65.66 1.671983 5006 334 60 futex
11.77 0.299775 967 310 epoll_wait
9.24 0.235263 364 647 nanosleep
2.58 0.065766 31 2136 clock_gettime
1.75 0.044623 38 1180 68 read
...
------ ----------- ----------- --------- --------- ----------------
100.00 2.546516 10290 356 total
iostat -xz 1
sar -n DEV 1
sar -n TCP,ETCP 1
debian@bbb-test:~$ pidstat 30 1
Linux 4.19.9-ti-r5 (bbb-test) 02/25/2019 _armv7l_ (1 CPU)
04:59:26 PM UID PID %usr %system %guest %CPU CPU Command
04:59:56 PM 0 26749 3.54 1.62 0.00 5.16 0 dockerd
04:59:56 PM 0 26754 0.44 0.37 0.00 0.81 0 docker-containe
04:59:56 PM 0 26784 0.00 0.07 0.00 0.07 0 kworker/u2:2-flush-179:0
04:59:56 PM 0 28814 10.08 10.79 0.00 20.88 0 kubelet
04:59:56 PM 0 29338 0.51 1.15 0.00 1.65 0 kube-proxy