Skip to content

Instantly share code, notes, and snippets.

High CPU from kworker/0:x-kacpi_notify
Ubuntu 20.04 LTS
Update: this problem is fixed after I did "apt dist-upgrade" on 9/21/2020
Update again: Acutally not fixed. It happened again after unplug/plug the usb-c hub.
I recently got a USB-C Hub (Targus ACA958USZ). When it's plugged in, the laptop gives high cpu from process
I've found a few USB-C hubs from various manufactures with the same problem. I think they are of the same chipset.
@GaryLee
GaryLee / cmdfmt.py
Last active October 3, 2017 01:44
Execute shell command or print text in Perl-like manner.
import sys
import os
from subprocess import CalledProcessError, check_output
def cmd(cmd_arg, local_only=False):
"""Execute shell command in Perl-like manner."""
if local_only:
ctx = sys._getframe(1).f_locals
else:
ctx = globals().copy()
@GaryLee
GaryLee / fmt.py
Last active October 2, 2017 13:04
Format string with caller's variable scope.
def fmt(spec):
"""Format string with caller's variable scope."""
return spec.format(**sys._getframe(1).f_locals)
# fmt() can be also written in lambda form.
# fmt = lambda s: s.format(**sys._getframe(1).f_locals)
a = 10
b = 20
c = 30
@GaryLee
GaryLee / cmd.py
Last active October 2, 2017 13:00
Execute shell command in Perl-like manner.
import sys
import os
from subprocess import CalledProcessError, check_output
def cmd(cmd_arg):
"""Execute shell command in Perl-like manner."""
ctx = globals().copy()
ctx.update(sys._getframe(1).f_locals)
for ln in check_output(cmd_arg.format(**ctx), shell=True).split(os.linesep):
yield ln
@GaryLee
GaryLee / RunAsAdmin.py
Last active March 22, 2024 21:52
Elevate the privilege to Admin. Support both python script and pyinstaller wrapped program. Need ctypes only.
#!python
# coding: utf-8
import sys
import ctypes
def run_as_admin(argv=None, debug=False):
shell32 = ctypes.windll.shell32
if argv is None and shell32.IsUserAnAdmin():
return True