快速清空超大数据表

作者:matrix 发布时间:2020年8月31日星期一 分类:Python 零零星星

第一次drop超过GB的数据表,没想到竟然会执行的这么慢。尝试过TRUNCATEDROP都不满意。
后来就直接找到数据库储存的文件来删除,这样比起使用sql语句操作会快得多,但也是危险操作,无法找回。

删除操作脚本

运行环境 python3.7,依赖pymysql,根据自身情况配置变量mysql_data_dir,db_config,table_names,condition_save

fast_drop_table.py

#codeing=utf-8
"""
快速清空超大数据表 保留想要数据
"""
import pymysql
import os

mysql_data_dir = '/mnt/mysql_data/db_name/' #数据库文件所在路径

# 数据库连接配置
db_config = {'host': '127.0.0.1', 'port': 3306, 'user': 'user', 'password': 'password', 'db': 'db_name', 'charset': 'utf8'}

# 需要清空操作的数据表
table_names = [
"com_hhtjim_badata_trades_eos_this_quarter",
"com_hhtjim_badata_trades_eth_this_quarter",
  ]

# 数据表保留的查询条件
condition_save = "timestamp  >  '2020-02-20T00:00:00Z'"
# condition_save = False# 不保留


class Db:
    '''
    简单数据库连接操作类
    '''
    def __init__(self,**kwargs):
        self.connection = pymysql.connect(**kwargs)
        self.cursor = self.connection.cursor()


if __name__ == "__main__":
  mysql = Db(**db_config)
  for table_name in table_names:
    os.link('{}{}.frm'.format(mysql_data_dir,table_name), '{}{}.frm.h'.format(mysql_data_dir,table_name))
    os.link('{}{}.ibd'.format(mysql_data_dir,table_name), '{}{}.ibd.h'.format(mysql_data_dir,table_name))


    mysql.cursor.execute('CREATE TABLE {0}_back like {0}'.format(table_name))
    mysql.connection.commit()


    if condition_save:
      mysql.cursor.execute("INSERT INTO {0}_back SELECT * FROM {0}  WHERE {1} ;".format(table_name,condition_save))
      mysql.connection.commit()


    mysql.cursor.execute("drop table {}".format(table_name))
    mysql.connection.commit()

    mysql.cursor.execute("alter table  {0}_back rename to  {0};".format(table_name))
    mysql.connection.commit()


    os.unlink('{}{}.frm.h'.format(mysql_data_dir,table_name))
    os.unlink('{}{}.ibd.h'.format(mysql_data_dir,table_name))

    print('succeed: {}'.format(table_name))

具体步骤

### 找到frm,ibd文件

根据数据库存储路径找到需要删除的表名的frm,ibd文件。

### 建立硬连接
$ ln mytable.ibd  mytable.ibd.h
$ ln mytable.frm  mytable.frm.h


### 备份表结构
CREATE TABLE mytable_back like mytable;

### 备份想要保留的数据
INSERT INTO mytable_back SELECT * FROM mytable  WHERE timestamp  >  '2020-02-27T00:00:00Z' ;

### 删除旧表
drop table mytable;

### 修改备份表名字
alter table  mytable_back rename to  mytable;


### 删除硬连接
$ rm -f  mytable.frm.h  mytable.ibd.h

参考:
https://blog.csdn.net/weixin_34034261/article/details/86250223

Evolution Host 免费VPS 申请

作者:matrix 发布时间:2020年7月2日星期四 分类:零零星星

图片5225-Evolution Host 免费VPS 申请

Evolution Host 官网

https://evolution-host.com/vps-hosting.php

前几天看到有免费vps可以申请,抱着诚恳的态度 😂 打开了Evolution Host。今天收到回复啦
evolution-host.com,成立也有4,5年时间了,主要做软件游戏和软件服务器。
申请的时候需要提交所有者网站,最后会要求网页上挂Evolution Host的链接。所以现在是专门介绍他们的网页。
看到一些信息,他们提供4档位的VPS来对应提交网站的流量,越大的话给你的配置也就越高。不支持违法站点使用。

期待真香~ 😛

Dallas, USA

第二天就收到了,他们处理的很快。所有信息全部在邮件里面,包括登录账户、密码、vps登录信息等。
选的达拉斯机房,速度一般。不过配置比起自己买的要高。选的HDD硬盘,其他的还没看 😂 香~

登录控制面板看到付费周期为一个月,估计要免费的话是需要邮件联系的。

图片5234-Evolution Host 免费VPS 申请

ios 自定义html页面发送到桌面图标

作者:matrix 发布时间:2020年6月26日星期五 分类:兼容并蓄 零零星星

经常用高德地铁图书签看地铁线路图
今天发现高德修改了scheme跳转规则,走到了测距界面。本来想重新设置个书签到桌面的,结果是找不到以前的方法了,干。

