编程经验分享

笑看嫣红染半山,
逐风万里白云间,
逍遥此身不为客,
天地三才任平凡。

0%

用ffmpeg转换mov到mp4

This is my personal list of functions that I wrote for converting mov files to mp4!

Command Flags

Flag Options Description
-codec:a libfaac, libfdk_aac, libvorbis Audio Codec
-quality best, good, realtime Video Quality
-b:a 128k, 192k, 256k, 320k Audio Bitrate
-codec:v mpeg4, libx264, libvpx-vp9 Video Codec
-b:v 1000, 2500, 5000, 8000 Video Bitrate
-vf scale -1:X Resize Video (X is height)
-qmin 10 -qmax 42 ??? I don’t really know what is this for, help related to this is welcome…
阅读全文 »

安装MariaDB10.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# cd /etc/yum.repos.d/
# vi MariaDB.repo
[root@centos7 yum.repos.d]# cat MariaDB.repo
[mariadb]
name = MariaDB
#baseurl = http://yum.mariadb.org/10.2.7/centos7-amd64
#gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
baseurl = http://mirrors.shu.edu.cn/mariadb/yum/10.2/centos7-amd64/
gpgkey=http://mirrors.shu.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
# yum install mariadb-server maridb-client
# systemctl enable mariadb
# systemctl start mariadb
# systemctl status mariadb

升级数据库

1
# mysql_upgrade -uroot -p

重置root密码

1
2
3
4
5
6
7
8
9
# systemctl stop mariadb
# mysqld_safe --skip-grant-tables --skip-networking &
# mysql -u root
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit;
# kill `cat /var/lib/mysql/centos7.pid`
# systemctl start mariadb

firewalld概述

动态防火墙后台程序 firewalld 提供了一个 动态管理的防火墙,用以支持网络 “ zones” ,以分配对一个网络及其相关链接和界面一定程度的信任。它具备对 IP v4 和 IP v6 防火墙设置的支持。它支持以太网桥,并有分离运行时间和永久性配置选择。它还具备一个通向服务或者应用程序以直接增加防火墙规则的接口。

系统提供了图像化的配置工具firewall-config(rhel7)、system-config-firewall(rhel6), 提供命令行客户端firewall-cmd, 用于配置 firewalld永久性或非永久性运行时间的改变:它依次用 iptables工具与执行数据包筛选的内核中的 Netfilter通信。

阅读全文 »

在centos7下面安装laravel5.6的时候,需要使用vue和bulma,用npm install安装的时候出现下面的错误信息:

1
2
3
4
5
6
7
8
9
10
11
12
> pngquant-bin@4.0.0 postinstall /export/home/geoseu/monitor/node_modules/pngquant-bin
> node lib/install.js

⚠ The `/export/home/geoseu/monitor/node_modules/pngquant-bin/vendor/pngquant` binary doesn't seem to work correctly
⚠ pngquant pre-build test failed
ℹ compiling from source
✔ pngquant pre-build test passed successfully
✖ MaxRedirectsError: pngquant failed to build, make sure that libpng-dev is installed
at ClientRequest.fn.request.res (/export/home/geoseu/monitor/node_modules/pngquant-bin/node_modules/got/index.js:69:23)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)

yum install libpng-devel安装后还是一样的错误。

最后参考https://stackoverflow.com/questions/29930978/node-js-imagemin-on-centos得到答案,pngquant用的libpng-devel的版本不对。

5月19日备注:不能删除原有的版本,否则nginx会因为缺少模块而无法启动。
# yum remove libpng libpng-devel

1
2
## 先卸载原来的版本,再安装适合的版本
# yum install libpng12-1.2.50-10.el7.x86_64 libpng12-devel-1.2.50-10.el7.x86_64

用上面这个重新安装后就OK了。

1
2
3
//====把 "小" 转成 "小"  范例: (必须查看网页源代码)
$T = '小';
$unicode = '&#' . base_convert(bin2hex(iconv("utf-8", "ucs-4", $T)), 16, 10) . ';';
1
2
//====把 "小" 转回 "小" 范例:
$str = mb_convert_encoding($unicode, 'UTF-8', 'HTML-ENTITIES');

转自:阮一峰的网络日志

一、定时任务

所谓定时任务,就是未来的某个或多个时点,预定要执行的任务,比如每五分钟收一次邮件、每天半夜两点分析一下日志等等。

Linux 系统通常都使用 cron 设置定时任务,但是 Systemd 也有这个功能,而且优点显著。

  • 自动生成日志,配合 Systemd 的日志工具,很方便除错
  • 可以设置内存和 CPU 的使用额度,比如最多使用50%的 CPU
  • 任务可以拆分,依赖其他 Systemd 单元,完成非常复杂的任务
阅读全文 »


  1. Make sure that “Enable access for assistive devices” is checked in System Preferences>>Universal Access. It is required for the AppleScript to work. You may have to reboot after this change (it doesn’t work otherwise on Mac OS X Server 10.4).
阅读全文 »

常用方式

  • 最简单的方式是直接用print输出变量
1
2
3
4
5
6
7
8
9
>>> q = 459
>>> p = 0.098
>>> print(q, p, p * q)
459 0.098 44.982
>>> print(q, p, p * q, sep=",")
459,0.098,44.982
>>> print(q, p, p * q, sep=" :-) ")
459 :-) 0.098 :-) 44.982
>>>
  • 也可以先用字符串连接符把所有变量连接成字符串后再输出
1
2
3
>>> print(str(q) + " " + str(p) + " " + str(p * q))
459 0.098 44.982
>>>

显然,第二种方法比第一种方法更差。

阅读全文 »