Skip to content

Instantly share code, notes, and snippets.

View wention's full-sized avatar

WENTION wention

View GitHub Profile
@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 / 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 / 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 / format.vim
Created June 24, 2023 02:41
Format commandlines in vim
s/\s\(-\w\+\)\s/ \\\r \1 /g
@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 / 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 / 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 / ssh-copy-id.ps1
Created July 13, 2023 02:26 — forked from elonmallin/ssh-copy-id.ps1
One-liner ssh-keygen and ssh-copy-id for Windows powershell
ssh-keygen && cat $env:userprofile/.ssh/id_rsa.pub | ssh user@linuxserver 'cat >> .ssh/authorized_keys'
@wention
wention / nginx.conf
Last active July 14, 2023 04:47
HTTP 反向代理与缓存
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@wention
wention / get_myip.py
Created July 25, 2023 07:14
Get My IPAddress
import socket
def get_myip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(0)
myip = None
try:
# doesn't even have to be reachable
s.connect(('10.254.254.254', 1))