重新设置

高德地铁图url data数据

data:text/html;charset=UTF-8,%3Chtml%3E%20%20%20%20%20%20%20%20%3Chead%3E%20%20%20%20%20%20%20%20%3Cmeta%20content=%22yes%22%20name=%22apple-mobile-web-app-capable%22%20/%3E%20%20%20%20%20%20%20%20%3Cmeta%20content=%22text/html;%20charset=UTF-8%22%20http-equiv=%22Content-Type%22%20/%3E%20%20%20%20%20%20%20%20%3Cmeta%20name=%22viewport%22%20content=%22width=device-width,%20initial-scale=1.0,%20user-scalable=no%22%20%20%20%20%20%20%20%20/%3E%20%20%20%20%20%20%20%20%3Clink%20rel=%22apple-touch-icon-precomposed%22%20href=%22data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAABGdBTUEAALGPC/xhBQAAAwBQTFRFNqb25OPhlp1/wK1uqqR2bo+P17puW4iXRoCgM5zrMXipqNTxCWq5wtbjhr3jUK3ux69qoMbearXo+fn52eDmitabOa/VltyTSLbKtKhybL31ebnlYLz+q+aE5PT/dMT+1O3/7+/vUq7+fbz/tdPqeLv+Z6qowd3vobh5S6XA28VJAFqu3vH/+NhGipiDZ7G0o7mehbKvruiB5sl3V7j+oaF6T4Oc6thXosOKUKHFzsJUiaqdZIuUl8LgOaDcjbSrFG21bciwq8WEmrejfJBrPXyjv7N4crn+49ZchL3jRanwea+2HaHpTqzu0LZsY6rDD5f0fM+lxMGKr7yXTqXPK6jfNZzYa8D+OJG6YLHqeJKL18Z/LZ7jhJOCAFuvAGrDgJ+9HJv2m8zuU7P30OPuYbf1Wrb2zuHtutvvI3OvNaTzx9LW0dXV9PT0wtDYldL+E5v9h5ZngcPy19fTBZT77Orlis3+wub/ssvbm8f/KaH5u75kAGe/lr+Tg7GRL5/X19Jk48dCF5nvW669Sqz+vOP+otHxVrT3Paz7M6n9Y7n2p7CJqtTwqtv+zOn/Jp3l/s9pAHTT5LpeHZvqbKWxiY93AFirAF+0AGW8AFSm6Ozsisjzk8zy6b1fAGK5c7/03ejtnM/xAGi/AFGhNaf5fMP0JaH63bli2tjU+/3+7O3s7fj/9fv/IqH9gMr+SLL+Qaz4HZnnDJb0A5T7sdfw8cRi981tarz1x+Du7cBg9shkAE+eAG/K7+/rB5b9+8xm8e/r7uznF5z61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wbmZFMDGI5MatHgO122wdKQRGoIA6TWW9tiTliSGqqcPo/b1aErC7uVJptuKyxJUujKIM3ncbs6HD1gYcIeP2OM+Y/1Daz+/03zedwvXA4NFoRpNYyx4119C6vXNaESCIIgCMLhFjaln2Al/26PT0mZXLq3fmp/w0q64nAcjsNxOA7H4ThsEf4PNuWrmdAlCQ8AAAAASUVORK5CYII=%22%3E%20%20%20%20%20%20%20%20%3C/link%3E%20%20%20%20%20%20%20%20%3Ctitle%3E%20%20%20%20%20%20%20%20%E5%9C%B0%E9%93%81%E5%9B%BE%20%20%20%20%20%20%20%20%3C/title%3E%20%20%20%20%20%20%20%20%3Cstyle%3E%20%20%20%20%20%20%20%20%20%20%20%20*%7Bmargin:0;padding:0%7D%20%20%20%20%20%20%20%20%20%20%20%20html,body%7Bheight:100%25;min-height:100%25%7D%20%20%20%20%20%20%20%20%20%20%20%20body%7Bbackground:%23eee;text-align:center;overflow:hidden%7D%20%20%20%20%20%20%20%20%20%20%20%20a%7Bdisplay:%20none%7D%20%20%20%20%20%20%20%20%20%20%20%20p%7Bfont-size:14px;line-height:200%25%7D%20%20%20%20%20%20%20%20%20%20%20%20.logo%7Bwidth:90px;margin-top:%2032px%7D%20%20%20%20%20%20%20%20%20%20%20%20section%7Bwidth:%20264px;height:%2078px;background:%23fff;position:absolute;bottom:%2020px;-webkit-border-radius:%203px;border-radius:%203px%7D%20%20%20%20%20%20%20%20%20%20%20%20section:before%7Bcontent:'';display:block;width:528px;height:156px;-webkit-transform:scale(0.5);-webkit-transform-origin:%20left%20top;border:1px%20solid%20%2389ccff;-webkit-border-radius:6px;border-radius:%206px;z-index:1%7D%20%20%20%20%20%20%20%20%20%20%20%20section:after%7Bcontent:'';display:block;width:36px;height:%2036px;border:%201px%20solid%20%2389ccff;background:%20%23fff;position:absolute;-webkit-transform:%20scale(0.5)%20rotate(45deg);bottom:%20-19px;left:113px;z-index:%202%7D%20%20%20%20%20%20%20%20%20%20%20%20div%7Bposition:%20absolute;top:%201px;right:%201px;bottom:0;left:1px;z-index:3;background:%23fff%7D%20%20%20%20%20%20%20%20%20%20%20%20div%20%3E%20p%7Bcolor:%20%23333%7D%20%20%20%20%20%20%20%20%20%20%20%20div%20%3E%20p:first-child%7Bmargin-top:8px%7D%20%20%20%20%20%20%20%20%20%20%20%20span%7Bdisplay:inline-block;width:%2017px;height:%2023px;background:%20url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAuCAMAAACRbICIAAABR1BMVEX///9+wv8UkP9ktv/j8v/S6v8lmf/Y7f90vv8Rj/8pl//s+P+a1P8smv8mmf/t+P+54/+Y0/+Z1P/q9/8Eif9fuP9Ssf9Usv/j8f/P6/8mlv8Dgv+Z0//p9/9Ssv9ovP/0/P/Z7f9TsP8qmv8Hgv/t+f9XtP/5/f/k9P/T7//9/v8IhP+k2f+W0f92w//4/v/U8P9Pr//X7f9Ep/9Vsf8pkf/y+f+m1f8pmv8qm/8tk/+Vzf8Sj//x+P+c0P8Rhf8Mjf96wP9PsP/X7P/9///8/v+IyP9nuP/U6//K5v+ey//w+P/W7P8VkP8hl/9zvv+73/8LjP/P7f90vf91vv9ktf9zwP9ksP+x2v8Ae/8Ag/8Ad/8AfP8Adv9it/8Ahv8LjP90wf8AhP8Ji/8Aev8AgP8Acv8Adf8Aav8imf+a0/8Tiv8AiP/+x5cfAAAAWXRSTlMAgeubHCzZJovt1RJk09kSRmZmFPufrascMNn7Zhatlwomq9X3EqcGGiwC91poiQYqryi7qdUMWNXV0WrtDmLt84WvKAICdpcqNGAOKOndi0TzMIuJm4ubTn6oYBsAAADXSURBVHhe7c1FVwNBEIXRNxODhIm7E0IUdXd3lx6JB///a1h0b2CoJbDIt3znnip8qeStgMwVfhulQaSrBpME8Myo7Xrj3ffzhZzerLHXl5Yf5gW2WGhHMqKxeGLAFKTSeiaLc20QV868GRkusLsi0Kc5gLJSHfkudvfGxsEFJianYBoXvN8V08qCaGiOi/lZMS0uLUNW+0Urq1ysrYtpQ9uE7Ka+bD9JkO2UsP0P0RP7zwe0wOHRMSlEfy96wk2Jk09xemYlujAkXLIOEXu8xs2ther+4QN2Dj6s1Wm3NwAAAABJRU5ErkJggg==)%20no-repeat%20center;background-size:%20contain;margin:%200%2010px;position:relative;top:3px%7D%20%20%20%20%20%20%20%20%3C/style%3E%20%20%20%20%20%20%20%20%3C/head%3E%20%20%20%20%20%20%20%20%3Cbody%3E%20%20%20%20%20%20%20%20%3Ca%20href=%22iosamap://openFeature?featureName=Subway&sourceApplication=applicationName&page=Subway%22%20id=%22qbt%22%3E%3C/a%3E%20%20%20%20%20%20%20%20%3Cnav%20id=%22nav%22%3E%3C/nav%3E%20%20%20%20%20%20%20%20%3C/body%3E%20%20%20%20%20%20%20%20%3Cscript%3E%20%20%20%20%20%20%20%20if%20(window.navigator.standalone%20==%20true)%20%7B%20%20%20%20%20%20%20%20%20%20%20%20var%20lnk%20=%20document.getElementById(%22qbt%22);%20%20%20%20%20%20%20%20%20%20%20%20var%20evt%20=%20document.createEvent('MouseEvent');%20%20%20%20%20%20%20%20%20%20%20%20evt.initMouseEvent('click');%20%20%20%20%20%20%20%20%20%20%20%20lnk.dispatchEvent(evt);%20%20%20%20%20%20%20%20%7D%20else%20%7B%20%20%20%20%20%20%20%20%20%20%20%20var%20bodyWidth%20=%20document.body.clientWidth;%20%20%20%20%20%20%20%20%20%20%20%20var%20nav%20=%20document.getElementById(%22nav%22);%20%20%20%20%20%20%20%20%20%20%20%20nav.innerHTML%20=%20'%3Cimg%20class=%22logo%22%20src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALEAAACxCAYAAACLKVzFAAAb00lEQVR4Xuzda3BU533H8d9zztmLtCutLkhCEkiAAAmQkG1iAwYak8bJ5E3i1E1n2nE77SRO4iZtkmljT9KpxzN9kQSDsWQCNsZOgvENGycNcprYSbGx0xiwICAh0BVJoBtI2tXer+f0PGdk1jteVnv2enb1fGeeWeFBkmf8mWf+es7jFeF5HjkSQaZjSciBBCRZMBhEKhIEg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E5%B9%95%E2%80%9D%3C/p%3E'%20+%20'%3C/div%3E'%20+%20'%3C/section%3E';%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%3C/script%3E%20%20%20%20%20%20%20%20%3C/html%3E

