Skip to content

Instantly share code, notes, and snippets.

@anddam
anddam / sample.py
Last active April 26, 2022 17:14
split, strip and get unique tokens from a string
def get_flags(key, sep=" "):
return list({stripped for item in get_config_var(key).split(sep) if (stripped := item.strip())})
@anddam
anddam / astylerc
Created March 30, 2022 12:02
astyle configuration
style=google
add-braces
indent-namespaces
pad-oper
pad-header
break-blocks
delete-empty-lines
indent-switches
# Objective-C
align-method-colon
@anddam
anddam / logger.cpp
Last active November 29, 2021 20:14
C++ logger class excerpt
Logger * Logger::m_Instance = 0;
Logger::Logger() {
char* buf = nullptr;
size_t sz = 0, l = 0;
// No `m_Instance` declared here
Logger * Logger::getInstance() throw () {
if (m_Instance == 0) {
m_Instance = new Logger();
@anddam
anddam / sample.py
Created November 8, 2021 22:20
PySide Qt issue with shifted chars in string when placing a TableWidgetItem in a TableWidget
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QMainWindow, QTableWidgetItem
class CMTableWidgetItemNonEditable(QTableWidgetItem):
"""Unset editing flags
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@anddam
anddam / gist:2ccf9f227e0ae817919c15c66c98c10b
Created August 31, 2021 22:45
virt-manager error saving
Error saving domain: operation failed: domain save job: unexpectedly failed
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/vmmenu.py", line 182, in cb
vm.save(meter=asyncjob.get_meter())
File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
ret = fn(self, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/object/domain.py", line 1377, in save
#!/bin/sh --
# example of .path_dirs file:
# /home/anddam/bin
# /home/anddam/.local/bin
{
# This 'config' should probably be found more nicely than this.
cat "${1:-$HOME/.path_dirs}"
IFS=:
# Wordsplitting is purposefully used here over a colon. PATH is
server {
listen 80;
listen [::]:80;
server_name a.server.invalid;
root /var/www/a;
index index.html;
location = /foo {
@anddam
anddam / build.out
Created June 3, 2021 21:50
issue customizing setuptools build_ext
Devel mode
Collecting pip
Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-21.1.2
Using local bit4id-pyexe source directory
+ env_devel=/home/test/Desktop/ada/venv
+ rm -rf /home/test/Desktop/ada/venv
+ python3 -m venv /home/test/Desktop/ada/venv
+ . /home/test/Desktop/ada/venv/bin/activate
+ deactivate nondestructive
+ [ -n ]
+ [ -n ]
+ [ -n -o -n ]
+ [ -n ]
+ unset VIRTUAL_ENV
openat(AT_FDCWD, "/home/ada/.local/var/db/xbps/pkgdb-0.38.plist", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=190, ...}) = 0
mmap(NULL, 4096, PROT_READ, MAP_SHARED, 3, 0) = 0x7ff95eb7e000
close(3) = 0
madvise(0x7ff95eb7e000, 4096, MADV_SEQUENTIAL) = 0
munmap(0x7ff95eb7e000, 4096) = 0
openat(AT_FDCWD, "/home/ada/.local/var/db/xbps/pkgdb-0.38.plist", O_RDWR|O_CREAT|O_CLOEXEC, 0664) = 3
fcntl(3, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_CUR, l_start=0, l_len=0}) = 0
access("/", W_OK) = -1 EACCES (Permission denied)
umask(022) = 022