Skip to content

Instantly share code, notes, and snippets.

@ptthisdan
ptthisdan / getPythonPath.ps1
Created December 23, 2021 03:16
One Line Command to detect Python Path
python -c "import os, sys; print(os.path.dirname(sys.executable))"
@ptthisdan
ptthisdan / regex4all.java
Created December 23, 2021 03:00
Java regex for Chinese use cases
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexUtils {
/**
* 验证Email
* @param email email地址,格式:zhang@gmail.com,zhang@xxx.com.cn,xxx代表邮件服务商
* @return 验证成功返回true,验证失败返回false
@ptthisdan
ptthisdan / commands.xml
Last active October 15, 2021 13:44
muCommander Configure for Total Commander UX compatibility
<?xml version="1.0" encoding="UTF-8"?>
<commands>
<command alias="view" value="open -a Preview $f"/>
<command alias="edit" type="system" value="open -a Visual\ Studio\ Code $f"/>
<command alias="editImg" value="open -a Fiji $f" display="Edit images"/>
</commands>
@ptthisdan
ptthisdan / adb-brightness.sh
Created July 14, 2021 07:06
Adjust screen brightness with adb
adb shell settings put system screen_brightness 0
adb shell settings put system screen brightness 5000
@ptthisdan
ptthisdan / powerchk.sh
Created March 13, 2021 05:19
ping the router, if ping fail>N, shutdown NAS
#!/bin/bash
# @author JasonLiu
# @since 2019/12/25
# @description ping the router,if power shutdown,router will shutdown,ping will fail,if ping fail>N,shutdown NAS
# idea first come from http://koolshare.cn/thread-120821-1-1.html
# */1 * * * * /share/Project/shell/powerchk.v5.sh >> /share/Project/shell/log/power.log
# crontab /etc/config/crontab && /etc/init.d/crond.sh restart
function usage()
{
@ptthisdan
ptthisdan / delete_outdated_photos.sh
Last active February 18, 2021 12:35
adb delete photos older than X Days
find /sdcard/DCIM* -mtime +180 -exec rm {} ";"
@ptthisdan
ptthisdan / jdks.sh
Created December 19, 2017 08:17 — forked from Noyabronok/jdks.sh
JDK switching
#list available jdks
alias jdks="/usr/libexec/java_home -V"
# jdk version switching - e.g. `jdk 6` will switch to version 1.6
function jdk() {
echo "Switching java version";
export JAVA_HOME=`/usr/libexec/java_home -v 1.$1`;
java -version;
}
@ptthisdan
ptthisdan / ngrok-selfhosting-setup.md
Created March 21, 2016 08:33 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#InstallKeybdHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; OPTIONAL: For those who use Home/End more than PgUp/PgDown, this flips their use with the Fn key.
; If you want the buttons to function as they are, add a semicolon (;) to the beginning of each line below.
Home::PgUp
End::PgDn
PgUp::Home