说明:

其中核心位置为 iosamap://scheme a标签跳转。

iosamap://openFeature?featureName=Subway&sourceApplication=applicationName&page=Subway

顺便再记录下官方原版不可用的scheme:

iosamap://openFeature?featureName=Mine&page=ToolBox&item=Subway

item参数失效,所以就默认跳转到了测距界面。

使用

复制顶部的url data代码,在safair地址栏中打开,使用下方的分享发送按钮发送到桌面快捷键即可。

到这里就解决了问题。
下面是简化和修改操作,各位没必要看了。

自定义以及精简

上面的大段官方代码主要是css样式、图标等信息,其实可直接简化。

代码中可以任意修改。设置为其他任意界面,样式,图标,标题,以及打开的跳转页面和预览窗口都可以。要求为data:text/html形式。

如果理解一些html,可简化html为如下形式:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        window.location.href = 'iosamap://openFeature?featureName=Subway&sourceApplication=applicationName&page=Subway';
    </script>
</head>
<body>
</body>
</html>

最终的url data数据:

data:text/html;charset=UTF-8,%3c!DOCTYPE%20html%3e%0d%0a%3chtml%20lang%3d%22en%22%3e%0d%0a%3chead%3e%0d%0a%20%20%20%20%3cmeta%20charset%3d%22UTF-8%22%3e%0d%0a%20%20%20%20%3ctitle%3eTitle%3c%2ftitle%3e%0d%0a%20%20%20%20%3cscript%20%3e%0d%0awindow.location.href%20%3d%20%27iosamap%3a%2f%2fopenFeature%3ffeatureName%3dSubway%26sourceApplication%3dapplicationName%26page%3dSubway%27%3b%0d%0a%20%20%20%20%3c%2fscript%3e%0d%0a%3c%2fhead%3e%0d%0a%3cbody%3e%0d%0a%3c%2fbody%3e%0d%0a%3c%2fhtml%3e

说明:

注意!需要以data:text/html;charset=UTF-8,形式开头。切记,后面字符全部为url编码数据,空格字符编码为%20,非+字符。

schma参考:

https://lbs.amap.com/api/amap-mobile/guide/ios/subway

如何提取损坏的压缩包文件

作者:matrix 发布时间:2020年5月19日星期二 分类:零零星星

有些压缩包损坏之后无法正常解压,尝试修复压缩包之后再忽略错误解压其实就可以提取出所有文件了,但是损坏的文件取出来不能保证完整性。

待修复文件: 华为主题压缩包 3.zip

尝试提取/unlock/manifest.xml文件

方法1. windows下手动操作

windows下尝试使用7z直接打开会提示错误,看不到里面任何内容。

  1. 先用WinRAR修复压缩包:工具 -> 修复压缩文件
  2. 7zip工具打开修复之后的压缩包,然后点击顶部的提取按钮就可以取出来啦

图片5202-Winrar+7z 提取损坏的压缩包文件

方法2. *unix下执行脚本

  • 确保正常使用zip,unzip命令

  • 下面代码保存为repair_zip.sh文件

  • 执行bash repair_zip.sh bla-bla.zip

尝试解压提取出bla-bla.zip所有文件,资料会提取到相同位置的bla-bla_repaired目录。

macos下测试可用。

gist: https://gist.github.com/Hootrix/1d5d96d95dc5238e170405c77d54f02f

#!/bin/bash
file=$1
dir=`dirname $file`

# 检测文件存在
if [ ! -f $file ];then
    echo "404: file not found"
    exit 1
fi

# 检测zip命令
if ! type "zip" > /dev/null; then
    echo "500: command not found. Please execute install >  apt-get/yum install zip"
    exit 1
fi


file_name=`echo $file | awk -F . '{print $1}'|awk -F '/' '{print $(NF)}'` # 截取文件名
save_path=$dir/"$file_name"_repaired # 修复后提取存放路径
echo -e "extract file: $file"
echo -e "processing... ... "

repaired_zip_package=$dir/"$file_name"_repaired.zip #修复后的压缩包路径

zip -FF $file  --out $repaired_zip_package && unzip $repaired_zip_package -d $save_path 
sleep 1;unlink $repaired_zip_package

echo -e " \e[0;32msuccessful: $save_path\e[0m"

参考:
https://superuser.com/questions/23290/terminal-tool-linux-for-repair-corrupted-zip-files

auto.js自动化处理插件 - 葡萄浏览器多账号签到

作者:matrix 发布时间:2020年2月11日星期二 分类:零零星星

这些天在家研究autojs操作,完全可以用它来模拟手动点击滑动app的各种操作,这个自动化是真的香~
ios端的Jsbox没这么友好,毕竟系统完全不同,也有很多限制。

https://hyb1996.github.io/AutoJs-Docs

目前要使用多个账号登录,然后进行点击签到,看广告的需求。

环境:mi8 Android9 AutoJs[4.1.1] 葡萄浏览器com.qwh.grapebrowser

AutoJs在应用市场都被下架了,留个下载的渠道:

https://github.com/SuperMonster002/Hello_Sockpuppet/raw/master/%5Bauto.js%5D%5B4.1.1_alpha2%5D%5Barm-v7%5D(b69a4e23).apk

https://www.hhtjim.com/wp-content/uploads/2020/02/auto.js4_.1.1_alpha2arm-v7b69a4e23.apk_.zip

鼓捣了几天,差不多完工。测试的app是葡萄浏览器com.qwh.grapebrowser,最终效果是运行后自动切换账号来签到。
第一次编写的确是各种懵逼,为啥子不动了,日志在哪里怎么看,每次都手动复制代码到手机好麻烦。。。

开发环境vscode

vscode插件来开发很方便。如果没有开发调试环境,我每次都要微信发送代码的消息,toast,再上app清空粘贴运行,累死。给hyb1996好评,相当不容易。

  1. command + shift + p运行Start Server命令来开启远程环境。

  2. auto.js APP设置里打开连接电脑,填入电脑端内网ip。当然手机和电脑是要一个内网环境

图片5130-auto.js插件 - 葡萄浏览器多账号签到

  1. 运行Run命令就可以在app端运行插件脚本。注意默认模式需要打开在Auso.js界面中启动。

开发

文档:

https://hyb1996.github.io/AutoJs-Docs/

要操作的控件基本信息都需要用 autojs app的悬浮窗设置里面找到分析

"auto"
console.show();//开启log窗口

//等待打开app
launchApp('葡萄浏览器');
waitForPackage("com.qwh.grapebrowser");

const LOGIN_ACTIVITY = 'com.qwh.grapebrowser.mvp.base.login.LoginActivity';
const MAIN_ACTIVITY = 'com.qwh.grapebrowser.mvp.navigation.NavigationActivity';
const SETTING_ACTIVITY = 'com.qwh.grapebrowser.ui.main.activity.mineview.SystemSettingActivity';
const BASEDIALOG = 'com.qwh.base.BaseDialog';

var  iv_cancel = id("iv_cancel"); //粘贴板搜索窗口的取消按钮
var ad = id('skip_view');//跳过广告按钮
var my = id("ll_mine");//我的按钮
var sign = id("iv_sign");//签到图标
var sign_in = id("iv_sign_in");//签到按钮
var profile_photo = id("iv_pic").className("android.widget.ImageView").clickable(true);//头像
var exit_btn = id('ll_exit');//退出登录的按钮. 不可点击 只能获取坐标来操作
var exit_ac = id('tv_dialog_message_confirm'); //同意执行退出
var login_btn = id('tv_login');//登录按钮 

var accounts = {
    "131***1110": "123123"
};

cance_list = [ad , iv_cancel];

//监听弹窗事件(异常界面处理)
threads.start(function(){
    while(true){
        sleep(100);
        for (i in cance_list){
            //toast(cance_list[i]);
            if(cance_list[i].exists()){
                cance_list[i].click();
            }
        }

    };
});

//监听音量下键
threads.start(function(){
  isKeyDown();
})

//id("iv_pic").className("android.widget.ImageView").clickable(true)  .findOne().click();


//根据控件布局点击
function click_btn_func (widget_list,time ){
  if(widget_list instanceof Array){
    for(var i in widget_list){
      var widget = widget_list[i];
      if(widget.exists()){
        if(time){
          while(!widget.findOne(time).click());
        }else{
          while(!widget.findOne().click());
        }

        // if(widget_list[i].clickable()){//可点击判断  测试没有用。
        //   toast('aaaa');
        // }
      }
    }
  }else{
    if(time){
      while(!widget_list.findOne(time).click());
    }else{
      while(!widget_list.findOne().click());
    }
  }
}

//根据坐标点击控件
function click_coord_func(widget_list){
  if(widget_list instanceof Array){
    for(var i in widget_list){
      let widget = widget_list[i];
      if(widget.exists()){
        widget = widget.findOne();
          //获取其中心位置并点击
        while( !click(widget.bounds().centerX(), widget.bounds().centerY()) );
      }
    }
  }else{
    let widget = widget_list.findOne();
          //获取其中心位置并点击
    while( !click(widget.bounds().centerX(), widget.bounds().centerY()) );
  }
}

// 我的界面中判断是否登录
function is_login_of_my_activity(){
    return !!profile_photo.exists();
}

function logout(){
  console.log('function: logout')

  //已经进入我的界面
    // waitForActivity(MAIN_ACTIVITY);//入口主界面 activity
  if(is_login_of_my_activity()){//如果已登录,则点击退出
    console.log('发现有登录账号')
    //切记等待界面响应
    click_btn_func([profile_photo]);
    waitForActivity(SETTING_ACTIVITY);//等待界面响应
    click_coord_func([exit_btn]);
    waitForActivity(BASEDIALOG);
    console.log('返回到登录界面');
    click_btn_func([exit_ac]);
  }else{//已经是退出了 进入登录界面
    console.log('发现已经退出');
      //我的界面点击登录按钮操作
  // if(id('tv_btn').exists()){
  //   .findOne().click();
  // }
  console.log('查找「登录/注册」按钮 进入登录界面')
  click_btn_func( id('tv_btn'),4000);
  }
}

function login(phone,pwd){
  //已进入登录界面
    waitForActivity(LOGIN_ACTIVITY);
    setText(0,phone);
    setText(1,pwd);
  click_btn_func([login_btn]);
  console.log('登录完成')
}

//检测是否点击了音量下键的方法
function isKeyDown(){
  //按键时不会弹出音量框
  events.setKeyInterceptionEnabled("volume_down",true);
  //监听按键
  events.observeKey();
  events.on("key_down",function(volume_down,event){
      toast("正在关闭此脚本");
      //退出脚本
      sleep(500);
      engines.stopAll();
      //直接返回桌面
      home();
  });
}

//每秒执行检测操作 超时退出
function await_callback(callback,timeout_second){
  let _n = 0;
  while(true){
    if(_n > timeout_second){// 最长等待n秒检测
      console.log('await_callback最长等待超时 break')
      break;
    }
    if(callback()){//执行回调 返回true
      return true;//返回true标记给外部
      // break;
    }
    sleep(1000);//步长 1秒
    _n++;
  }
  return false
}

console.log('查找关闭按钮');
await_callback(function(){
    if(className("android.widget.ImageView").depth(5).bounds(55,130,137,212).exists()){
        className("android.widget.ImageView").findOne().click();
        console.log('完成 关闭广告按钮');
        return true
    }
    return false
},3);

  //确定图片 领取报销额度
  console.log('等待界面 准备领取');
  // waitForActivity('com.qwh.grapebrowser.dialog.s');//等待领取报销额度的页面
  var pull_down = await_callback(function(){
    if(className("android.widget.FrameLayout").exists()){
      console.log('点击确定FrameLayout 领取');
      click_coord_func(className("android.widget.FrameLayout"));
      return true;
        }
        return false;
  },30);

console.log('done');

说明:
上面成品修改下账户密码可以直接运行。
需要注意的是代码中很多时候卡住不动都需要判断控件或者按钮是否存在,否者findOne()会一致做轮询。
用log输出,查看运行状态
有些控件无法触发click()方法,需要查看其clickable属性是否为true,意即为是否可点击
不能正常按照控件布局点击的话只能用坐标进行点击操作

安卓是真的香,以后想拥有一台一加😂

参考:

https://hyb1996.github.io/AutoJs-Docs

https://github.com/SuperMonster003/Auto.js_Projects/tree/Ant_Forest

https://www.jianshu.com/p/d2ad3ce9cf87

https://thbelief.coding.me/2019/04/02/Auto-js-Script%E5%BC%80%E5%8F%91-%E4%BA%8C/

https://www.autojs.org/

https://www.autojs.org/topic/1651/%E5%BD%93%E6%8E%A7%E4%BB%B6-clickable-false-%E6%97%B6-%E6%80%8E%E4%B9%88%E8%BF%9B%E8%A1%8C%E7%82%B9%E5%87%BB%E6%88%96%E8%80%85%E8%A7%A6%E6%91%B8

PEACE~

ifttt推送gmail新邮件提醒

作者:matrix 发布时间:2020年2月8日星期六 分类:零零星星

今天临时想用ifttt来发送新邮件提醒服务的推送,查了下才知道19年初google就取消了对ifttt的api调用。不过看到可以使用其他三方应用来解决这个问题。

目的:新gmail邮件->tg消息通知

需要Gmail,IFTTT,automate.io,Trello,telegram相关账户

后续两天使用发现automate.io的免费版配额调用次数只有250次,所以说下面的操作对于想使用免费版本的人来说,可行性很低

[Alert] Action Quota about to Expire

This is to notify you that your account has consumed 80% of the total Action quota (250) in the Free plan. As and when it crosses the limit, your Bots will be paused automatically.

Please upgrade your plan if you anticipate more usage within the current billing cycle.

方法

类似于ifttt的automate.io可以设置处理条件,自由度也更高,可以接收处理Gmail邮件,但是没找到telegram私有频道的接收app。但是可以用trello来中转达到转发效果。

调用链形式:gmail->automate->Trello->ifttt->telegram

绑定授权的automate.io应用

设置automate.io,进入app界面 授权gmail和Trello应用。注意授权gmail时要选着权限更高的gmail app要不然没有权限读取邮件。

图片5117-ifttt推送gmail新邮件提醒

添加Trello相关List用于接收邮件

  • 在Trello中添加私有看板boards命名为gmail

    图片5118-ifttt推送gmail新邮件提醒

  • 进入gmail看板再添加一个列表List命名为新邮件提醒用来接收邮件

设置automate.io BOT

创建bot

  • 添加gmail触发器

    触发应用Trigger app选择绑定了的Gmail,操作应用Action app选择Trello。
    触发事件Event选择新New EmailLable为Gmail邮件的分类,我这里选择INBOX,也就是所有收件箱。还可以设置Search Filter达到关键字过滤的效果。

  • 添加Trello操作

    选择Add or Update a Card事件,Board和List选择Trello中创建好的名称,gmail和新邮件提醒。title中设置显示的标题[From Email] - [From Name] - [Subject],
    Description描述我这里写入邮件的url https://mail.google.com/mail/u/0/#inbox/[Message ID],方便tg中点击查看。
    其他还有时间,标签的配置都可以自定义。
    如果想要预览邮件内容的话再添加个Trello的Add a Comment操作。

    个人版本不能分享bot,可以参照下面图片配置:

    图片5120-ifttt推送gmail新邮件提醒

automate.io的配置自由度很高,甚至都有存在or不存在的逻辑判断,真的好方便。免费版应该有很多限制,不过足够个人使用了。
这里添加完成之后进行automate.io的BOT测试,发送个邮件,如果Trello的gmail看板中有邮件就算成功一半。

每次有新邮件,让系统自动添加Card到List就好了。邮件标题和email等基本信息作Card名,方便可读。

图片5119-ifttt推送gmail新邮件提醒

上面就是接收新邮件到Trello的List的效果

设置IFTTT

到这里完成最后一步的IFTTT设置就可以把Trello的新Card发送到TG私有频道。如果是第一次使用IFTTT的tg频道的话还需要去关联

  • 设置This为Trello,之后选择Card added to list事件触发

  • 选择看板board,默认个人私有看板是My Boards

  • List name填入新邮件提醒

  • 选择IFTTT的thatTarget chat 选择绑定的tg ifttt频道。

  • 之后再设置tg频道的message消息内容格式

    GMAIL新邮件提醒: <a href="{{Description}}">{{Title}}</a><br>
    <a href="{{CardURL}}">View on Trello</a>
    

实现接收gmail提醒的方式还有很多路径,类似于automate的还可以用Zapier

参考:

Gmail is being removed from IFTTT from ifttt

https://if404.com/archives/2019/04/09/use-ifttt-gmail-dropbox-auto-push-ebook-to-kindle

Matlab一些简单的操作tips

作者:matrix 发布时间:2019年8月12日星期一 分类:零零星星

由于matlab编程偏向于学术方面,对于我这种😍喜欢OOP以及普通字符串操作来说多少的不熟悉和麻烦。
遂记录。

timer定时器操作

类似于javascript的setInterval操作

myTimer = timer('Name','MyTimer',               ...
    'Period',2,                 ... % 2秒钟间隔
    'StartDelay',0,                 ...
    'TasksToExecute',inf,           ...
    'ExecutionMode','fixedSpacing', ...
    'TimerFcn',@myTimerCallback,...
    'ErrorFcn',@(~,thisEvent)exit);%  如果报错 则推出程序

start(myTimer);%启动

function myTimerCallback(hObject, eventdata)
     disp(['run time:: ', datestr(datetime('now'),'yyyy-mm-dd HH:MM:SS') ])
end

删除所有定时器:

delete(timerfindall());

手动抛异常

baseException = MException('MYFUN:BadParameter','Parameter miss');
throw(baseException);

throw函数需要传入异常类。
MException类第一个参数为msgID。必须要有冒号:,名称都可以自定义。
参考:
https://ww2.mathworks.cn/help/matlab/ref/mexception.html

字符串比较

使用strcmp函数进行字符串比较。
不同于使用双等号==,双等号会对字符串中的每个字符进行比较相等,最终返回逻辑数组logical array

if strcmp(str,'timestr')%判断字符串相等
        dis('Content is equal');
   end

多行注释

单行注释使用百分号%
多行注释使用%{...%}

%{
  ...some thing
%}

函数默认参数判断以及设置值

function rel = func(arg1,arg2)
    if exist('arg2', 'var') && ~isempty(arg2)%如果传入arg2参数 且不为空
      bla bla
    end
end

function [result] = func(format)
    if ~exist('format', 'var') %不存在默认参数
        result = '默认参数';
    else
        result = format;
    end
end

exist函数中var表示(变量)类型

https://blog.csdn.net/liuxiabing150/article/details/46519785

删除数组指定下标

list(1) = [];%删除指定的下标的元素

del_index_list = [1 2 9 18]
list(del_index_list) = [];%删除多个下标元素

检测struct结构体字段是否存在

isfield(struct('a','1'),'a1') #判断a1字段是否存在

all(isfield(struct('field1','val1'),{'a','b'}))#判断a,b字段是否都存在

参考:
https://ww2.mathworks.cn/matlabcentral/answers/260295-dynamically-name-a-struct

动态添加struct数据key名称

data = struct();
name = 'Dynamic_Name';
data.(name) = 990;

匿名函数

匿名函数最为回调的处理和调用


% 回调函数的执行 function rel = func(arg1,callback) cb = callback(data);%执行回调函数,传入data数据作为参数 if ~cb bla bla end end %回调函数作为参数来使用 func(arg1,@(data)deal(1)); func(arg1,@(data)[a=1;deal(a);]);%匿名函数执行多条语句 %普通函数作为回调函数 func(arg1,@cb); function rel = cb(data) rel = 1 end

说明:
使用@操作符
deal函数类似于java中的return操作
方括号[]最为数组操作可以防置多条语句来执行

追加保存数据到文件

now = 1583237214;
data_diff = 1;
data_uni_diff = 2;
res = [res;now,data_diff,data_uni_diff];

dlmwrite('chech_diff_time.txt',res,'-append');

-append参数表示追加处理

判断数据类型

class(123) % double
ischar('') % logic true

修改matlab编码集到utf-8

作者:matrix 发布时间:2019年8月11日星期日 分类:零零星星

默认matlab安装会根据系统语言环境来设置文件编码,想设置为utf-8编码反而是件麻烦事。
网上大多都说直接修改lcdata就可以,但是我找了一大圈都没看到里面出现的关键字内容,也试了很多方法都没用。
2017之后版本的lcdata.xml都只是空白的注释文件,其实就需要把lcdata_utf8改为lcdata或者把里面的内容放到lcdata.xml就可以了。

环境: matlab_R2018a for Mac

修改lcdata.xml

Mac lcdata.xml路径:/Applications/MATLAB_R2018a.app/bin/lcdata.xml
windows的话找到安装目录的bin文件夹

<?xml version="1.0" encoding="UTF-8" ?>
<!-- MathWorks Locale Database -->
<!-- File Name: lcdata.xml -->
<!-- Copyright 2007-2016 The MathWorks, Inc. -->
<lcdata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="lcdata.xsd" >
<!-- Note: -->
<!-- This locale database is used to customize the MathWorks locale database. -->

<!-- Codeset entry example -->
<!--    <codeset> -->
<!--        <encoding name="StandardEncodingName" jvm_encoding="JavaEncodingName"> -->
<!--            <encoding_alias name="AliasName"/> -->
<!--        </encoding> -->
<!--    </codeset> -->

<!-- Locale entries example -->
<!--    <locale name="StandardLocaleName" encoding="EncodingName" xpg_name="XpgLocaleName"> -->
<!--        <alias name="AliasName"/> -->
<!--    "region_alias" is only for Mac -->
<!--        <region_alias name="RegionAliasName"/> -->
<!--    </locale> -->

<locale name="zh_CN" encoding="UTF-8" xpg_name="zh_CN.UTF-8"> </locale>

</locale>

在locale标签里面添加<locale name="zh_CN" encoding="UTF-8" xpg_name="zh_CN.UTF-8"> </locale>
之后再重启matlab就好了。

参考:
https://blog.csdn.net/qq_34241498/article/details/90168924