Skip to content

Instantly share code, notes, and snippets.

@luxixing
luxixing / php-pdo-helper.php
Last active April 23, 2019 20:40
PHP-PDO Class
<?php
/**
* 轻量级pdo操作封装函数
* @author xixing.lu@outlook.com
* @version 2013-04-16
* @todo 根据实际情况继续优化或者添加功能
*/
namespace dataservice\helper;
class PDOHelper
@luxixing
luxixing / cmd.sh
Created June 22, 2013 15:31
一些常用sh命令收集
#将本地生成的公匙写入到远端服务器的验证文件中,实现无密码登录
cat ~/.ssh/id_rsa.pub | ssh user@host "cat - >> ~/.ssh/authorized_keys"
#生成ssh密匙命令在当前用户家目录
ssh-keygen
#显示系统有多少用户
cat /etc/passwd | cut -d: -f1
#ssh登陆之后执行一个命令
ssh -t root@10.1.1.169 "cd /data ; bash"
@luxixing
luxixing / php-configure.sh
Created June 23, 2013 02:27
php编译选项 报错一般就是扩展依赖的库不存在,查找并且安装即可
./configure\
--with-config-file-path=/usr/local\
--with-config-file-path=/usr/local/etc/php\
--enable-fpm\
--with-fpm-user=php-fpm\
--with-fpm-group=php-fpm\
--enable-mysqlnd\
--with-mysqli\
--with-pdo-mysql\
--with-mysql=mysqlnd\
<?php
// No, Thanks. Direct file access forbidden.
! defined( 'ABSPATH' ) AND exit;
// INIT
add_action( 'after_setup_theme', array( 'unavailable_post_status', 'init' ) );
class unavailable_post_status extends wp_custom_post_status
{
/**
@luxixing
luxixing / audition.php
Last active December 19, 2015 18:19
面试题答案
1 打印前一天时间
<?php
echo date("Y-m-d H:i:s", strtotime("-1 days"));
?>
2 过滤html代码
如果此题单纯值的html代码,则 htmlspecialchars($str),处理输入存储
如果包含用户输入过滤,则sql语句防注入,过滤关键词,使用pdo的时候prepare sql语句 ' 转义
还有和谐社会的关键词过滤(这个非技术而属于政治了)
php 原生 Filler 族函数能做相当一部分工作,可在此基础上扩展一个过滤类
@luxixing
luxixing / nginx-confgiure.sh
Created July 26, 2013 11:07
nginx 编译安装选项 google 的工具单独安装
./configure --prefix=/usr/local\
--conf-path=/usr/local/etc/nginx/\
--user=nginx\
--group=www\
--with-http_ssl_module\
--with-http_realip_module\
--with-http_gunzip_module\
--with-google_perftools_module
@luxixing
luxixing / nginx-startup.sh
Created August 6, 2013 10:44
nginx 开启启动脚本
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@luxixing
luxixing / mysl-init-script.sh
Created August 7, 2013 01:46
mysql install after run the init-db shell script
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql-5.6.13/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql-5.6.13/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
@luxixing
luxixing / 常见问题碎片
Created August 15, 2013 03:17
常见问题汇总
1 php json_encode
假设encode编码的源数据是 : array(1,2,3,4,5,5),那么json_encode的结果是数组
假设encode编码的源数据是:array(1=>1,2=>3),那么json_encode的结果是对象
json_encode默认把关联数组编码为对象
这个细节在和前端js交互传递数据的时候非常重要
@luxixing
luxixing / vimrc.sh
Created September 16, 2013 06:10
vim 配置文件 文件位置: ~/.vimrc 依赖于vundle 深入学习vimscript,了解工具的定制 安装 git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 创建 .vimrc文件在$HOME 目录,编辑完毕 :source .vimrc 然后 BundleInstall 安装插件 请继续优化完善该脚本打造自己的php-ide
"==========================================
" Author: wklken
" Version: 6
" Email: wklken@yeah.net
" BlogPost: http://wklken.me
" ReadMe: README.md
" Last_modify: 2013-08-04
" Github: " https://github.com/wklken/k-vim
" Sections:
" ->General 基础设置