-
Software Architecture
-
-
tl;dr
- use with inheritance
- delegation
- composition
- aggregation
- DRY - don't repeat yourself
- How I Declare My class And Why
- use with inheritance
-
SOLID OOP
-
-
Backup + Restore of the system
- Howto: Backup and restore your system!
- Backup:
sudo su cd / tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /
- Restore:
tar xvpfj backup.tar.bz2 -C / mkdir proc mkdir lost+found mkdir mnt mkdir sys etc...
- Howto: Backup and restore your system!
-
Distributed versioning systems
-
git & github & gitlab
-
Git remote access
- [s there a way to skip password typing when using https:// on GitHub?](Is there a way to skip password typing when using https:// on GitHub?)
- How to use git with gnome-keyring integration
- tl;dr
$ sudo pacman -S libgnome-keyring $ pushd /usr/share/git/credential/gnome-keyring $ sudo make $ popd $ git config --global credential.helper /usr/share/git/credential/gnome-keyring/git-credential-gnome-keyring
- Git на сервере - Создание открытого SSH-ключа
- Как настроить подключение к удаленному Git репозиторию
-
Mary Rose Cook on git
-
How to: Delete a remote Git tag
- delete tag
git tag -d v0.2.3 git push origin :refs/tags/v0.2.3
- pushing new tags to remote
git push --tags
-
git checkout tag, git pull fails in branch
git push -u origin master git pull origin master git pull git branch --set-upstream-to=origin/master master git pull git branch -u origin/master git branch --set-upstream-to=origin/master master git branch -u origin/master
-
A Git Horror Story: Repository Integrity With Signed Commits
-
git rebase memo
git rebase origin/master git status <fix conflicts> git add <changed> git rebase --continue git push origin my-branch --force <repeat>
-
aborting & syncing with origin/master
git rebase --abort git merge --abort git checkout -B master origin/master ... git push origin master:master ...
git subtree add -P u-boot /scratch/tegra-sources/u-boot_nvidia_distribution/u-boot master
-
subtree import of the subfolder
git subtree split -P modules/my_module -b temporary-split-branch git subtree add -P prefix-name/ /path-to-repo temporary-split-branch
-
Git - Find when a method is removed
tl;drgit log -c -S'methodName' /path/to/file.cpp
-
two-factor authentication in your Github account leads to inability to push via HTTPS
tl;dr
git remote -v git remote remove origin git remote add origin git@github.com:user/repo.git git push --set-upstream origin master
- git - remote add origin vs remote set-url origin
tl;dr
below is used to a add a new remote:
git remote add origin git@github.com:User/UserRepo.git
below is used to change the url of an existing remote repository:
git remote set-url origin git@github.com:User/UserRepo.git
below will push your code to the master branch of the remote repository defined with origin and -u let you point your current local branch to the remote master branch:
git push -u origin master
-
gitlab
-
-
gcc unsorted question (TODO reorganize)
- list gcc's pre-defined macros
gcc -x c /dev/null -dM -E
- Why doesn't GCC optimize aaaaaa to (aaa)(aaa)?
- list gcc's pre-defined macros
-
Terminal emulators
- A look at terminal emulators, part 1
- A look at terminal emulators, part 2
- 20 Useful Terminal Emulators for Linux
- A tiling terminal emulator for Linux using GTK+ 3
Source vte.sh in bashrc Update ~/.bashrc (or ~/.zshrc if you are using zsh) to execute vte.sh directly, this involves adding the following line at the end of the file. if [ $TILIX_ID ] || [ $VTE_VERSION ]; then source /etc/profile.d/vte.sh fi
-
Editors
-
modern ctags
- A maintained ctags implementation
- Universal-ctags Hacking Guide
- Hong's Technology Blog for ctags for C++
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
-
vim tips :set ff=unix
- Vim: Squeezing the Text Editor’s Juice with More Features
- How I revamped my Vim setup
- Minimalist Vim Plugin Manager
- A guide to setting up Vim for JavaScript development
- You Should Be Using Tags In Vim
- Browsing programs with tags
- Find and replace using regular expressions
- Understanding Vim’s Jump List
- Что вам стоит знать, если вы начали изучение Vim
- Configure coc.nvim for C/C++ Development
pacman -S nodejs yarn yay -S ccls
- A guide to modern Web Development with (Neo)vim
- Vim’s absolute, relative and hybrid line numbers
- Об удобной навигации и отладке C++ кода в Vim
- Vim - open new tab in buffer
- tl;dr
:Te
- From Vim to Emacs+Evil chaotic migration guide
- The Modern Vim Config with Pathogen
- How to setup vim to edit both Makefile and normal code files?
- How to Configure Vim like VSCode
- vim+scala
- VIM and Python -- a Match Made in Heaven
- vim-multiple-cursors
- Provide easy code formatting in Vim by integrating existing code formatters
- Vundle vs. Pathogen
- Разработка → VIM: зачем, если есть IDE, и как?
- Vim vs. Neovim
- Find in files within Vim
- Vim: Substitute pattern between braces
- Neovim 0.5+
- Modern neovim
- Awesome Neovim
- Neovim with LSP and tree-sitter
- nvim tree-sitter config
- LunarVim
- How to set up Neovim 0.5 (LSP, Treesitter, fuzzy finder, etc)
- How to migrate from init.vim to init.lua?
orviB:s/word/replacement/gc
vi{:s...
- The Ultimate Vim Distribution
- Ultimate auto-completion system for Vim
Plugin 'Shougo/neocomplcache' Plugin 'Shougo/neosnippet' Plugin 'Shougo/neosnippet-snippets' Open up Vim and start installation with :PluginInstall
-
YouComplete
tl;dr~/.vim/bundle/YouCompleteMe$ ./install.sh --clang-completer --racer-completer
gpg --keyserver keys.gnupg.net --recv-keys 702353E0F7E48EDB yay -S ncurses5-compat-libs
- "ycmd server SHUTDOWN" error on Arch Linux
- tl;dr
yay -S libtinfo yay -S libtinfo5 :YcmGenerateConfig :YcmRestartServer
- Ubuntu : fatal error: pyconfig.h: No such file or directory # include <pyconfig.h>
- tl;dr
sudo apt install python3-dev python3 install.py --clang-completer --racer-completer
- "ycmd server SHUTDOWN" error on Arch Linux
-
CoC - Conquer of Completion
- Install coc.nvim
- Ubuntu install issues
sudo apt install npm curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update sudo apt install yarn yarn --version 1.17.3
- Fast check after install
tl;dr
tl;dr look into:CocInfo :CocList diagnostics :CocInstall coc-json :CocInstall coc-rls :CocConfig :CocCommand
~/.config/coc
rustup component add rls rust-analysis rust-src
- Ubuntu install issues
- Intellisense engine for vim8 & neovim, full language server protocol support as VSCode
- CoC Language servers : C++
- Install coc.nvim
-
Demystifying multi file searches in
vim
and the command line -
NeoVim specific
- Neovim ArchLinux notes
tl;dr
mkdir -p ~/.config/nvim/ ln -s ~/.vimrc ~/.config/nvim/init.vim
- Neovim ArchLinux notes
-
Can't enter a tab character when previous character is not a tab or space in insert mode
-
Emacs
-
kate-config
-
Atom - The hackable text editor
-
Atom Editor Keyboard Shortcut Cheat Sheet
- Line Manipulation
- ⌘ + ] / [ Indent/outdent current line.
- ⌘ + enter. Insert new line after current line.
- ⌘ + shift + enter. Insert new line before current line.
- ctrl + shift + k. Delete current line.
- ctrl + ⌘ + up/down. Move current line up/down.
- shift + ⌘ + d. Duplicate current line.
- ⌘ + j. Join current and next lines.
- Auto indent code in Atom editor
- TL;DR
Package auto-indent exists to apply auto-indent to entire file with this shortcuts :
ctrl+shift+i
Package url : auto-indent
- TL;DR
Package auto-indent exists to apply auto-indent to entire file with this shortcuts :
- Line Manipulation
-
-
atom/Sublime Style Column Selection
- TL;DR
Platform Modifier Key Mouse Button Linux Shift Left
-
performance issues
-
Slap is a sublime-like text editor which works inside the terminal.
-
Xi-editor - a modern editor with a backend written in Rust.
- GTK frontend for the Xi text editor, written in Rust
tl;dr
yay -S tau-editor-git
sudo pacman -S flatpak ... flatpak install flathub org.gnome.Tau Required runtime for org.gnome.Tau/x86_64/stable (runtime/org.freedesktop.Platform/x86_64/19.08) found in remote flathub Do you want to install it? [Y/n]: org.gnome.Tau permissions: ipc wayland x11 ID Branch Remote Download 1. [✓] org.freedesktop.Platform 19.08 flathub 223.6 MB / 237.7 MB 2. [✓] org.freedesktop.Platform.GL.default 19.08 flathub 90.8 MB / 90.8 MB 3. [✓] org.freedesktop.Platform.GL.nvidia-435-21 1.4 flathub 103.3 MB / 103.3 MB 4. [✓] org.freedesktop.Platform.Locale 19.08 flathub 163.7 MB / 318.9 MB 5. [✓] org.freedesktop.Platform.openh264 19.08 flathub 594.2 kB / 593.4 kB 6. [✓] org.gnome.Tau stable flathub 4.6 MB / 4.6 MB 7. [✓] org.gnome.Tau.Locale stable flathub 45.3 kB / 41.0 kB Installation complete. flatpak run org.gnome.Tau Note that the directories '/var/lib/flatpak/exports/share' '$HOME/.local/share/flatpak/exports/share' are not in the search path set by the XDG_DATA_DIRS environment variable, so applications installed by Flatpak may not appear on your desktop until the session is restarted. Gtk-Message: 23:05:39.139: Failed to load module "canberra-gtk-module" Gtk-Message: 23:05:39.140: Failed to load module "canberra-gtk-module"
- GTK frontend for the Xi text editor, written in Rust
-
MIT online courses
-
Linux distros specific
-
systemd
vs.init
- RHEL7: How to get started with Systemd
- The Story Behind ‘init’ and ‘systemd’: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linux
- ELI5: The SystemD vs. init/upstart controversy
- Systemd Essentials: Working with Services, Units, and the Journal
- Comparison of init systems
- gentoo - systemd
- How does systemd use /etc/init.d scripts?
systemds for
upstart` usersjournald
#include <systemd/sd-journal.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { sd_journal_send("MESSAGE=Hello World!", "MESSAGE_ID=52fb62f99e2c49d89cfbf9d6de5e3555", "PRIORITY=5", "HOME=%s", getenv("HOME"), "TERM=%s", getenv("TERM"), "PAGE_SIZE=%li", sysconf(_SC_PAGESIZE), "N_CPUS=%li", sysconf(_SC_NPROCESSORS_ONLN), NULL); return 0; }
journalctl -o json-pretty MESSAGE="Hello World!"
printf "hola\n\rbro\n\r" | systemd-cat -t HOLA-BRO-SLASH-R journalctl --sync journalctl -b -t HOLA-BRO-SLASH-R --no-pager --no-hostname
- How can I send a message to the systemd journal from the command line?
- How to configure systemd journal-remote?
- LOGGING DONE RIGHT systemd-journal-upload & systemd-journal-remote setup
- log4cplus
- polltest
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <systemd/sd-journal.h> int main(int argc, char *argv[]) { int r; sd_journal *j; r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); if (r < 0) { fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); return 1; } /* Opening the fd now means the first sd_journal_wait() will actually wait */ r = sd_journal_get_fd(j); if (r < 0) { fprintf(stderr, "Failed to get fd: %s\n", strerror(-r)); return 1; } r = sd_journal_seek_tail(j); if (r < 0) { fprintf(stderr, "Failed to seek tail: %s\n", strerror(-r)); return 1; } if (getenv("seek")) r = sd_journal_previous_skip(j, 0); else r = sd_journal_next_skip(j, 0); if (r < 0) { fprintf(stderr, "Failed to skip: %s\n", strerror(-r)); return 1; } r = sd_journal_wait(j, (uint64_t) -1); if (r < 0) { fprintf(stderr, "Failed to wait for changes: %s\n", strerror(-r)); return 1; } for (;;) { const void *d; size_t l; r = sd_journal_next(j); if (r < 0) { fprintf(stderr, "Failed to iterate to next entry: %s\n", strerror(-r)); break; } if (r == 0) { /* Reached the end, let's wait for changes, and try again */ r = sd_journal_wait(j, (uint64_t) -1); if (r < 0) { fprintf(stderr, "Failed to wait for changes: %s\n", strerror(-r)); break; } continue; } r = sd_journal_get_data(j, "MESSAGE", &d, &l); if (r < 0) { fprintf(stderr, "Failed to read message field: %s\n", strerror(-r)); continue; } printf("%.*s\n", (int) l, (const char*) d); } sd_journal_close(j); return 0; }
-
D-Bus
-
Building object-oriented software with the D-Bus messaging system
-
Telepathy
-
[dbus-cplusplus-devel] Proposal: Give objects through dbus-c++
-
dbus-c++ and g++-7.1
- #18 Invalid template code in Threading class
- tl;dr patch '/usr/include/dbus-c++-1/dbus-c++/dispatcher.h'
-
sdbus - and shutdown
- The new sd-bus API of systemd
- systemd-233/src/libsystemd/sd-bus/test-bus-objects.c
- C++ bindings for systemd dbus APIs
tl;dr poweroff
gdbus introspect --system --dest org.freedesktop.systemd1 --object-path /org/freedesktop/systemd1 ... interface org.freedesktop.systemd1.Manager { methods: ... PowerOff(); ...
sudo busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager PowerOff reboot: Power down
#include <stdio.h> #include <stdlib.h> #include <systemd/sd-bus.h> int main(int argc, char *argv[]) { sd_bus_error error = SD_BUS_ERROR_NULL; sd_bus_message *m = NULL; sd_bus *bus = NULL; const char *path; int r; // Connect to the system bus r = sd_bus_open_system(&bus); if (r < 0) { fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r)); goto finish; } // Issue the method call and store the respons message in m r = sd_bus_call_method(bus, "org.freedesktop.systemd1", // service to contact "/org/freedesktop/systemd1", // object path "org.freedesktop.systemd1.Manager", // interface name "PowerOff", // method name &error, // object to return error in nullptr, // input signature nullptr); // 1st arg if (r < 0) { fprintf(stderr, "Failed to issue method call: %s\n", error.message); goto finish; } /* Parse the response message */ r = sd_bus_message_read(m, "o", &path); if (r < 0) { fprintf(stderr, "Failed to parse response message: %s\n", strerror(-r)); goto finish; } printf("Queued service job as %s.\n", path); finish: sd_bus_error_free(&error); sd_bus_message_unref(m); sd_bus_unref(bus); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }
g++ systemd-service-client.cc -o systemd-service-client `pkg-config --cflags --libs libsystemd`
-
WebSockets
- ws: a Node.js WebSocket library
npm install -g ws ...
- ws: a Node.js WebSocket library
-
How to shutdown Linux using C++ or Qt without call to “system()”?
-
profilers
-
gperftools: Fast, multi-threaded malloc() and nifty performance analysis tools
- cpuprofile doc
- pmu tools is a collection of tools and libraries for profile collection and performance analysis on Intel CPUs on top of Linux perf
- Issue 278 in google-perftools: CPU profiler shows function addresses instead of function names
- Instructing configure where libunwind lives: an answer to
#error Cannot calculate stack trace: will need to write for your environment
-
http://milianw.de/blog/heaptrack-a-heap-memory-profiler-for-linux
-
Ubuntu Linux C++ error: undefined reference to 'clock_gettime' and 'clock_settime' : add
-lrt
-
Memory profiling
-
-
purescript - A small strongly typed language that compiles to Javascript
-
Linux From Scratch
-
Docker+Kubernetes+FireCracker
-
Post-installation steps for Linux
sudo usermod -aG docker $USER
-
Configure and troubleshoot the Docker daemon
- Why docker container exits immediately
- tl;dr
run -it --entrypoint=/bin/bash custom-ubuntu-image
- tl;dr
- Why docker container exits immediately
-
Docker - a way to give access to a host USB or serial device?
-
Starting Docker as Daemon on Ubuntu
- tl;dr
sudo service docker restart
-
add-apt-repository: command not found in Docker installation on Ubuntu
- tl;dr docker command to add g++-7 to ubuntu16.04 docker image
apt-get install -y software-properties-common python-software-properties && \ add-apt-repository ppa:ubuntu-toolchain-r/test && \ apt-get -qq update && \ apt-get install -y -qq gcc-7 g++-7 gfortran-7 && \
-
docker run -> name is already in use by container
- tl;dr
docker rm $(docker ps -aq --filter name=CONTAINER_NAME)
- tl;dr
-
How to force Docker for a clean build of an image
- tl;dr
docker build --no-cache -t u12_core -f u12_core .
docker system prune
- tl;dr
-
CLion
-
Jenkins
-
Haskell (see also
pandoc
anddiagrams
links above) -
Test-driven development
- Test-driven development and unit testing with examples in C++
- Google Unit Test
- github repository
- good intro from IBM
- another good introduction
- Google Test Primer
- Google TestAdvanced
- fast deployment in
/usr/local
git clone https://github.com/google/googletest && pushd googletest && mkdir build && cd build && cmake .. && sudo make install
-
Scriptics selected tips
- Is double square brackets [[ ]] preferable over single square brackets [ ] in Bash?
- The most recently changed file.
ls -lrt | grep ^- | awk 'END{print $NF}'
-
Text search-and-replace (grep-like tools)
-
config formats : CSV vs. JSON vs. XML vs. YAML
-
Implementing an update/upgrade system for embedded Linux devices
-
VirtualBox
- VirtualBox on ArchLinux
parted /dev/sda (parted) mklabel gpt (parted) mkpart primary ext4 0% 100% mkfs.ext4 /dev/sda1 tune2fs -L "/scratch" /dev/sda1
- How To Install Ubuntu 14.04.3 LTS On VirtualBox
sudo gpasswd -a <username> vboxusers VBoxManage list usbhost
- VirtualBox on ArchLinux
-
Ext4
- Ext4 Disk Layout
- How to extract raw ext3 inode data from disk?
debugfs
sample session:
debugfs: imap <262328> Inode 262328 is part of block group 32 located at block 1048619, offset 0x0700 debugfs: show_inode_info <262328> Inode: 262328 Type: regular Mode: 0644 Flags: 0x80000 Generation: 933973137 Version: 0x00000000:00000001 User: 1000 Group: 1000 Project: 0 Size: 948 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 8 Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x5809deb8:1af1cef0 -- Fri Oct 21 12:24:08 2016 atime: 0x5809deb8:1af1cef0 -- Fri Oct 21 12:24:08 2016 mtime: 0x5809deb6:00000000 -- Fri Oct 21 12:24:06 2016 crtime: 0x5809deb8:1af1cef0 -- Fri Oct 21 12:24:08 2016 Size of extra inode fields: 32 EXTENTS: (0):1082813
- Determine the size of a block device
- tl;dr with
sudo
#include <linux/fs.h> ... ioctl(file, BLKGETSIZE64, &file_size_in_bytes);
- tl;dr with
-
bash
if [ "${target_partname}" = "" -o "${target_partname}" = "APP" ]; then build_fsimg "$localsysfile" "$fillpat" \ "$rootfssize" "$rootfs_type" "$rootfs_dir"; fi;
is equivalent to more readable
if [[ "${target_partname}" == "" || "${target_partname}" == "APP" ]]; then ...
-
tmux
-
TCP backup
-
The Illustrated TLS Connection Every byte of a TLS connection explained and reproduced
-
- VPP/What is VPP? The VPP platform is an extensible framework that provides out-of-the-box production quality switch/router functionality
- VPP/Pulling, Building, Running, Hacking and Pushing VPP Code
tl;dr
git clone https://USERNAME@gerrit.fd.io/r/a/vpp
-
Data transfer
- So you want to write to a file real fast…
- tl;dr
ssize_t do_sendfile(int in, int out) { ssize_t t = filesize(in); off_t ofs = 0; while(ofs < t) { if(sendfile(out, in, &ofs, t - ofs) == -1) { assert(errno == EINTR); continue; } } return t; }
- high CPU load by 'mmcqd' in Ubuntu
- Copy a file in a sane, safe and efficient way
- Linux function to get mount points
- tl;dr
#include <stdio.h> #include <stdlib.h> #include <mntent.h> int main(void) { struct mntent *ent; FILE *aFile; aFile = setmntent("/proc/mounts", "r"); if (aFile == NULL) { perror("setmntent"); exit(1); } while (NULL != (ent = getmntent(aFile))) { printf("%s %s\n", ent->mnt_fsname, ent->mnt_dir); } endmntent(aFile); }
- How to Get Available Filesystem Space on Linux: a C Function with a C++ Example ```
- So you want to write to a file real fast…
-
packaging
-
lock files
-
misc
- nm vs “readelf -s”
tl;dr
nm -o -D *.so
- fdupes – A Comamndline Tool to Find and Delete Duplicate Files in Linux
- Is there a difference between using pmount and mount?
- How To Quickly Generate A Large File On The Command Line (With Linux)
- How to check programatically if the Ethernet cable is plugged in?
tl;dr
for i in $( ls /sys/class/net ); do echo $i; done dummy0 enx00044b5acf64 ip6tnl0 lo rmnetctl sit0 tunl0 wlan0 for i in $( ls /sys/class/net ); do echo -n $i: ; cat /sys/class/net/$i/carrier; done dummy0:cat: /sys/class/net/dummy0/carrier: Invalid argument enx00044b5acf64:1 ip6tnl0:cat: /sys/class/net/ip6tnl0/carrier: Invalid argument lo:1 rmnetctl:cat: /sys/class/net/rmnetctl/carrier: Invalid argument sit0:cat: /sys/class/net/sit0/carrier: Invalid argument tunl0:cat: /sys/class/net/tunl0/carrier: Invalid argument wlan0:1 for i in $( ls /sys/class/net ); do echo -n $i: ; cat /sys/class/net/$i/operstate; done dummy0:down enx00044b5acf64:up ip6tnl0:down lo:unknown rmnetctl:down sit0:down tunl0:down wlan0:unknown
- nm vs “readelf -s”
-
Maximum length of the textual representation of an IPv6 address?
-
Apache Thrift vs Protocol Buffers detailed comparison as of 2019
-
youtube-dl
-
Can I share a file descriptor to another process on linux or are they local to the process?
-
Take a screenshot of a area in xfce?
xfce4-screenshooter -f
-
Linux refresh
-
AWS