Skip to content

Instantly share code, notes, and snippets.

View wangmuy's full-sized avatar

zdwang wangmuy

View GitHub Profile
@wangmuy
wangmuy / MySQL Replication Check
Created October 13, 2018 14:00 — forked from ssimpson89/MySQL Replication Check
Just a simple Mysql Replication Health Check script I wrote. You can put this in a cron.
#!/bin/bash
### VARIABLES ### \
EMAIL=""
SERVER=$(hostname)
MYSQL_CHECK=$(mysql -e "SHOW VARIABLES LIKE '%version%';" || echo 1)
LAST_ERRNO=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Last_Errno" | awk '{ print $2 }')
SECONDS_BEHIND_MASTER=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G"| grep "Seconds_Behind_Master" | awk '{ print $2 }')
IO_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_IO_Running" | awk '{ print $2 }')
SQL_IS_RUNNING=$(/usr/bin/mysql -e "SHOW SLAVE STATUS\G" | grep "Slave_SQL_Running" | awk '{ print $2 }')
@wangmuy
wangmuy / hard-subtitle.py
Created May 16, 2018 06:30
Burn subtitle into video
#!/usr/bin/env python
import os
import sys
import shlex
import subprocess
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("orig_dir")
parser.add_argument("baked_dir")
args = parser.parse_args()
@wangmuy
wangmuy / ThreadedLogcat.java
Last active July 6, 2017 04:13
[threaded logcat] Get threaded logcat #logcat #process #InputStream
class ThreadedLogcat {
private boolean mClear;
private String mOutputFile;
private Thread mLoggingThread;
private Process mP;
private void stopLogging() {
if(mLoggingThread == null)
return;
try {
@wangmuy
wangmuy / ndk_property_get.cpp
Created September 13, 2016 10:30
android ndk getProperty
// http://stackoverflow.com/questions/26722040/replacement-for-system-property-get-in-android-l-ndk
#include <string>
#include <cstdio>
#include <cstdlib>
#include <errno.h>
int property_get(const char* key, char* out, char* def)
{
std::string cmd = "getprop ";
cmd += key;
@wangmuy
wangmuy / BackTraceUtils.cpp
Created September 13, 2016 10:29
android native stack backtrace
#ifndef BACKTRACE_UTILS_h
#define BACKTRACE_UTILS_h
// ref: http://stackoverflow.com/questions/8115192/android-ndk-getting-the-backtrace
#include <cstdio>
#include <ostream>
#include <sstream>
size_t captureBacktrace(void** buffer, size_t max);
@wangmuy
wangmuy / android-media-massStorage.java
Last active August 30, 2016 10:05
android.media.MassStorageDevice
// http://stackoverflow.com/questions/7142987/media-mounted-broadcast-not-being-received
// 静态 BroadcastReceiver
<receiver
android:name=".MediaMountedReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<data android:scheme="file" />
</intent-filter>
@wangmuy
wangmuy / android-service-overlayWindow.java
Last active August 30, 2016 09:53
android.service.overlayWindow
// prepare
// AndroidManifest.xml add permission
// <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
// see http://stackoverflow.com/questions/7569937/unable-to-add-window-android-view-viewrootw44da9bc0-permission-denied-for-t
WindowManager mWm = (WindowManager) getSystemService(WINDOW_SERVICE);
mTextView = new TextView(this);
mLayoutParam = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
@wangmuy
wangmuy / reload-path.bat
Last active January 18, 2024 15:02
refresh path in windows shell
@echo off
echo.
echo Refreshing PATH from registry
setlocal EnableDelayedExpansion
:: Get System PATH
for /f "tokens=3*" %%A in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path') do set syspath=%%A%%B
:: Get User Path
for /f "tokens=3*" %%A in ('reg query "HKCU\Environment" /v Path') do set userpath=%%A%%B
@wangmuy
wangmuy / git-bash-portable.bat
Last active August 30, 2016 02:17 — forked from dgw/git-bash-portable.bat
git-bash-portable startup
@echo off
rem Copyright (C): 2010 Voyagerfan5761
rem http://technobabbl.es/
rem Put in your git-for-windows root dir
set USER=wangmuy
set HOMEDRIVE=%~d0
set HOMEPATH=%~dp0home\%USER%\
set HOME=%~dp0home\%USER%\
set USERPROFILE=%HOMEPATH%
@wangmuy
wangmuy / svnsync-revprop.sh
Last active August 30, 2016 02:16
svnsync repo properties
#!/bin/sh
source /etc/profile
[ -z "$DIR" ] && DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SRC=http://192.168.1.100/svn
cd $DIR
repo=$1
rev=$2
echo repo=$repo
FILE=file://$DIR/$repo