Posts

MacOS VNC Screensaver fix

defaults write /Library/Preferences/com.apple.PowerManagement.{UID}.plist "AC Power" -dict-add "System Sleep Timer" 0 defaults write /Library/Preferences/com.apple.PowerManagement.{UID}.plist "AC Power" -dict-add "Display Sleep Timer" 0

Tumbleweed post install.

  hostnamectl set-hostname name zypper install -t pattern devel_basis zypper install cmake

Acer Aspire E15 grub fix

Taken from:  https://askubuntu.com/a/630662 Recently, I bought an Acer Aspire ES1-512 for a college course. As it happens this course requires the students to use Ubuntu. After several unsuccessful attempts to install Ubuntu alongside Windows. I believe I have an answer that allows you to install Ubuntu 14.04.2 alongside Windows 8.1 on an Acer Aspire ES1-512. Some of the steps are from memory, so if something doesn't work please let me know. Steps for Installing Ubuntu: Turn on the laptop and press F2 as soon as you see the "Acer Explore Beyond Limits" screen. This will take you into the UEFI/BIOS screen. If this is the first time you have entered the UEFI/BIOS section there are some adjustments that need to be made. Using the cursor keys highlight the menu item "Main." Network Boot: [Disabled] F12 Boot Menu: [Enabled] D2D Recovery: [Enabled] Wake on LAN: [Disabled] SATA Mode: [AHCI Mode] Touchpad: [Advanced] xHCI Support: [Enabled] Cursor over to the "Secu

Dearpygui resizable table

