This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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 | |