Skip to content

Instantly share code, notes, and snippets.

@mozbugbox
mozbugbox / webdriverRequest.md
Last active July 18, 2021 11:44
Get network request/performance data using selenium

To get the network request data using firefox, chrome or whatever selenium driver, just access the window.performance object.

def get_performance(driver):
    """Get network performance for webdriver"""
    JS_PERFORM = "return window.performance.getEntries() || {};"
    test = driver.execute_script(JS_PERFORM)
    return test
@mozbugbox
mozbugbox / 北斗七星歌.md
Last active February 21, 2021 03:39
北斗七星歌

魁斗,彪炳

树悬鸡犬,鱼开咬

  • 魁: 天枢,天璇,天机,天权
  • 杓 (biao): 玉衡,开阳,摇光
北斗七星高,哥舒夜带刀
@mozbugbox
mozbugbox / numzh2num-ver02.py
Last active December 30, 2019 14:07
中文数字转阿拉伯数字 Convert Chinese number count into Arabic integers.
#!/usr/bin/python3
# vim:fileencoding=utf-8:sw=4:et
# 参考 <https://blog.csdn.net/grllery/article/details/89430363>
def numzh2int(txt):
"""Convert Chinese number count to Arabic integer"""
cn_nums = {'〇': 0, '一': 1, '二': 2, '三': 3, '四': 4,
'五': 5, '六': 6, '七': 7, '八': 8, '九': 9,
'零': 0, '壹': 1, '贰': 2, '叁': 3, '肆': 4,
'伍': 5, '陆': 6, '柒': 7, '捌': 8, '玖': 9,
@mozbugbox
mozbugbox / update-showmet-git.sh
Created May 5, 2018 06:50
Update showmet git master into "showmet-master/" directory
#!/bin/sh
# Update showmet git master into "showmet-master/" directory
OUTPUT_DIR="showmet-master"
URL="https://github.com/mozbugbox/showmet/archive/master.zip"
OUTPUT="showmet-master.zip"
wget -O "${OUTPUT}" "${URL}"
if [ $? -ne 0 ]; then
echo "**ERROR** Download Failed..."
@mozbugbox
mozbugbox / pywrun.vbs
Created April 27, 2018 12:40
Run msys2 python3.exe without console on windows/win32
'
' Run Python script with hidden/no console using MSYS2 Python3
' Keywords: python msys2 windows win32 vbs gtk+ hidden console
'
' License: GNU GPL v3 or later (c) mozbugbox
'
PY_BIN = "C:\msys64\mingw64\bin\python3.exe "
PY_SCRIPT = WScript.Arguments.Item(0)
' Get Full Path of python script file
@mozbugbox
mozbugbox / ibusjump.vim
Created June 10, 2017 15:15
Switch ibus to English on Escape key for Vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto switching IBus engine to Engish when leaving insert mode
" Maintainer: mozbugbox <mozbugbox@yahoo.com.au>
" License: GPL version 3 or later
"
" Options:
" let g:ibus_eng_engine = 'xkb:us::eng'
" let g:ibus_reset_insert = 1
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@mozbugbox
mozbugbox / rk3128-flash-without-reset.md
Last active June 7, 2019 14:52
Upgrade rockchip rk3128 device without reset button

Upgrade rockchip rk3128 device without reset button

  • unplug power, not needed

  • short circuit 6th and 7th pin on the NAND chip (the big rectangle chip) using a needle or ball pen tip. The side with a bigger circle on the chip. The 1st pin is from the another side of the big circle.

  • plugin the USB connector near the ethernet (RJ45) jacket

@mozbugbox
mozbugbox / gist:2f278b324e31a6f042377c367fb61098
Last active January 27, 2023 04:47
v-com (vcom) value for Panasonic LCD/LED TV in service mode

The meaing of the v-com (vcom) value for Panasonic LCD/LED TV under the service mode.

Wonder why the LED TV screen flicking like crazy and look washed out in white noise? Particularly when you enter the service mode for the first time?

With a wrong v-com value, the TV screen will look washed out with continue flickering.

When the vcom value was wrong, you cannot even see the service menu text clearly. The screen just flick like crazy. When you getting close to the correct value of the vcom, the text on the service menu will became clearer and clearer with a relatively steady background.

In one case, a vcom value around 0x60 gives better result.

@mozbugbox
mozbugbox / pixbuf2pillow.py
Last active October 15, 2023 14:05
Python Pillow image to/from GdkPixbuf with gobject introspection
#!/usr/bin/python3
# vim:fileencoding=utf-8:sw=4:et
# Convert between pygobject Pixbuf and PIL/Pillow image format
# Also a function to do fast gamma correction with Pillow image
from __future__ import print_function, unicode_literals, absolute_import
import sys
from gi.repository import GLib, GdkPixbuf
@mozbugbox
mozbugbox / xscreensaver-suspend
Created August 10, 2014 13:08
Auto suspend Linux box with xscreensaver
#!/bin/bash
# suspend/sleep linux system on xscreensaver activation
#
# run the bash script in your .xsession,
# or something like .config/lxsession/LXDE/autostart for lxde
timeout=60 # After xscreensaver activated, wait timeout to suspend
read_timeout=5 # timeout for read from `xscreensaver-command -watch`
SUSPEND_BIN=/usr/sbin/pm-suspend