Giter Club home page Giter Club logo

blog's People

Contributors

aaasayok avatar wzhanjun avatar

Watchers

 avatar

blog's Issues

Fastadmin后台操作

自定义批量删除


 $(document).on("click", "#toolbar .btn-del-multi", function () {
    var that = this;
    var ids = Table.api.selectedids(table);
    layer.confirm(
        __('确定删除选中的 %s 项吗?', ids.length),
        {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
        function (index) {
            Fast.api.ajax({
                url: $.fn.bootstrapTable.defaults.extend.multi_del_url,
                data: {ids: ids.join(',')}
            }, function (data, ret) {
                Toastr.success("操作成功");
                $(".btn-refresh").trigger("click");
                return false;
            }, function (data, ret) {
                Toastr.error(ret.msg);
                return false;
            });
            layer.close(index);
        }
    );

});


php curl ssl证书

wget https://curl.haxx.se/ca/cacert.pem
curl.cainfo="/etc/php7.0/cacert.pem"
openssl.cafile="/etc/php7.0/cacert.pem"

PHPExcel A4纸张打印

$objPHPExcel = new PHPExcel();

// Set Orientation, size and scaling
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToPage(true);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);

// Generate spreadsheet
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');

参考:
http://www.craiglotter.co.za/2010/04/18/setting-your-worksheet-printing-layout-options-in-phpexcel/

ffmpeg 学习

// m3u8 
  ffmpeg -i playlist.m3u8  -vcodec copy -acodec copy -absf aac_adtstoasc  out.mp4

  // ffmpeg m3u8 转mp4
  ffmpeg -i playlist.m3u8 -c copy  output.mp4


  // 从第10s 开始截取
  ffmpeg -ss 10 -i  playlist.m3u8 -c copy  00003.mp4

  // 截取前10s

   ffmpeg  -i playlist.m3u8 -c copy -t 10 00004.mp4

   // 转换视频的分辨率 640:360
   ffmpeg -i video_1920.mp4 -vf scale=640:360 video_640.mp4 -hide_banner

   // 转换分辨率 同时设置视频的宽高比
   ffmpeg -i video_1920.mp4 -vf scale=640:480,setdar=4:3 video_640x480.mp4 -hide_banner

    // ffmpeg 转mp3
    ffmpeg -i 52a8b8ccded5ddb4c40bf350dff089aa2ad2efe6_v1.mp4 -f mp3 -vn  522.mp3

    // ffmpeg 抽取音频
    ffmpeg -i 3.mp4 -vn -y -acodec copy 3.aac

neo4j 数据查询

1. 两点之间的关系查询

MATCH (m1:member),(m2:member), 
p = shortestPath((m1)-[:Invite*]-(m2)) 
WHERE (m1.uid) = 100000 AND (m2.uid) = 10133947
return p

从.git文件夹中恢复git仓库

cd repo.git

创建budele文件

git bundle create ./reponame.bundle --all

从bundle文件中clone出代码

git clone ./reponame.bundle reponame

这是文件夹内会出现一个 reponame 文件夹,这个文件夹内就是所有的代码文件

并且还可以恢复其他分支的代码

git clone -b release ./reponame.bundle reponame

新建新的git仓库 名为 newrepo

git remote rm origin

url.git 为新的git仓库地址

git remote add origin newrepo.git

参考:https://zhuanlan.zhihu.com/p/45289391

js 日期转换

js 日期转换

function getWeekNumber(d) {
    // Copy date so don't modify original
    d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
    // Set to nearest Thursday: current date + 4 - current day number
    // Make Sunday's day number 7
    d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7));
    // Get first day of year
    var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
    // Calculate full weeks to nearest Thursday
    var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
    // Return array of year and week number
    return [d.getUTCFullYear(), weekNo];
}

Date.prototype.format = function(fmt) {
    var o = {
        "M+" : this.getMonth()+1,                 //月份
        "d+" : this.getDate(),                    //日
        "h+" : this.getHours(),                   //小时
        "m+" : this.getMinutes(),                 //分
        "s+" : this.getSeconds(),                 //秒
        "q+" : Math.floor((this.getMonth()+3)/3), //季度
        "S"  : this.getMilliseconds()             //毫秒
    };
    if(/(y+)/.test(fmt)) {
        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    }
    for(var k in o) {
        if(new RegExp("("+ k +")").test(fmt)){
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
        }
    }
    return fmt;
}

