Table of Contents:
- 1. C/C++
- 2. Algorithms
- 3. Design Patterns and OO
- 4. Python
- 5. Rust
- 6. Debugging,Analysis and Performance Tuning
- 7. OS specific
- 8. Unix tips
- 9. make/cmake/configure
- 10. Perforce
- 11. Git
- 12. Editors
- 13. Books
- 14. ICU/Unicode
- 15. REST APIs/JSON
- 16. SQL
- 17. Statistical Analysis and Machine Learning
- CPP: 💥 https://en.cppreference.com/w/cpp
- CPP: https://www.cplusplus.com/reference/unordered_map/unordered_map/
- CPP How to Program: https://cs.fit.edu/~mmahoney/cse2050/how2cpp.html
- C standard library: https://www.cplusplus.com/reference/clibrary/
- Docs: https://gcc.gnu.org/onlinedocs/libstdc++/manual/index.html
- Library test suite for parallel sort: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/testsuite/25_algorithms/pstl/alg_sorting/sort.cc;h=e0c55df404f82dc360cea77ce411511bc2b4e619;hb=HEAD
https://en.cppreference.com/w/cpp/links/libs
Forms the basis of parallel algorithms in latest C++ versions
https://software.intel.com/content/www/us/en/develop/documentation/tbb-documentation/top.html
Introduction: https://www.youtube.com/watch?v=9Otq_fcUnPE
- https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html
- https://johnysswlab.com/the-price-of-dynamic-memory-allocation/
- Syntax cheat sheet: https://github.com/gibsjose/cpp-cheat-sheet/blob/master/C%2B%2B%20Syntax.md
- Data Structures and Algorithms cheat sheet: https://github.com/gibsjose/cpp-cheat-sheet/blob/master/Data%20Structures%20and%20Algorithms.md
- C++ STL quick reference: https://overapi.com/static/cs/STL%20Quick%20Reference%201.29.pdf
from https://www.youtube.com/watch?v=7fGB-hjc2Gc
-
Don’t use C-strings (
char*). Do usestd::string. -
Don’t use C style arrays
type[size]. Do usestd::array/std::vector. -
Don’t use
enum. Do useenum class. -
Don’t use
union. Do usestd::variant. -
Don’t use macros. Do use
constexpror templates. -
Don’t use
malloc/freeornew/deleteor owning raw pointers. Do usestd::unique_ptr. -
Don’t use
NULL. Do usenullptr. -
Don’t return
NULLornullptrto indicate an error. Do returnstd::optionalorstd::expected. -
Don’t use
void*. Do usestd::any. -
Don’t use
typedef. Do useusing. -
Don’t use C style casts (
int). Do usestatic_cast/dynamic_cast/reinterpret_castetc... -
Don’t use
type*andint lengthargument pairs. Do usestd::string_viewandstd::span. -
Don’t use project prefixes (
LIB_function). Do use namespaces (lib::function). -
Don’t use
gotocleanup. Do use RAII. -
Don’t use
unsigned charto represent a byte. Do usestd::byteto represent a byte. -
Don’t use C headers (
#include <math.h>). Do use the C++ version<c*>(#include <cmath>). -
Don’t write C-style out parameters (
T**). Do (if you have to use them) usestd::out_ptr. -
Prefer not to write
for intloops. Do writefor eachloops. -
Prefer not to do pointer arithmetic. Do only do pointer arithmetic if absolutely necessary.
https://www.geeksforgeeks.org/
- SOLID: https://scotch.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-design
- Catalog: https://en.wikipedia.org/wiki/Software_design_pattern
- Cloud Patterns: https://docs.microsoft.com/en-us/azure/architecture/patterns/
- UML: https://www.guru99.com/uml-cheatsheet-reference-guide.html
<> +public -private variable: type
Inheritance: from class: solid line black arrow, from abstract class: solid line white arrow, from interface: dashed line white arrow
Aggregation: white diamond
Composition: black diamond
- 💥 Misc: https://realpython.com/
- python source: https://realpython.com/cpython-source-code-guide/
python -m cProfile -s time circuit.py
Tokens: https://github.com/python/cpython/blob/main/Python/generated_cases.c.h
Py_Initialize();
if ( !Py_IsInitialized() )
{
return -1;
}
printf("doing import math in libbar.so:\n");
PyRun_SimpleString("import math");
printf("import done\n");
Py_Finalize();
- sudo apt-get install python3-dbg
- sudo wget https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz
- on windows use py instead of python
- pip freeze shows everything installed by pip
- pip install uninstall cache purge
- pip show psutil
- To see how python was configured look at sysconfg module: CONFIG_ARGS or python3 -m sysconfig
- pmilosla@pmilosla-ubuntu24:rust> pwd /home/pmilosla/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust pmilosla@pmilosla-ubuntu24:rust> python3 -m http.server Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
- For Rust, this is worth doing (probably can skip the Android related stuff):* https://google.github.io/comprehensive-rust/
- There's also "The Rust Book" which is available online or in book form (feel free to expense that if you ended up buying it): https://doc.rust-lang.org/stable/book/
- valgrind
- cachegrind (find cache thrashing)
- SIGSEGV: http://unknownroad.com/rtfm/gdbtut/gdbsegfault.html
- Cheat sheets: https://darkdust.net/files/GDB%20Cheat%20Sheet.pdf
-
https://cs.brown.edu/courses/cs033/docs/guides/gdb.pdf -
https://beej.us/guide/bggdb/ - step into s step over n finish dir b d 1(delete first breakpoint)
- p $r3 $eax p/x $r3 x/8xw 0x110075770+27048 ([x]/(number)(format)(unit_size=bhwg) )
- gdb tui layout split asm src regs layout next focus next
- p p/x
- ptype ptype /o (offsets)
- p *(struct node *) 0x00000000004004fc
- x addr x/h addr x/20h addr
- info symbol 98765432109876543210 - to see why whats in a register crashes you
- gdb -batch -ex "disassemble/rs mainsub" mux.o | more
- If CTRL-C crashes gdb -> kill -TRAP from another window
- Sometimes you should do (gdb)handle SIGUSR1 pass
- b vec_op_varith<int64_t>
- There is a record and replay mode: https://sourceware.org/gdb/onlinedocs/gdb/Process-Record-and-Replay.html
- and there is also native reverse debugging https://www.sourceware.org/gdb/news/reversible.html
- To do reverse debugging you have to do (gdb) record before you do (gdb)rs (reverse-step)
- multiproc child
- stop on load "pythonint.so"
- step,next,continue
- print variable in hex &x/x h,x,X
- stop at 6920
- stop in PyInit_pythonint
- use /nethome/pmilosla/perforce/iris/latest/modules/pythonint
- sudo dbx /home/pmilosla/iris/IBMCLANGD/bin/irisdb /home/pmilosla/iris/IBMCLANGD/mgr/user/core
- https://www.ibm.com/docs/en/aix/7.2?topic=overview-register-usage-conventions
- stepi listi stepi 4 p $r21
- (dbx) listi 0x100919884,0x100919994
- list FunctionName
- list 7000,7100
- https://www.ibm.com/docs/en/aix/7.1?topic=d-dbx-command
- To see if binary was compiled with -ggdb do: sudo nm -X64 binary | grep ".dwstr"
- For -ggdb, by default it will use non-inline strings, means it will use
.dwstrsection and strings in.dwinfosection will use offsets to thedwstrsection. - For -gdbx, by default it will use inline strings, means, it will not use
.dwstrsection, all strings in.dwinfosection will be inlined in the.dwinfosection.
- with perf: https://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
- with valgrind: https://developer.mantidproject.org/ProfilingWithValgrind.html
- AIX: /opt/IBM/openxlC/17.1.3/tools/ibm-gen-list --objdump=/opt/IBM/openxlC/17.1.3/libexec/ibm-llvm-objdump aeol.o https://community.ibm.com/community/user/blogs/jinsong-ji/2021/11/30/instruction-level-listing-annotation
- start your process doing a heavy loop of what you are interested in
- sudo perf record -F 999 -g -p 2277501 --call-graph dwarf (creates perf.data file)
- sudo perf report
- lsof (procfiles on AIX)
- pmap procmap on AIX
- truss
- strace
- rlimit files, semaphores, stack size
- ulimit
- pldd (procldd -F on AIX)
- genld -ld (AIX)
- proctree on AIX
- iptrace AIX https://unixhealthcheck.com/blog?id=306
- ldd
- otool -L (mac)
- file
- objdump AIX: dump -X64 -t dump -X64 -Hp to see libpath dump -X32_64 -Hov libzstd.a
- strings -a
- restore -qxvf libc++.rte.16.1.0.10.bff to see whats in it
- ProcessMonitor (windows)
- Open Developer Command Prompt for VS2019 dumpbin /dependents (windows)
- dumpbin /IMPORTS:python3.dll pythonint.pyd to see whats being used from a DLL
- ldconfig -p shows the default library location in linux
- kill -l lists all signals
- echo $? gives 128+signum that says what killed you
- sudo kill -TRAP 10486072 to the process gdb is debugging causes gdb to break
- gcc -v
- gcc -dumpmachine
- gcc -march=native -Q --help=target
- gcc -march=aarch64-redhat-linux -Q --help=target
- comm -13 <(gcc -march=x86-64-v4 -Q --help=target | grep -F '[enabled]' | sort) <(gcc -march=znver4 -Q --help=target | grep -F '[enabled]' | sort)
- echo | gcc -v -E - 2>&1 | grep cc1
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=ARES AIX: sudo vmstat -Pall
- Search kernel source: https://elixir.bootlin.com/linux/v5.14.10/source
- Search kernel Docs: https://www.kernel.org/doc/html/latest/search.html
- sudo apt-get update
- sudo apt-get dist-upgrade
- sudo apt-get install --reinstall linux-tools-common linux-tools-generic linux-tools-
uname -r - sudo perf top
- apt list --installed
- yum update yum install yum-utils yum provides gtar yum info tar-1.33-1.ppc repoquery -l tar-1.33-1.ppc
- dnf is replacing yum
- dnf package downgrade:
- sudo dnf --showduplicates list tar
- sudo dnf install tar-1.33-1.ppc
- sudo rpm -ivh python3-3.7.11-1.rpm
- yum list installed | grep python
- repoquery -l rh-python38-python-devel
- dpkg-query -L libssh2-1
- If you have fatal conflicts you may need to wget packages and do rpm -Uvh *.rpm
- If you have conflicting packages and what to wipe dnf and start fresh do this:
- https://community.ibm.com/community/user/power/blogs/jan-harris1/2022/05/25/destroyrpms
- if you dont want to struggle with apport you can do this:
sudo sysctl -qa |grep core_pattern sudo emacs /etc/default/apport sudo systemctl stop apport.service sudo systemctl disable apport.service
sudo emacs /etc/security/limits.conf to have:
* - core -1 sudo emacs /etc/sysctl.conf #kernel.sysrq=438 # Core pattern (core.<executable>.<pid>.<time of core>) kernel.core_pattern = /var/crash/core.%e.%p.%t # Controls whether core dumps will append the PID to the core filename. kernel.core_uses_pid = 1sudo sysctl --system
- if you do want to use apport:
- ls -lh /var/crash/
- apport-unpack /var/crash/_opt_iris_LATEST_bin_irisdb.0.crash /tmp/crash-unpacked/
- gdb /opt/iris/LATEST/bin/irisdb /tmp/crash-unpacked/CoreDump
for example wayland: dmesg journalctl -b -1 -e journalctl --list-boots
/etc/default/grub Then look for a line like this in the opened file: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" It may have other options there as well, but just remove quiet splash and: sudo update-grub
/etc/gdm3/custom.conf
apt install ubuntu-desktop
sudo journalctl -b -1 -e will show the end of the log of the previous boot
sudo /usr/sbin/dhcpcd ens33 renew dhcp address
/usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs/VMSHARE -o subtype=vmhgfs-fuse
Turn vm 3d acceleration off powercfg /powerthrottling disable /path "C:\Program Files (x86)\VMware\VMware Workstation\x64\vmware-vmx.exe" powercfg /powerthrottling disable /path " c:\intersystems\IRIS\LATEST\bin\Iristerm.exe" powercfg /powerthrottling /list
settings->system->dislay->graphics entries for both vmware.exe and vmware-vmx.exe (its in a subdirectory) Both entries specify that vmware must run only on RTX2000 and not the cpu GPU.
sudo su subscription-manager register
- PTFs come from IBM's "Fix Central", while the GA images (with the embedded licenses) come from either Passport Advantage (software sales) or ESS (hardware bundles). https://www.ibm.com/support/pages/fix-list-xl-cc-aix
- command security
1420-012 "/usr/sbin/lsattr" does not exist in the privileged command database.
sudo lssecattr -c /usr/pmapi/tools/pmcycles
/usr/pmapi/tools/pmcycles accessauths=aix.system.pmustat.global innateprivs=PV_PMU_CONFIG,PV_PMU_SYSTEM secflags=FSF_EPS
- lslpp -Lqc
- remove web download pack python sudo installp -u python3.9.base python3.9.test
- remove an MRS package and replace with SP package:
Hope you are using smitty installp command. To downgrade using smitty installp, set below options. Select the “SOFTWARE to install” list by selecting these 3 from the list “openssl.base, openssl.license, openssl.man.en_US”. Bold ones are the ones changed from default values. INPUT device / directory for software . SOFTWARE to install [openssl.base ALL @@I:openssl.base _all_filesets,openssl.license] PREVIEW only? (install operation will NOT occur) no COMMIT software updates? yes SAVE replaced files? no AUTOMATICALLY install requisite software? no EXTEND file systems if space needed? yes OVERWRITE same or newer versions? yes VERIFY install and check file sizes? no DETAILED output? no Process multiple volumes? yes ACCEPT new license agreements? yes Preview new LICENSE agreements? yes - OpenSSL version: You can grep for “grep OPENSSL_CONFIGURED_API config*“ which shows below output grep OPENSSL_CONFIGURED_API config* define OPENSSL_CONFIGURED_API 10002 Whereas in TL1 SP1 you would see output as grep OPENSSL_CONFIGURED_API config* define OPENSSL_CONFIGURED_API 30000
- topas
- nmon n,t, 0,1,2,3,4
- svmon -P 26018054 -O summary=basic,unit=MB
- sudo slibclean -> genkld to see is shared libs still loaded, also genld -ld
- df -Pg disk space left
- oslevel -s (what TL version)
- yum list installed | grep python
- yum install yum-utils repoquery -l
- yum install emacs-nox
- dnf update
- dnf install emacs-nox
- dnf install dnf-utils
- path for all users is in /etc/environment
- dump -h libcrypto.a | grep : to see what versions it supports
- errpnt -a
- ar -X64 -tv /usr/lib/libssl.a How to see whats in an AIX archive bundle
- objdump -dS (from binutils in toolbox sudo dnf install binutils)
- If you have an AIX problem you can type script /tmp/problem.log and do the commands and when finished type exit to generate a log file
- smit failures leave /smit.log around
- serial number for support cases: lscfg -vp|grep Machine/Cabinet
- use the snap tool to report system state to ibm. If you have a core file do 'snapcore <program_exe>' .
- to start dbx under LIBPATH do sudo dbx -E "LIBPATH=../lib:../stubdata:../tools/ctestfw:$LIBPATH" ../bin/genrb
- lscfg -lproc*
- lparstat -i | grep CPU
- also lparstat without args (shows smt4 sometimes)
- bindprocessor -q
- lsattr -El proc0
- sudo pmcycles -m
- sudo smtctl
- lsmcode -c
- lsvg rootvg
- df -g
- lspv
- chfs -a size=1G /opt
- chvg -g rootvg (to detect growing disk)
- cfgmgr detects new added disks
- smitty jfs2
- mount /scratch
- umount /scratch
- Adding a volume to rootvg:
- chvg -t 16 rootvg
- extendvg -f rootvg hdisk0 (alternative)
- smitty mkusr or
- mkuser -a pmilosla
- passwd pmilosla
- Expanding /home:
- lslv hd1
- chlv -x 6000 hd1
- chfs -a size=30G /home
- Using datavg:
- mkvg -y datavg -s 128 hdisk2 (the ones not in rootvg)
- mklv -y datalv -t jfs2 datavg 80G
- lslv datalv
- crfs -v jfs2 -d datalv -m /data
- mount /data
- varyoffvg datavg
- exportvg datavg
- rmdev -dl hdisk1
- importvg hdiskN
Terminology: oslevel -s 7300-00-01-2148 00 is TL 01 is SP 21 is year 48 is the week of the year
remove interm fixes (like the openssl patch): emgr -l emgr -r -L emgr -r -L testifix2
https://www.ibm.com/docs/en/aix/7.2?topic=s-suma-command http://www.unixmantra.com/2013/09/aix-technology-level-tl-update-methods.html https://www.ibm.com/docs/en/power7?topic=upgrade-updating-aix-new-technology-level https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-downloading-fixes-updates
Before you start and OS upgrade make sure you expand these: Check in-house systems, they have it expanded even more
chlv -x 6000 repo00 chfs -a size=20G /usr/sys/inst.images chfs -a size=4G /var chfs -a size=4G /opt chfs -a size=4G /usr
The manual way (dont do this, use smit below) This does the latest SP but not a new TL level: date suma -s "minutes hours * * *" -a RqType=Latest -a DisplayName="Latest fixes" make it 5 minutes into the future: suma -s "45 8 * * *" -a RqType=Latest -a DisplayName="Latest fixes" this will do it every day
suma -l ... until it downloads
After you install dont forget to remove the manual way: suma -d 1 crontab -l root
This upgrades to a new TL the easy way: smit suma type in 7300-01
cd /usr/sys/inst.images/installp/ppc ls -lart (make sure you have new files that suma got) smitty update_all shutdown -Fr
- preprocessor defines: ibm-clang++_r -dM -E - < /dev/null
- dissasembly /opt/IBM/xlc/16.1.0/exe/dis produces a .s file silently
- -blibpath
- -blibsuff:so
setenv CLOUD xx.xx.xx.xx setenv IRIS IRIS-2023.2.0LDEV.133.0-ppc64.tar.gz ssh -i id_rsa root@$CLOUD
openssl version
cfgmgr lsvg chvg -t 16 rootvg extendvg -f rootvg hdisk1 chfs -a size=2G /opt lslv hd1 chlv -x 6000 hd1 chfs -a size=30G /home chfs -a size=1G /tmp chfs -a size=+1G /usr chfs -a size=+1G /var
mkuser -a pmilosla passwd pmilosla
from laptop:
cd /home/pmilosla/projects/ibmcloud/ibm_downloads
scp -r -i id_rsa ibm_downloads root@${CLOUD}:/home/pmilosla
scp -r -i id_rsa
on cloud machine: export PATH=$PATH:/opt/freeware/bin cd /home/pmilosla/ibm_downloads DONT NEED TO DO DNF ON THERE on AIX73 # ./dnf_aixtoolbox.sh -y dnf update (doesnt work because of openssl)
install openssl from bundle you put on there: uncompress openssl-3.0.7.1000.tar.Z tar xvf openssl-3.0.7.1000.tar go to the dir and smitty install (check accept license) f10 to exit when done cat /usr/include/openssl/opensslv.h
Install SSL3 ifix from bundle you put on there: emgr -e testifix2.230116.epkg.Z
dnf update dnf install emacs-nox tar tcsh /opt/freeware/bin/tar now exists
- procmon (https://docs.microsoft.com/en-us/sysinternals/downloads/procmon) can show what ddls are being loaded (you need to filter on pid or name)
- ListDlls dlls in a process /cygdrive/c/users/pmilosla/Downloads/ListDlls/Listdlls64.exe python.exe
- process Explorer http://live.sysinternals.com/ procexp for when you cant see pids in task manager
- DLL dependancy walker: https://github.com/lucasg/Dependencies
- Get-NetIPConfiguration -detailed
- Sysinternals Suite can be gottein in the microsoft store: https://apps.microsoft.com/detail/9p7knl5rwt25?rtc=1&hl=en-US&gl=US
- open Visual studio native x64 shell
- copy in subordinate DLLs your DLL will need (may need to set PATH for run time DLL search)
- cl -c /Zi /W3 test.cpp
- link /debug /MACHINE:X64 test.obj C:\libfavoritedll.lib
- & 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild' .\XXXtest.vcxproj -p:Configuration="Debug" -p:Platform="x64" -maxcpucount
- /P to keep preprocessor
- /showIncludes or true to see whats being included
- Recompile your windows .pyd extension with debug See here: https://docs.microsoft.com/en-us/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2022 and here: https://stackoverflow.com/questions/28805401/debugging-my-python-c-extension-lead-to-pythreadstate-get-no-current-thread and here: https://stackoverflow.com/questions/66162568/lnk1104cannot-open-file-python39-d-lib
- Click on your 3.9.5 python installer and install the debug libraries symbols. Copy python39_d.dll and python39_d.pdb to where your application is. (instance/bin)
- Get the 3.9.5 source code from here for later: https://www.python.org/downloads/source/
- start python3 do os.getpid(), Use procmon to start debugging it since task manager doesnt work https://docs.microsoft.com/en-us/sysinternals/downloads/procmon
xcodebuild -version sw_vers
Install docker: https://docs.docker.com/engine/install/ubuntu/#installation-methods Hello world doesn’t work at first – eventually it started working for me
sudo docker run -it docker/surprise
sudo docker ps -a
sudo docker ls
Networking: https://docs.docker.com/network/network-tutorial-standalone/
sudo ip link set dev docker0 up/down
sudo docker exec -it iris ping -c 2 google.com
Sudo docker exec -it iris ip addr show
sudo docker network ls
sudo docker network inspect bridge
sudo docker network inspect host
sudo docker exec -it iris ls -la /usr/irissys/bin/libirisHLL.so
bash ps -p $$ . /xxx/.podman_setup id cat /etc/subuid podman info
cap-add is to get gdb to work --cap-add=SYS_PTRACE in particular
podman run -name NAME -it -v /nethome/pmilosla:/nethome/pmilosla --cap-add=all docker_image bash
podman ps podman rename c54467946b78 NAME
podman exec -it NAME bash podman start -a -i NAME podman stop <> podman start NAME podman inspect NAME podman exec -it NAME bash podman ps -a podman rm <>
podman cp xxx.tar.gz dd978b62fdd9:/tmp
apt-get update apt-get install gdb emacs strace
dnf install gdb strace
strace -p $$
- A Sysadmin's Unixersal Translator (ROSETTA STONE) : http://bhami.com/rosetta.html
- !-1 last command
- bindkey "^R" i-search-back to make CTRL-R reverse search work in tcsh
- top
- free
- dstat
- iostat
- sudo apt install tmux
- tmux
- export TERM=xterm-256color
- setenv TERM xterm-256color
- tmux ls
- tmux attach-session -t 0
- CTRL-B D (detach)
- nohup ./bld -v kernel//USEUNICODE &
- nohup ./bld -v kernel > /home/pmilosla/nohup2.out 2>&1 &
- disown -a
- tail -f /home/pmilosla/nohup.out
- cmake --build https://cliutils.gitlab.io/modern-cmake/chapters/intro/running.html
- If you use cmake --build instead of directly calling the underlying build system, you can use -v for verbose builds (CMake 3.14+), -j N for parallel builds on N cores (CMake 3.12+), and --target (any version of CMake) or -t (CMake 3.15+) to pick a target. Otherwise, these commands vary between build systems, such as VERBOSE=1 make and ninja -v. You can instead use the environment variables for these, as well, such as CMAKE_BUILD_PARALLEL_LEVEL (CMake 3.12+) and VERBOSE (CMake 3.14+).
CL=nnnnnnn DEST="shelf_${CL}_backup"; mkdir -p "$DEST"; p4 -ztag describe -S -s "$CL" | awk -v CL="$CL" '$1=="..." && $2 ~ /^depotFile/ {print $3 "@=" CL}' | xargs -I{} bash -c 'd="$1"; f="${d%%@=*}"; f="${f#//}"; f="${f////__}"; p4 print -q -o "'"$DEST"'/$f" "$d"' _ {}
- M-: is eval you can then type what hook
- M-x is execute
- ESC is meta key in helm
- emacs -nw starts emacs in non windowed mode (macs homebrew)
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
;;(add-hook 'after-init-hook 'global-company-mode)
(setq package-selected-packages '(lsp-mode lsp-ui yasnippet treemacs lsp-treemacs helm-lsp
projectile hydra flycheck company avy which-key helm-xref dap-mode))
(when (cl-find-if-not #'package-installed-p package-selected-packages)
(package-refresh-contents)
(mapc #'package-install package-selected-packages))
;; sample `helm' configuration use https://github.com/emacs-helm/helm/ for details
(helm-mode)
(require 'helm-xref)
(define-key global-map [remap find-file] #'helm-find-files)
(define-key global-map [remap execute-extended-command] #'helm-M-x)
(define-key global-map [remap switch-to-buffer] #'helm-mini)
; I become scared of what my emacs is doing with these settings
;(require 'eglot)
;(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
;(add-hook 'c-mode-hook 'eglot-ensure)
;(add-hook 'c++-mode-hook 'eglot-ensure)
;;ctl-c ctl-s shows syntactic element
(c-add-style "kernel"
'(
(tab-width . 8)
(indent-tabs-mode . t)
(c-basic-offset . 3)
(c-offsets-alist . ((statement-block-intro . +)
(knr-argdecl-intro . 8)
(defun-open . -1000)
(defun-close . -1000)
(defun-block-intro . 8)
(case-label . +)
(label . -1000)
(statement-cont . +)
))
(hide-ifdef-mode . nil)
(c-comment-only-line-offset . 0)
(comment-column . 64)
(fci-rule-column . 78)
))
(setq gc-cons-threshold (* 100 1024 1024)
read-process-output-max (* 1024 1024)
treemacs-space-between-root-nodes nil
company-idle-delay 0.1
company-minimum-prefix-length 1
lsp-idle-delay 0.1) ;; clangd is fast
(which-key-mode)
(add-hook 'c-mode-hook 'lsp)
(add-hook 'c++-mode-hook 'lsp)
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(require 'dap-cpptools)
(yas-global-mode))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(global-display-line-numbers-mode t)
'(inhibit-startup-screen t)
;'(lsp-ui-imenu-colors (quote ("sky blue" "green3")))
;'(lsp-ui-peek-enable nil)
;'(lsp-ui-sideline-show-hover nil)
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(require 'whitespace)
(setq whitespace-style '(face empty tabs lines-tail trailing))
(global-whitespace-mode t)
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
((c-mode . ((c-file-style . "kernel"))) (c++-mode . ((c-file-style . "kernel"))) ;(c++-mode (eval . (message "Set C++ kernel style")))
- view -> command Markdown All in One Add/update section numbers open preview to the side
- (Stroustrop’s paper about C++ evolution) https://dl.acm.org/doi/abs/10.1145/3386320
- Fedor G Pikus Hands on Design Patterns with C++
- CRUD up some nouns (create/read/update/delete) (post/get/put/delete)
popSD = numpy.std(population)
def stdDev(X):
return variance(X)**0.5
pylab.array or numpy.array.mean()
r_squared:
def rSquared(observed, predicted):
error = ((predicted - observed)**2).sum()
meanError = error/len(observed)
return 1 - (meanError/numpy.var(observed))
If the samples are not random and independent don’t make conclusions……
SEM:
def sem(popSD, sampleSize):
return popSD/sampleSize**0.5
Gaussian: numpy.random.normal(mu, sigma, size)
Area in standard deviation:
for numStd in (1, 1.96, 3):
area = scipy.integrate.quad(gaussian,
mu-numStd*sigma,
mu+numStd*sigma,
(mu, sigma))[0]
print(' Fraction within', numStd,
'std =', round(area, 4))
pylab.plot pylab.hist pylab.table
pylab.errorbar(xVals, sizeMeans,
yerr = 1.96*pylab.array(sizeSDs), fmt = 'o',
label = '95% Confidence Interval')
def genFits(xVals, yVals, degrees):
models = []
for d in degrees:
model = pylab.polyfit(xVals, yVals, d)
estYVals = pylab.polyval(model, xVals)
random.sample(population, sampleSize)
def leaveOneOut(examples, method, toPrint = True):
def split80_20(examples):
If the samples are not random and independent don’t make conclusions……
Survivor bias, non response bias, cherry picking
Clustering (kNearestNeighbor) is Unsupervised Learning Classification (Logistic Regresion and k-means(greedy)) is Supervised Learning: Logistic Regression comes in 2 kinds:
L1: many weights – the point is to drive weights to zero to avoid overfitting if 2 variables are correlated, only one will have weight
L2: spreads weight evenly across correlated variables
def minkowskiDist(v1, v2, p):
"""Assumes v1 and v2 are equal-length arrays of numbers
Returns Minkowski distance of order p between v1 and v2"""
dist = 0.0
for i in range(len(v1)):
dist += abs(v1[i] - v2[i])**p
return dist**(1.0/p)
import sklearn.linear_model
def buildModel(examples, toPrint = True):
featureVecs, labels = [],[]
for e in examples:
featureVecs.append(e.getFeatures())
labels.append(e.getLabel())
LogisticRegression = sklearn.linear_model.LogisticRegression
model = LogisticRegression().fit(featureVecs, labels)
if toPrint:
print('model.classes_ =', model.classes_)
for i in range(len(model.coef_)):
print('For label', model.classes_[1])
for j in range(len(model.coef_[0])):
print(' ', Passenger.featureNames[j], '=',
model.coef_[0][j])
return model
Reciever Operating Characteristic
auroc = sklearn.metrics.auc(xVals, yVals, True)
The Area Under Curve (AUC) metric measures the performance of a binary classification.
In a regression classification for a two-class problem using a probability algorithm, you will capture the probability threshold changes in an ROC curve.
Normally the threshold for two class is 0.5. Above this threshold, the algorithm classifies in one class and below in the other class.
Accuracy, Sensitivity, Specificity, Pos. Predictive Value, Neg Predictive Value
download postgre and pgadmin, it will come with psql, default port is 5432 sudo -u postgres psql SELECT version(); now(); \l list all databases \c colors switch db context to colors db CREATE TABLE colors(ColorID int, ColorName char(20)); INSERT INTO colors VALUES(1,'red'),(2,'blue'),(3,'green'); select * from colors;
- https://developers.google.com/machine-learning/crash-course/classification/accuracy-precision-recall
- https://medium.com/@mikeusru/common-metrics-for-evaluating-natural-language-processing-nlp-models-e84190063b5f
- https://pandas.pydata.org/docs/
- https://docs.scrapy.org/en/latest/ web scraping
- https://huggingface.co/blog/setfit few shot learning (data with no labels)
- https://huggingface.co/spaces/NyxKrage/LLM-Model-VRAM-Calculator
- https://symbl.ai/developers/blog/a-guide-to-quantization-in-llms/
- https://mljourney.com/what-are-the-key-differences-between-traditional-rag-and-agentic-rag/
- Use haystack and llamaindex to support your full agent/RAG workflow
- Precision: true positives out of all all positives TP/TP+FP (FP to zero). Focusing on this metric means you want to drive FP, incorrect detections to zero.
- Recall (sensitivity, true positive rate): correct predictions out of all positives TP/TP+FN (FN to zero) low recall means you are missing true cases, add more examples of positives. Focusing on this metric means you want to drive false negatives, misses of positive cases, to zero.