Skip to content

Instantly share code, notes, and snippets.

@boxcore
boxcore / install-php-fpm-service.sh
Last active February 18, 2019 15:42
systemctl形式添加到wdcp下不工作,暂时推荐使用php-fpm 模式
#!/bin/bash
# 自动识别和添加wdcp php-fpm服务
IS_SYSTEMCTL=0
if command -v systemctl >/dev/null 2>&1; then
echo 'exists systemctl'
IS_SYSTEMCTL=1
else
echo 'no exists systemctl'
@boxcore
boxcore / mac-setting.sh
Created October 25, 2018 16:43
mac setting
# 解决MAC合盖耗电问题
# macOS Mojave 待机时多了个 tcpkeepalive 选项,大概会每晚掉电 20% ,关掉后基本就不掉电了。
# 当然,关掉后可能用不了"find my mac"的功能!
sudo pmset -a tcpkeepalive 0
#
@boxcore
boxcore / nginx-vhost.conf
Created October 25, 2018 13:33
nginx域名配置参考
server
{
listen 80;
#listen [::]:80;
server_name mianfeibang.cn www.mianfeibang.cn;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/mianfeibang.cn;
include wordpress.conf;
#error_page 404 /404.html;
@boxcore
boxcore / aria2-install-log.sh
Last active October 25, 2018 13:29
linux aria2 安装脚本(测试)
#!/bin/bash
# install aria2 for centos 6.8
# author: boxcore
# aria2 docs:https://github.com/aria2/aria2
# more gnu project for download : http://ftp.gnu.org/gnu/ ; ftp://gcc.gnu.org/pub/gcc/infrastructure/
#
# aria2 gui tools:
# for mac: https://github.com/yangshun1029/aria2gui/releases
#
yum install bison libssh2-devel expat-devel gmp-devel nettle-devel libuv-devel libssh2-devel zlib-devel c-ares-devel cppunit-devel gnutls-devel libgcrypt-devel libxml2-devel sqlite-devel gettext lzma-devel xz-devel gperftools gperftools-devel gperftools-libs jemalloc-devel
/bin/sh /usr/local/opt/mysql/bin/mysqld_safe --bind-address=127.0.0.1 --datadir=/usr/local/var/mysql
/usr/local/Cellar/mysql/5.7.11/bin/mysqld --basedir=/usr/local/Cellar/mysql/5.7.11 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.7.11/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/mysql-error.log --pid-file=/usr/local/var/mysql/mysql.pid
/bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/3306/my.cnf --user=mysql
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/3306/mysql_run.err --open-files-limit=65536 --pid-file=/data/mysql/3306/pid_mysql.pid --socket=/data/mysql/3306/mysqltmp/mysql.sock --port=3306
@boxcore
boxcore / sql.fn.php
Created October 25, 2018 13:23
php下sql处理函数集合
<?php
/**
* 判断数据保存或插入
*
* @author boxcore
* @date 2016-07-18
* @param object $db 数据库对象
* @param string $table 表名称
* @param array $data 单条数据
* @param array $unque 查询唯一映射
@boxcore
boxcore / file_dir.fn.php
Last active October 24, 2018 04:54
file_dir.fn.php
<?php
/**
* 文件相关处理函数
*
* @created 2016-06-13
* @author boxcore
*/
/**
@boxcore
boxcore / filesum.php
Created June 27, 2018 06:36
php获取文件md5,修改时间、创建时间
<?php
/**
* filesize() 函数在部分 x86 系统上读取大于 2GB 的文件会返回错误的值
*/
$file = "./testfile";
if(!file_exists($file)){
echo "File don't exist! please check: {$file}\n";
@boxcore
boxcore / lftp-sync.sh
Created March 12, 2018 16:46
lftp to sync
#!/bin/bash
# 通过lftp同步范例
echo Script start at: `date +%Y-%m-%d %H:%M:%S`
HOST='your_ip'
USER='user_name'
PASS='pass_word'
LCD='/home/your_name/hkftp'
RCD='/'
/usr/sbin/lftp -u $USER,$PASS -e "mirror --delete --only-newer --verbose $RCD $LCD" $HOST
echo Script end at: `date +%Y-%m-%d %H:%M:%S`
@boxcore
boxcore / php-ajax.php
Created July 26, 2017 11:25 — forked from pratikdhaboo/php-ajax.php
PHP cross-domain AJAX
<?php
// To be added to top of php file which serves the AJAX Request
// Checks for HTTP_ORIGIN against multiple domains
$http_origin = $_SERVER['HTTP_ORIGIN'];
if ($http_origin == "http://www.domain1.com" || $http_origin == "http://www.domain2.com" || $http_origin == "http://www.domain3.info")
{
header('Access-Control-Allow-Origin: *');
}