function getDateOfISOWeek(w, y) {
    var simple = new Date(y, 0, 1 + (w - 1) * 7);
    var dow = simple.getDay();
    var ISOweekStart = simple;
    if (dow <= 4)
        ISOweekStart.setDate(simple.getDate() - simple.getDay() + 1);
    else
        ISOweekStart.setDate(simple.getDate() + 8 - simple.getDay());
    return ISOweekStart.format("yyyy-MM-dd");
}




chrome技巧

chrome 技巧

  • 开启多线程下载

    Chrome 浏览器,地址栏输入并回车:chrome://flags/#enable-parallel-downloading
    Edge 新版浏览器,地址栏输入并回车:edge://flags/#enable-parallel-downloading

监听弹窗关闭事件

table.on('post-body.bs.table', function (e, settings, json, xhr) {
        $(".btn-edit").data("end", function(){
            $('.btn-refresh').trigger("click");
        });
    });

goaccess的使用

goaccess 使用

1. 项目地址

https://goaccess.io/get-started

2. 安装


$ wget http://tar.goaccess.io/goaccess-1.2.tar.gz
$ tar -xzvf goaccess-1.2.tar.gz
$ cd goaccess-1.2/
# --with-openssl项开启openssl,HTTPS时需要
$ ./configure --enable-utf8 --enable-geoip=legacy --with-openssl
$ make
$ make install

