Skip to content

Instantly share code, notes, and snippets.

View liujingyu's full-sized avatar

jingyu liu liujingyu

View GitHub Profile
@liujingyu
liujingyu / Tools
Last active August 29, 2015 14:20
Tools 使用总结
[编辑器: vim]
插件
ShowTrailingWhitespace, ack.vim, calendar.vim, ctrlp.vim, delimitMate,
indentLine, nerdcommenter, nerdtree, rsynccreatefile, snipmate.vim,
syntastic, tabular, tagbar, thrift, vim-easymotion, vim-fugitive,
vim-matchit, vim-multiple-cursors, vim-pathogen, vim-php-cs-fixer,
vim-airline, vim-surround, vimwiki,xptemplate,YouCompleteMe,
ctrlsf, webapi-vim, html5, gist-vim, gitgutter, gundo,
[版本管理器]
@liujingyu
liujingyu / setting
Created May 5, 2015 08:41
php opcache 官方推荐配置
[opcache]
zend_extension=opcache.so
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli= On
opcache.enable= On
@liujingyu
liujingyu / sql
Created May 5, 2015 11:48
mysql 位操作(权限使用)
位操作即开始学习计算机就接触的
按位与(&): 1&1=1 1&0=0 0&0=0
按位或(|):1|1=1 1|0=1 0|0=0
按位异或(^):1^1=0 0^0=0 1^0=1
这几个运算都支持交换律
MySQL中也支持这几个位运算,今儿遇到记录用户登录日期一功能需求,设计数据库用一位记录一天,第一位记录1号,第二位记录2号登录,这样可节省数据库存储开支。于是用户在一天内登录多次如何存储,于是想起按位或运算可解决此法,第一次登录更新后,按位或时此位不再更新,好用。
记录用户8号有登录。
insert into USER_LOGIN_12 set sinaid=1686497165,LOGIN=64,MON=2 on duplicate key update login=login|128 ;
@liujingyu
liujingyu / wiki
Created May 6, 2015 02:01
wiki 搭建过程
Apache
yum -y install httpd #根据提示,输入Y安装即可成功安装
service httpd start #启动Apache
备注:Apache启动之后会提示错误:
正在启动 httpd:httpd: Could not reliably determine the server's fully qualif domain name, using ::1 for ServerName
解决办法:
vi /etc/httpd/conf/httpd.conf #编辑
找到 #ServerName www.example.com:80
修改为 ServerName www.osyunwei.com:80 #这里设置为你自己的域名,如果没有域名,可以设置为localhost
@liujingyu
liujingyu / bubbleSort.class.php
Last active August 29, 2015 14:20
php 排序算法(直接插入排序, 希尔排序, 冒泡排序及改进版1-2, 快速排序, 归并排序, 选择排序, 堆排序)
<?php
/**
* 排序名称:冒泡排序.
*
* 说明:冒泡排序的原理非常简单,它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.
*
* 步骤:
* 1 比较相邻的元素。如果第一个比第二个大,就交换他们两个。
* 2 对第0个到第n-1个数据做同样的工作。这时,最大的数就“浮”到了数组最后的位置上。
@liujingyu
liujingyu / abc
Created May 9, 2015 02:38
各种语言执行自身代码段或方法的方式
[python]
exec, eval, repr
[php]
eval, call_user_func
@liujingyu
liujingyu / abc
Created May 9, 2015 03:44
mongodb 从现有的片式集群中删除分片
Ensure the Balancer Process is Active
To successfully migrate data from a shard, the balancer process must be active. Check the balancer state using the sh.getBalancerState() helper in the mongo shell. For more information, see the section on balancer operations.
Determine the Name of the Shard to Remove
To determine the name of the shard, do one of the following:
From the admin database, run the listShards command.
Run either the sh.status() method or the sh.printShardingStatus() method.
The shards._id field lists the name of each shard.
@liujingyu
liujingyu / install.sh
Created May 20, 2015 12:27
centos6.5 apache2.4.9+php5.5.25安装
[apache]
wget http://geekpeek.net/download/httpd-2.4.9-RPM-full.x86_64.tgz
tar -xvzf httpd-2.4.9-RPM-full.x86_64.tgz
cd httpd-2.4.9-RPM-full.x86_64
yum -y localinstall * --skip-broken
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
@liujingyu
liujingyu / httpd.conf
Created May 25, 2015 11:11
apache 参数配置
线程数优化
Prefork优化的关键在于MaxClients与MaxRequestsPerChild。
MaxClients最佳的值:
apache_max_process_with_good_perfermance < (total_hardware_memory /apache_memory_per_process ) * 2
apache_max_process = apache_max_process_with_good_perfermance * 1.5
计算httpd平均占用内存
@liujingyu
liujingyu / profile
Created May 29, 2015 06:58
关于PHP性能优化(转)
1、升级硬件的一般规则:对于 PHP 脚本而言,主要的瓶颈是 CPU ,对于静态页面而言,瓶颈是内存和网络。一台 400 Mhz 的普通奔腾机器所下载的静态页面就能让 T3 专线(45Mbps)饱和。
2、Apache 处理 PHP 脚本的速度要比静态页面慢 2-10 倍,因此尽量采用多的静态页面,少的脚本。
3、PHP 脚本如果不做缓冲,每次调用都需要编译,因此,安装一个 PHP 缓冲产品能提升 25-100% 的性能。
4、把基于文件的会话切换到基于共享内存的会话。编译 PHP 时采用 --with-mm 选项,在 php.ini 中设置 setsession.save_handler=mm 。这个简单的修改能让会话管理时间缩短一半。
5、另外一项缓冲技术是把不常修改的 PHP 页面采用 HTML 缓冲输出。