Skip to content

Instantly share code, notes, and snippets.

View wention's full-sized avatar

WENTION wention

View GitHub Profile
@wention
wention / utils.py
Last active July 12, 2023 08:49
Qt Utils
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
def rect_scale(source, target, aspect=Qt.IgnoreAspectRatio):
"""缩放
source 待缩放
@wention
wention / main_layout.py
Created July 5, 2023 09:24
Custom qlayout base on borderlayout example
import sys
from PyQt5.QtCore import QRect, QSize
from PyQt5.QtWidgets import QMainWindow, QApplication, QLayout, QHBoxLayout, QFrame, QPushButton, QWidget, \
QWidgetItem
POSITISON_HEADER = 1
POSITISON_FOOTER = 2
POSITISON_CONTENT = 3
@wention
wention / packer.qemu.pkr.hcl
Last active June 25, 2023 00:30
Packer demos
source "qemu" "vm" {
iso_url = "file:///home/wention/VMs/images/t.qcow2"
iso_checksum = "none"
output_directory = "${path.root}/build"
headless = false
display = "sdl"
cpus = 4
memory = 4096
disk_image = true
skip_resize_disk = true
@wention
wention / format.vim
Created June 24, 2023 02:41
Format commandlines in vim
s/\s\(-\w\+\)\s/ \\\r \1 /g
@wention
wention / fix_packer_parallel
Created October 11, 2022 06:24 — forked from gildas/fix_packer_parallel
Fix packer error: couldn't find Parallels Tools for ... flavor after upgrading Parallels
# After upgrading Parallels Desktop, often, this command (used by the packer parallels driver):
# mdfind kMDItemCFBundleIdentifier == com.parallels.desktop.console
# will return not only one path, but a list of the old one(s) and the one:
# /opt/homebrew-cask/Caskroom/parallels-desktop/11.0.2-31348/Parallels Desktop.app
# /opt/homebrew-cask/Caskroom/parallels-desktop/11.1.0-32202/Parallels Desktop.app
#
# Maybe one day the packer team will fix their code and use only the highest version in that list,
# Until then we have to fix the list by ourselves:
mdfind kMDItemCFBundleIdentifier == com.parallels.desktop.console
@wention
wention / README.md
Last active March 1, 2022 09:19
Build custum ubuntu with bios/efi bootable

Prepare

sudo apt-get install \
    binutils \
    debootstrap \
    squashfs-tools \
    xorriso \
    grub-pc-bin \
 grub-efi-amd64-bin \
@wention
wention / export_parallels_vm.sh
Created February 5, 2022 11:43
Export Parallels VM
#!/bin/bash
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
basename() {
echo ${1##*/}
}
@wention
wention / nvidia_gpu_passthrough.xml
Last active February 5, 2022 08:26
KVM GPU passthrough helpers
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>win10</name>
<uuid>a03f5f0b-d4e0-49e9-975c-62970b296719</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://microsoft.com/win/10"/>
</libosinfo:libosinfo>
</metadata>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
@wention
wention / Startnet.cmd
Last active June 16, 2024 08:31
iPXE Sanboot windows
Wpeinit
ipconfig /all
netsh interface show interface
net use z: \\10.211.55.19\public
z:
.\setup.exe
@wention
wention / jail.conf
Created September 27, 2021 06:27 — forked from AysadKozanoglu/jail.conf
fail2ban nginx 404 400 403 444 filter /etc/fail2ban/filter.d/nginx-4xx.conf enable
# to enable this filter add to jail.conf following (/etc/fail2ban/jail.conf)
# Thanks to -> TheBarret
[nginx-4xx]
enabled = true
port = http,https
logpath = /var/log/nginx/access.log
maxretry = 3