[配置](https://goaccess.io/faq#configuration)
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

3. 操作方法


F1   主帮助页面
F5   重绘主窗口
q    退出
1-15 跳转到对应编号的模块位置 
o    打开当前模块的详细视图
j    当前模块向下滚动
k    当前模块向上滚动
s    对模块排序
/    在所有模块中搜索匹配
n    查找下一个出现的位置
g    移动到第一个模块顶部
G    移动到最后一个模块底部

4 使用

goaccess access.log --log-format=COMBINED

goaccess -f access.log -o output.html

参考

https://segmentfault.com/a/1190000016383026
https://ericdraken.com/goaccess-web-log-analyzer-installation-centos/

git 学习

0. ssh-keygen

ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa <<< y

1. 设置git ui

git config --global color.ui true

2. 设置git编辑器

git config --global core.editor vim

3. 批量删除tag

git tag | grep "v" |xargs git tag -d

4. 查看缓冲区变更

git diff --cached
git diff --staged

5. 查看改变的文件列表简化版

git status -s

6. git 提交日志

git log --name-status 每次修改的文件列表, 显示状态
git log --name-only 每次修改的文件列表
git log --stat 每次修改的文件列表, 及文件修改的统计
git whatchanged 每次修改的文件列表
git whatchanged --stat 每次修改的文件列表, 及文件修改的统计
git show 显示最后一次的文件改变的具体内容
git show -5 显示最后 5 次的文件改变的具体内容
git show commitid 显示某个 commitid 改变的具体内容

7 清理无效分支

# 查看清理分支
git remote prune origin --dry-run
# 清理分支
git remote prune origin

8 忽略文件

# 忽略文件
git update-index --assume-unchanged
# 取消忽略
git update-index —no-assume-unchanged  
#  查看忽略
git ls-files -v| grep '^h\ '
##  跳过工作树
git update-index --skip-worktree $filename
## 取消跳过工作树
git update-index --no-skip-worktree path
## 查看 跳过工作树
git ls-files -v | grep -i ^S 

docker 命令整理

docker 网络命令

  • 查看docker中存在的网络:

     docker network ls
    
  • 查看bridge网络的详细配置:

     docker network inspect bridge
    
  • 创建了一个名为"my-net"的网络

    docker network create my-net 
    
  • 将Web服务加入my-net网络中

    docker network connect my-net test_demo  
    
  • 断开容器与docker0的连接

     docker network disconnect bridge test_demo   
    

plupload组件上传

plupload 新增过滤器


   // 添加过滤
    Plupload.addFileFilter('width_height', function(data, file, cb) {
        var self = this, img = new moxie.image.Image();
        function finalize(result) {
            // cleanup
            img && img.destroy();
            img = null;

            // if rule has been violated in one way or another, trigger an error
            if (!result) {
                self.trigger('Error', {
                    code : Plupload.IMAGE_DIMENSIONS_ERROR,
                    message : "图片尺寸不一致, 尺寸要求, 宽:" + data.width + "px, 高: " + data.height + " px.",
                    file : file
                });
            }
            cb(result);
        }
        img.onload = function() {
            // check if resolution cap is not exceeded
            console.log("image:", img.width, img.height, "data:", data)
            var result = true;
            if (data.width > 0 && data.height > 0) {
                result = (img.width == data.width) && (img.height == data.height)
            }
            finalize(result);
        };
        img.onerror = function() {
            finalize(false);
        };
        img.load(file.getSource());
    });


参考:
https://chaping.github.io/plupload/doc/#plupload_doc2
https://www.coder.work/article/2253194
https://blog.sylingd.com/archives/271.html

MYSQL 笔记

mysql 笔记

  • 查询重复数据

     Select * From 表 Where 重复字段 In (Select 重复字段 From 表 Group By 重复字段 Having Count(*)>1)
    

安装教程

MySQL 用户授权

1. 普通用户授权

create user zhangsan identified by 'zhangsan';
grant all privileges on zhangsanDb.* to zhangsan@'%' identified by 'zhangsan';
flush privileges;

2. 备份用户授权

mysql> CREATE USER back_user IDENTIFIED BY '123456';
mysql> GRANT SELECT,RELOAD,SHOW DATABASES,LOCK TABLES,EVENT,REPLICATION CLIENT  ON *.* TO 'back_user'@'192.168.0.203' IDENTIFIED BY '123456'; 
mysql> FLUSH PRIVILEGES;

https://www.linuxhub.org/?p=2579

phpstorm hotkey

  • Ctrl+Alt+O. 去掉无效的use
  • Ctrl+J 快速选中相同单词
  • Ctrl+Alt+Shift+J 快速选中所有相同单词

nginx常见问题

nginx常见问题

数据被截断(返回数据不完整)

      1、首先查看nginx的error日志,会有报错提示,类似:nginx的目录明下的文件 failed(13: Permission denied) while reading upstream, client:...,server

      2、看报错提示是没有权限,原因就是nginx存在一个buffer的机制,在数据过大超出缓冲区的最大容量,会将数据写入临时文件(临时目录),而此时如果你安装的nginx的用户权限不是服务器权限,就会报没有权限的问题,因为此时没有权限,所以再返回时,超出缓冲区的数据将丢失,就会出现截断。

     3、最后将nginx的目录赋予权限就可以了

     4、执行操作:

          sudo chown -R www:root nginx目录名称
          chmod -R  764 /usr/local/nginx/临时目录名称

    fastcgi_buffer 8 128;此处代表nginx设置8个128k的块进行缓存,总共大小是8*128k

    fastcgi_buffer_size 128k; 此处代表每块大小,用于指定读取fastcgi应答第一部分需要用多大的缓冲区,这个值表示将使用1个128kb的缓冲区读取应答的一部分(应答头),可以设置为fastcgi_buffers选项指定的缓冲区大小。

    fastcgi_buffers : 指定本地需要用多少和多大的缓冲区来缓冲FastCGI的应答请求。如果一个PHP脚本所产生的页面大小为256KB,那么会为其分配4个64KB的缓冲区来缓存;如果页面大小大于256KB,那么大于256KB的部分会缓存到fastcgi_temp指定的路径中,但是这并不是好方法,因为内存中的数据处理速度要快于硬盘。一般这个值应该为站点中PHP脚本所产生的页面大小的中间值,如果站点大部分脚本所产生的页面大小为256KB,那么可以把这个值设置为“16 16k”、“4 64k”等。



参考:
https://www.codenong.com/cs106772846/
https://segmentfault.com/a/1190000007513677

Qrcode生成二维码

const qrcode = new QRCode(document.createElement('div'), {
	text: "http://jindo.dev.naver.com/collie",
	width: 128,
	height: 128,
	colorDark : "#000000",
	colorLight : "#ffffff",
	correctLevel : QRCode.CorrectLevel.H
});
qrcode._oDrawing._elImage.onload = ev => { 
    console.log(ev.target.src);
}

以太坊开发

文档

PHP工具库

测试

教程

其他

目前交易所的以太坊代币的方案是这样的:
1、给每一个账号分配一个唯一的以太坊钱包地址
2、用户充币往分配给他们的钱包中转币,设置监控程序,检测到他们的钱包有入账记录就给账号中增加响应的充值金额
3、用户提币:用户提交提币申请然后进行扣币,后台通过一个指定钱包地址(称为主钱包)向用户的提币钱包中转账

linux ssh

linux ssh 配置

ssh-keygen -f  xxx       #生成指定的文件名xxx    

  ssh-copy-id -i .ssh/id_rsa.pub  [email protected]

.ssh 目录新增/编辑 config文件

    HOST  name
    HostName   192.168.x.xxx
    IdentityFile ~/.ssh/xxx

docker php扩展编译

1. 编译安装mongodb.so

RUN pecl install mongodb \
&&  echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/mongo.ini

注:需先安装openssl
 apt-get install libssl-dev
 yum install -y openssl openssl-devel

参考:https://stackoverflow.com/questions/49894623/why-docker-php-ext-install-does-not-contains-some-extensions-and-has-it-advanta

2. 编译GD

RUN apt-get update && apt-get install -y libpng-dev
RUN apt-get install -y \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev libxpm-dev \
libfreetype6-dev

RUN docker-php-ext-configure gd \
--with-gd \
--with-webp-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-xpm-dir \
--with-freetype-dir

RUN docker-php-ext-install gd

遇到php-fpm:7.2版本gd库一直没有安装freetype

参考:https://www.coder.work/article/891126

linux 笔记

命令

  • 快速禁用用户(username是你想锁住的用户)

    sudo passwd -l username
    
  • 重新启用账户(username是你想锁住的用户)

    sudo passwd -u username
    

软件安装

  • ifconfig: command not found

     yum install net-tools
    

查看文件或磁盘大小

df -h
du -hd 1 . | sort -hr

其他教程

vim

  1. 编辑文件时readonly

    :w !sudo tee %
    
  2. 在文件插入当前路径

    :r !pwd

Js 下载文件


fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(resp => resp.blob())
  .then(blob => {
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.style.display = 'none';
    a.href = url;
    // the filename you want
    a.download = 'todo-1.json';
    document.body.appendChild(a);
    a.click();
    window.URL.revokeObjectURL(url);
    alert('your file has downloaded!'); // or you know, something with better UX...
  })
  .catch(() => alert('oh no!'));


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
     <button onclick="GetFile()">下载</button>
     <script>
         // 会先下载流,完成后才弹出选择目录,所以最好加上进度条
         function GetFile(){
             axios({
                 url: `http://image.wangrui8.top/dms-2019-07-22-00-00~1.mp4`,
                 method: 'get',
                 responseType: 'blob',
                 onDownloadProgress (progress){
                     // 这里是下载的进度
                    console.log(Math.round(progress.loaded / progress.total * 100) + '%');
                 },
             })
                 .then(res=>{
                    let blobUrl = window.URL.createObjectURL(res.data);
                    let link = document.createElement('a');
                    document.body.appendChild(link);
                    link.href = blobUrl;
                    link.download = '下载文件.mp4';
                    link.click();
                    window.URL.revokeObjectURL(blobUrl);
                 })
         }
     </script>
</body>
</html>

参考:
https://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery
https://my.oschina.net/u/4342183/blog/3419827

thinkphp+nginx+pathinfo

    location / {
        if (!-e $request_filename) {
             rewrite  ^(.*)$  /index.php?s=/$1  last;
             break;
        }
     }

  location ~ .*\.(php|php5)(.*)?$ {
        fastcgi_pass   php-fpm:9000;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include        fastcgi_params;
    }

php预编译异常解决办法搜罗

 './configure'  '--prefix=/usr/local/php73' '--with-config-file-path=/usr/local/php73/etc' '--with-config-file-scan-dir=/usr/local/php73/etc/php.d' '--with-fpm-user=www' '--with-fpm-group=www' '--enable-fpm' '--enable-opcache' '--disable-fileinfo' '--enable-mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir=/usr/local' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-exif' '--enable-sysvsem' '--with-curl' '--enable-mbregex' '--enable-inline-optimization' '--enable-mbstring' '--with-mcrypt' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-ftp' '--enable-intl' '--with-xsl' '--with-gettext' '--enable-zip' '--enable-soap' '--disable-ipv6' '--disable-debug'

富文本编辑器手机端展示

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <style> html,body{ height:100%; width:100%; padding:0; margin:0; } #content{ width:90%; height:100%; padding:0; margin:10px auto; } </style>
</head>
<body>
    #CONTENT
</body>
    <script> var imgs = document.getElementsByTagName('img'); for(var i in imgs) { var img = imgs[i]; img.style.width='100%'; img.style.height='auto'; } </script>
</html>


[参考]
https://blog.csdn.net/xm393392625/article/details/88217958

mongo

mongo 查询

## 模糊查询
db.getCollection("tencent_group_message").find({"msg_body.MsgContent.Text": /red/});

## 右侧模糊 xx%
db.getCollection("tencent_group_message").find({"msg_body.MsgContent.Text": /^red/});

## 不区分大小写
db.getCollection("tencent_group_message").find({"msg_body.MsgContent.Text": /red/i});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.