Resizable table using main window resize as redraw trigger. Create an item_resize_handler that calls the table redraw, and bind the main window to it. import dearpygui.dearpygui as dpg import random import string DEBUG = 1 def generate_entries():     entries = []     for x in range(1, 10):         entry = {}         for y in ["A", "B", "C", "D", "E"]:             entry[y] = "".join(random.SystemRandom().choices(string.ascii_uppercase, k=6))         entries.append(entry)     return entries def draw_entry_table(parent, entries):     if dpg.does_item_exist("entry_table"):         dpg.delete_item("entry_table", children_only=False)        table = dpg.add_table(         tag="entry_table",         header_row=True,         parent=parent,         resizable=True,         borders_outerH=True,         borders_innerH=True,         borders_outerV=True,         delay_search=True,         policy=dpg.mvTable_Sizi

Local package cache setup

 Opensuse: uses squid. /etc/sysconfig/proxy PROXY_ENABLED="yes" HTTP_PROXY="http://192.168.1.118:3128/" Ubuntu: uses apt-cacher-ng. /etc/apt/apt.conf.d/02proxy Acquire::http { Proxy "http://fileserv:3142"; }; Arch: uses nginx. /etc/pacman.d/mirrorlist Server = http://fileserv:8080/archlinux/$repo/os/$arch

Python environment

asdf python poetry python3 -m pip install --user pipx python3 -m pipx ensurepath pipx install black pipx install mypy pipx install flake8

Platformio Config

[env:nodemcuv2_client] platform = espressif8266 board = nodemcuv2 framework = arduino upload_port = COM11 monitor_port = COM11 monitor_speed = 115200 build_flags = -D CLIENT -save-temps=obj -fverbose-asm  ;-D L_DEBUG [env:nodemcuv2_server] platform = espressif8266 board = nodemcuv2 framework = arduino upload_port = COM8 monitor_port = COM8 monitor_speed = 115200 build_flags = -D SERVER  ;-D L_DEBUG

Pktmon commands

pktmon filter add -p 4120 pktmon start --etw -m real-time pktmon filter remove ncat -lnuvx -p 4120

Update calibre server

service calibre stop rsync -av --no-p --modify-window=2 /Volumes/Local/ebooks/Calibre\ Library/ /Volumes/ebooks/Calibre_Library /

Poetry and Docker

poetry install --no-dev poetry shell pip list --format=freeze > requirements.txt Delete project from requirements.txt. Update Dockerfile. Delete any existing containers. docker build -t command_name .

Vim tips

Pad lines with spaces:  : %s/.*/\=printf('%-63s', submatch(0))

Opensuse Leap to Tumbleweed

 Edit /etc/sysconfig/proxy. zypper up zypper lr zypper mr -d repo-backports-update zypper mr -d repo-sle-update zypper lr mkdir /etc/zypp/repos.d/old mv /etc/zypp/repos.d/*.repo* /etc/zypp/repos.d/old zypper ar -f -c http://download.opensuse.org/tumbleweed/repo/oss repo-oss zypper ar -f -c http://download.opensuse.org/tumbleweed/repo/non-oss repo-non-oss zypper ar -f -c http://download.opensuse.org/tumbleweed/repo/debug repo-debug zypper ar -f -c http://download.opensuse.org/update/tumbleweed/ repo-update reboot to level 3. zypper cc -a && zypper ref && zypper dup --allow-vendor-change rpm --import https://dl.google.com/linux/linux_signing_key.pub zypper addrepo https://dl.google.com/linux/chrome/rpm/stable/x86_64 Google-Chrome zypper ref zypper install google-chrome-stable rpm --import https://packages.microsoft.com/keys/microsoft.asc zypper addrepo https://packages.microsoft.com/yumrepos/vscode vscode zypper ref zypper install code

Figlet temp command

  watch -n 15 "curl -s basement:4455/temp?params=0 | grep -P -o '\d\d\.\d\d' | figlet -w 120 -d /usr/share/figlet/contributed/ -f doh"

C Notes

#include <stdio.h> #include <string.h> int main(void) {     char f[] = "++++";     char c;     char m[11];     int i;     int o_size = 4;     int i_size = 1;          scanf("%c", &c);     memset(m, c, 10);     m[10] = 0;     for (i = 0; i < 5; i++) {         printf("%.*s%.*s%.*s\n", o_size, f, i_size, m, o_size, f);         o_size -= 1;         i_size += 2;     }     return 0; } e.g.: ends_with(filename, ".pdf.epub.mobi"); int ends_with(const char *string, const char *tail) {     const char *s1;     const char *s2;     if (!*tail)         return 1;     if (!*string)         return 0;     for (s1 = string; *s1; ++s1);     for (s2 = tail; *s2; ++s2);     if (s1 - string < s2 - tail)         return 0;     while (*--s1 == *--s2) { if (s2 == tail) return 1; } return 0; } faster bsearch: int monobound_bsearch(uint8_t *key, Digest_t **array, size_t nmemb, size_t size, int (*cmp)(const void *, const void *)) {     size_t mid, top, p

Crystal notes

(0..10).step(2) do |x|      puts x end --- x = ["the","end","game"] x[0..1].each() do |y|      puts y end --- # times method 2.times do |n|      puts n end --- # upto method 0.upto(1) do |n|      puts n end --- For ranges it's simple: x..y defines a range from x to y inclusive and x...y defines a range from x to y exclusive. So if you want the same behavior as times use 0...n. For x.upto(y) there is only one version which will iterate upto and including y.

SQLite3 Regex

sudo apt install sqlite3-pcre sqlite3 /data/DBases/2022-01-housetemps.db -cmd ".load /usr/lib/sqlite3/pcre.so" "SELECT bed,downstairs,InsertedDatetime FROM housetemps WHERE InsertedDatetime REGEXP '\d\d\d\d-\d\d-1[4,5]';"

Nodemcu flash commands

esptool.py.exe erase_flash esptool.py --baud 460800 write_flash --flash_size=4MB -fm=dout 0 esp8266-20210902-2MB-v1.17.bin

Setup housemon

 Based on Ubuntu 20.04: sudo ufw status sudo ufw default allow outgoing sudo ufw default deny incoming sudo ufw allow ssh sudo ufw enable sudo ufw status sudo apt-get install fail2ban sudo service fail2ban status sudo vim /etc/fail2ban/jail.local [DEFAULT]  bantime = 8h  ignoreip = 127.0.0.1/8 xxx.xxx.xxx.xxx  ignoreself = true  [sshd]  enabled = true  port = 22  filter = sshd  logpath = /var/log/auth.log  maxretry = 3 sudo systemctl restart fail2ban sudo iptables -L f2b-sshd --line-numbers sudo service fail2ban status sudo iptables -L f2b-sshd --line-numbers sudo iptables -L Install python via asdf. Install poetry. Install nginx. Copy hm_server.tgz to server. Untar hm_server.tgz in /opt/services. sudo chown -R userx:userx /opt/services/hm_server cp configs/hm_server.conf /etc/nginx/conf.d cp configs/hm_server.service /etc/systemd/system/ Edit configs/hm_server.service for appropriate user. sudo usermod -a -G www-data userx cd /opt/services/hm_server  python -m venv venv; . venv/bin/ac

Syncthing install Ubuntu 20.4

curl -s https://syncthing.net/release-key.txt | sudo apt-key add - echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list sudo apt-get install apt-transport-https sudo apt-get update sudo apt-get install syncthing sudo apt install daemonize For WSL 2: (issue in admin Powershell) netsh interface portproxy add v4tov4 listenport=22000 listenaddress=0.0.0.0 connectport=22000 connectaddress=xxx.xxx.xxx.xxx netsh interface portproxy add v4tov4 listenport=21027 listenaddress=0.0.0.0 connectport=21027 connectaddress=xxx.xxx.xxx.xxx connectaddress from ip addr in WSL 2. Open both ports for UDP and TCP in Defender.

Cmake compile

 cd to top subdirectory. CXX=/opt/gcc-11.2.0/bin/g++-11.2 cmake . make

mp3splt

mp3splt -t 5.00 -a -d . mp3splt -S 2 -d .  a=1; for i in *.mp3; do   new=$(printf "%04d.mp3" "$a");   mv -i -- "$i" "$new";   let a=a+1; done;

Xonsh installation.

python3 -m pip install --user pipx python3 -m pipx ensurepath pipx install xonsh pipx inject xonsh pygments prompt-toolkit setproctitle

GCC 10.2 Ubuntu

sudo apt install build-essential wget m4 flex bison libgmp-dev libmpfr-dev libmpc-dev mkdir src && cd src tar -xvf ../gcc-10.2.0.tar.xz cd gcc-10.2.0/ mkdir build && cd build ../gcc-10.2.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/opt/gcc-10.2.0 --enable-checking=release --enable-languages=c,c++,d,fortran,go --disable-multilib --program-suffix=-10.2 make  -j 12 make install-strip export PATH="$PATH":/opt/gcc-10.2.0/bin export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/opt/gcc-10.2.0/lib64 export CC=/opt/gcc-10.2.0/bin/gcc-10.2 export CXX=/opt/gcc-10.2.0/bin/g++-10.2 https://solarianprogrammer.com/2016/10/07/building-gcc-ubuntu-linux/

FT-8800 Cheat Sheet

Set CTCSS: [SET] key -> Menu #40 -> Press dial ->               Select tone -> [SET] key. Program memory: In VFO, set up params -> Hold [SET] key ->               Select memory -> [SET] key. Memory delete: Hold [SET] key -> select memory ->               [SCN] button. Memory to VFO: Select memory -> hold [SCN], "MT" appears ->               hold [V/M].

Install Node / Yarn / ReasonML

asdf plugin-add nodejs asdf list-all nodejs bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring asdf install nodejs 12.16.3 asdf global nodejs 12.16.3 npm install -g yarn yarn global add bs-platform

Install Opam

apt install bubblewrap mercurial darcs sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) opam init

Ubuntu / Arch packages for python source install

sudo apt install wget build-essential sudo apt install libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev uuid-dev tk-dev pacman -S openssl zlib ncurses readline sqlite3 gdbm db bzip2 gcc-libs expat xz libffi libutil-linux tk zypper install zlib-devel ncurses-devel readline-devel gdbm-devel sqlite3-devel libbz2-devel  db bzip2 expat xz-devel libffi-devel tk-devel libopenssl-devel env PYTHON_CONFIGURE_OPTS="--enable-shared" asdf install python 

x11vnc

x11vnc Execute on machine to be shared as normal user: x11vnc -bg -nevershared -tightfilexfer -usepw -display :0

Fixing DNS Resolution problems with Linux Mint 19

Fixing DNS Resolution problems with Linux Mint 19 Linux Mint 19 has an issue (at least on the machines I've installed it on) where resolv.conf has its nameserver entry pointing to 127.0.0.53. That works fine except for resolving local subnet names (in my case 196.168.1.x). The following fixes the symptoms, though I still don't know why 127.0.0.53 is being used instead of the assignment from DHCP. Run in root console, or sudo: # apt install resolvconf # nano /etc/resolvconf/resolv.conf.d/tail nameserver 192.168.1.1 # resolvconf -u This will tag the local nameserver entry onto the end of resolv.conf and persists through resets.

Create a new repo

Create a new repository Generate a local git repo in the project working directory: git init . SSH to remote server create a bare repo using the project name: ssh tim@fileserv git init --bare /files/git/xxxxxxx exit Add the files to be tracked and commit: git add blah.c git commit -a -m "Initial commit." Add the remote repo and push: git remote add origin tim@fileserv:/files/git/xxxxxxx git push --set-upstream origin master

dd Command

dd Command dd if=linuxmint-19-mate-64bit-v2.iso of=/dev/sdc bs=1M status=progress conv=fsync && sync

Rsync Commands

Rsync Commands rsync archive mode, preserve hard links, acls, extended attributes. rsync -aHAXv /mnt/src/ /mnt/dest/ rsync root filesystem. rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder