作者归档:ning

Android SDK常用命令(adb,sdkmanager,uiautomatorviewer,avdmanager,apkanalyzer)

adb

通过ADB命令获取当前activity

方法1:logcat实时查看

  1. cmd命令中输入:adb shell 进入shell命令模式
  2. shell中输入:logcat | grep ActivityManager 真机运行应用,可以实时 查看当前正在运行的Activity;

    ActivityManager: START u0 {flg=0x20000000 cmp=com.tencent.mm/.plugin.webview.ui.tools.WebviewMpUI (has extras)} from uid 10163

其中com.tencent.mm是包名,.plugin.webview.ui.tools.WebviewMpUI为运行的Activity

方法2:cmd命令中输入:adb shell 'dumpsys activity activities | grep Intent'

Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.mm/.ui.LauncherUI }
Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10800100 cmp=com.miui.home/.launcher.Launcher }
Intent { flg=0x10804000 cmp=com.android.systemui/.recents.RecentsActivity bnds=[48,796][516,1481] (has extras) }

Arch linux / manjaro开启bbr

查看内核版本号

uname -r

如果内核版本大于等于4.9可以直接开启

检查bbr模块是否存在

然后使用命令modinfo tcp_bbr查看内核模块是否存在。

modinfo tcp_bbr

开启bbr模块

sudo  modprobe tcp_bbr

下次自动开启

默认没有开启,自动开启

echo "tcp_bbr" > /etc/modules-load.d/80-bbr.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/80-bbr.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.d/80-bbr.conf

立即加载

sysctl -p 

检查是否成功

sysctl net.ipv4.tcp_congestion_control

Mysql不锁表增加字段和索引方法

看了网上很多回答,基本都是过时和错误的。

5.6 以后增加了ONLINE DDL,

实现不锁表增加字段和索引非常简单。

解决办法

ALTER TABLE `member` ADD `user_from` smallint(1) NOT NULL, ALGORITHM=INPLACE, LOCK=NONE

ALGORITHM表示算法:default默认(根据具体操作类型自动选择),inplace(不影响DML),copy创建临时表(锁表),INSTANT只修改元数据(8.0新增,在修改名字等极少数情况可用)

LOCK表示是否锁表:default默认,none,shared共享锁,exclusive

什么情况下会inplace,什么情况下会copy?

什么情况下会inplace,什么情况下会copy,具体参考:Online DDL Operations

5.6以前版本解决办法

参考

打印队列监控(拦截+取消+状态获取)(附C#,C++,VB实现)

Print Spooler API

https://docs.microsoft.com/zh-cn/windows/win32/printdocs/print-spooler-api

The Print Spooler API provides an interface to the print spooler for applications to manage printers and print jobs.

The Print Spooler API is used by an application as part of its programming and not directly by end users.

PrintQueue.GetPrintJobInfoCollection Method

Creates a collection that contains a PrintSystemJobInfo object for each job in the queue.

https://docs.microsoft.com/en-us/dotnet/api/system.printing.printqueue.getprintjobinfocollection?view=netframework-4.8

"Virtual Printer" or "Moving Printjobs" (C++)

https://cboard.cprogramming.com/windows-programming/108156-virtual-printer-moving-printjobs.html

Monitor jobs in a printer queue (C# .NET)

https://www.codeproject.com/Articles/51085/Monitor-jobs-in-a-printer-queue-NET

Monitoring a Printer Queue from VB.NET

https://www.codeproject.com/Articles/3313/Monitoring-a-Printer-Queue-from-VB-NET

内网穿透工具比较(ngrok,frp,lanproxy,goproxy,nps)

从是否有API,客户端单独key,子域名,收费模式,采用语言,github stars多个维度比较了ngrok, frp, lanproxy, goproxy, nps几款内网穿透工具

file

ngrok

https://github.com/inconshreveable/ngrok

frp

https://github.com/fatedier/frp

lanproxy

https://github.com/ffay/lanproxy

goproxy

https://github.com/snail007/goproxy

nps

https://github.com/cnlh/nps

综合比较后发现nps比较符合需求,但是目前版本(0.23)存在稳定性问题,作者打算在未来版本收费

centos下supervisor安装和使用

安装

dnf update -y
dnf install supervisor
sytemctl enable supervisord

配置

vim /etc/supervisor/xxx.conf

    [program:testprogram]
    directory = /root/go/src/test
    command = /root/go/src/test/bin/server
    autostart = true
    startsecs = 5
    autorestart = true
    startretries = 3
    user = root
    redirect_stderr = true
    stdout_logfile = /var/log/supervisor/test.log

使用

supervisorctl reload
supervisorctl start xxx
supervisorctl status

微信小程序抽奖平台源码(4套)

一,https://github.com/tuoxie15/LuckDrawProgram

    页面

├── home                   首页 奖品列表页
├── luckDraw               奖品详情页 抽奖页
├── personalCenter         个人中心 我参加的抽奖、中奖纪录、收货地址
├── past                   我参与过的抽奖页 待开奖、已结束
├── prize                  中/未中奖展示页、分享页、通过通知点进去展示页
├── record                 中过奖的记录页
├── portraitList           头像列表
├── FLBRecord              福利分领取记录
├── exchangeDetails        兑换商品详情
├── exchangeRecord         兑换商品记录
├── rankingList            排行榜
├── strategy               赚币攻略
|—— getMoreFLC             福利分页面 获得更多福利分
|—— historyDraw            历史抽奖
|—— sponsor                成为赞助商
|—— feedBack               意见反馈

二,https://github.com/ezshine/mp_luckydraw

一套微信小程序抽奖平台(包含全部前后端源码)

功能介绍

1、口令抽奖: 大家都知道小程序的限制颇多,不能引导回公众号,即使关联跳转小程序,也有数量限制。口令抽奖一来可以限制参与抽奖的人,二来可以通过口令提示引导回公众号下发口令,带动关注。

2、限定地点: 我希望这个小程序未来也可以帮助线下的商户发起抽奖活动,那么做一个参与的位置电子围栏是很有必要的。

3、限定性别: 不多解释

4、条码解锁: 这个的思路也很好玩,让抽奖活动需要触发扫描特定的条形码方可参与。那么自然特别适合快速消费品品牌来玩。

5、RP币

三,https://github.com/ifanrx/hydrogen-lottery-miniprogram

知晓云抽奖小程序

四,https://github.com/wang-binbin/smallAppsLottery

golang交叉编译

Windows主机编译Linux,MAC客户端

Windows主机编译Windows客户端

SET CGO_ENABLED=0
SET GOOS=windows
SET GOARCH=amd64
go build -o client-windows.exe main.go

Windows主机编译LINUX客户端

SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build -o client-linux main.go

Windows主机编译MAC客户端

SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build -o client-mac main.go

Linux主机编译Widows,MAC客户端

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o client-linux main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o client-mac main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o client-windows.exe main.go

MAC主机编译Widows,linux客户端

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o client-linux main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o client-mac main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o client-windows.exe main.go

PHP7.3 zts(线程安全)编译以及多线程(pthreads)使用

下载PHP

下载地址:https://www.php.net/downloads.php,开始下载:

su root
mkdir tmp
cd tmp
wget https://www.php.net/distributions/php-7.3.7.tar.bz2

编译安装PHP开启线程安全

tar -jxvf php-7.3.7.tar.bz2
cd php-7.3.7
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libicu-devel

编译

./configure \
--prefix=/usr/local/php-7.3.7-ts \
--enable-maintainer-zts \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-bcmath \
--enable-exif \
--enable-intl \
--enable-mbstring \
--enable-pcntl \
--with-pdo-mysql \
--enable-sockets \
--enable-mysqlnd \
--with-gd

然后:

make && make install

更新autoconf

Autoconf version 2.68 or higher is required错误是才需要此步骤

wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar -zxvf autoconf-latest.tar.gz 
cd autoconf-2.69/
.configure
make
make install
autoconf --version 

安装pthreads

git clone https://github.com/krakjoe/pthreads.git
cd pthreads
/usr/local/php-7.3.7-ts/bin/phpize
./configure --with-php-config=/usr/local/php-7.3.7-ts/bin/php-config
make
make install

修改 /usr/local/php-7.3.7-ts/lib/php.ini,增加 extension=pthreads

测试pthreads

/usr/local/php-7.3.7-ts/bin/php worker.php

<?php

class MyWorker extends Worker
{
    public $id;
    public $time;

    public function __construct($id, $time)
    {
        $this->id = $id;
        $this->time = $time;
    }

    public function run()
    {
        while (true) {
            echo sprintf(worker %s is running, %s\n, $this->id, date('Y-m-d H:i:s'));
            sleep($this->time);
        }
    }
}

class MyManager
{
    /**
     * @var MyWorker[]
     */
    protected $workers;

    public function add(MyWorker $work)
    {
        $this->workers[$work->id] = $work;
        echo 'add worker' . $work->id . \n;
    }

    public function run()
    {
        foreach ($this->workers as $id => $work) {
            echo 'run worker' . $work->id . \n;
            $work->start();
        }
    }
}

$manager = new MyManager();
$manager->add(new MyWorker('1', 1));
$manager->add(new MyWorker('2', 3));
$manager->run();