Skip to content

Instantly share code, notes, and snippets.

@mo-han
mo-han / path_check.py
Created March 4, 2021 04:10
python validate path str
#!/usr/bin/env python3
import errno
import os
import pathlib
import tempfile
# The code below is based on or copy from an answer by Cecil Curry at:
# https://stackoverflow.com/questions/9532499/check-whether-a-path-is-valid-in-python-without-creating-a-file-at-the-paths-ta/34102855#34102855
# -*- CODE BLOCK BEGIN -*-
@mo-han
mo-han / traitsui_large_image_button_fail.py
Last active February 5, 2021 04:54
traitsui large icon button test
from mylib.traitsui_helper.import_10_qt import * # mylib: https://github.com/mo-han/mo-han-toolbox/tree/master/mylib
i = ImageResource(r'scpi_shell\icon.png')
TestAction = Action(
name="&Test", action="test_clicked", tooltip="Click to test", image=i, height=-1280
)
class DialogWithToolbar(HasTraits):
@echo off & pushd %TEMP%
mode con cols=78 lines=3
title KMS ^& KMS 2038 ^& Digital ^& Online Activation Suite %ver% by mephistooo2 - TNCTR.com
set ver=v8.7
echo.
whoami /user|findstr "S-1-5-18">nul || (call :runasTI 1 cmd.exe /c "%~f0" &echo TRUSTED INSTALLER RIGHTS ENABLED... &echo Please wait... &TIMEOUT /T 3 >nul &exit)
echo.
echo Files extracting , please wait...
if exist "%TEMP%\KMS_Suite" @RD /S /Q "%TEMP%\KMS_Suite" >nul
powershell -noprofile -c "$f=[io.file]::ReadAllText('%~f0') -split ':bat2file\:.*';iex ($f[1]);X 1;" >nul
@mo-han
mo-han / nt_clipboard.py
Last active June 11, 2020 05:31
simple class for using clipboard in NT OS (Windows), supporting copied files (paths)
class Clipboard:
import win32clipboard as wcb
cf_dict = {n.lstrip('CF_'): m for n, m in inspect.getmembers(wcb) if n.startswith('CF_')}
def __enter__(self):
self.open()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
@mo-han
mo-han / image-hosting-图床
Created March 21, 2020 09:02
image-hosting-图床
image-hosting-图床
@mo-han
mo-han / synclock
Created July 8, 2019 17:38
a shell script for openwrt to sync system clock using ntpclient
#!/bin/sh
for i in $(seq 0 3)
do
server=$i.openwrt.pool.ntp.org
if ping -c 3 -w 3 $server >/dev/null
then
echo $server
ntpclient -s -h $server
break
@mo-han
mo-han / yt-dl.bat
Created July 7, 2019 06:41
a windows cmd script wrapper for youtube-dl
:: yt-dl.bat
:: Mo Han <zmhungrown@gmail.com>
:: @ yt-dl_worker.bat
@echo off
setlocal
call u_var.bat
set proxy=%u_autoproxy%
rem set proxy=%u_proxy%
pushd "%u_dl%"
@mo-han
mo-han / dir2cbz.sh
Created June 23, 2019 13:31
dir2cbz.sh
#!/bin/bash
for i in "$@"; do
if test -d "$i"; then
pushd "$i/.."
folder=$(basename "$i")
echo cbz: $folder
zip -q -0 -r "$folder.cbz" "$folder"
rm -r "$folder"
popd
@mo-han
mo-han / zip2cbz.sh
Created March 16, 2019 18:05
use zip to compress a folder into an cbz comic anchive
#!/bin/bash
for i in "$@"
do
if [ -d "$i" ]
then
parent=$(dirname "$i")
pushd $parent >/dev/null
echo $parent
dir=$(basename "$i")
@mo-han
mo-han / eh-helper-v405-mod1.userscript.js
Created February 8, 2019 17:13
E(X)Hentai Helper userscript ver 4.05 mod 1
// ==UserScript==
// @name E(X)Hentai Helper
// @description Links between E-Hentai and ExHentai page, and also links user to ExHentai automatically if gallery is "removed" and adds "view later" function
// @namespace https://greasyfork.org/en/scripts/24342-e-hentai-exhentai
// @version 4.05
// @icon https://e-hentai.org/favicon.ico
// @resource exCSS http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css
// @resource jqueryui https://code.jquery.com/ui/1.12.0/jquery-ui.min.js
// @include https://upload.e-hentai.org/*