代码改变世界

随笔档案-2012年07月

单用户的一次并发[原创]

2012-07-26 14:14 by tetang1230, 351 阅读, 收藏,
摘要: 线上竟然爆出fata error!Duplicate entry'52549023' for key 'userid'这是如何产生的呢?贴一张图,然后慢慢解释。这是apache access log上的截图, 可以从访问时间,userid看出这是来自一个用户的并发请求!时间相同,用户相同。那么这是如何产生的呢?首先这个链接的访问都来自一个按钮的click操作, 当这个用户第一次点击之后,立即点击了第二次!这样便产生了一个并发请求!所点击的页面的逻辑是这样的: 先上数据库查询,如果数据库没有记录,再去做insert操作,其中为userid字段建立了唯一索引。 两次 阅读全文

pthread_clean_push和pthread_clean_up的使用[转]

2012-07-24 20:52 by tetang1230, 331 阅读, 收藏,
摘要: 转载链接:http://blog.myspace.cn/e/407245412.htmvoid pthread_cleanup_push(void (*routine)(void*), void *arg);void pthread_cleanup_pop(int execute);//这里的int参数,0是不执行push的内容,非0是执行。原型很简单,功能跟atexit()差不多,只不过一个是线程一个是进程。用来设置在push/pop内线程退出时要做的事情。需要注意的问题有几点:1,push与pop一定是成对出现的,其实push中包含"{"而pop中包含"}&q 阅读全文

清理ubuntu垃圾文件

2012-07-24 08:57 by tetang1230, 588 阅读, 收藏,
摘要: 1、清理安装/卸载后产生的拉圾sudo apt-get autoremove //自动卸载不使用的内容sudo apt-get autoclean //自动清理,但不会删除用于安装而下载的临时文件sudo apt-get clean //清理下载的临时文件在使用以上命令时注意系统提示,常见的问题有,(1)上次使用apt-get 安装或卸载没有完成,导致不能使用apt-get,这时系统会提示你输入一些命令先解决问题再继续(命令一般为sudo apt-get update);(2)系统中其它后台程序正在安装、升级或卸载,需要等待完成后再使用上面的命令(最好是重启系统后使用上面的命令)2、清理Ubu 阅读全文

CentOS下安装Git[转]

2012-07-23 13:53 by tetang1230, 130 阅读, 收藏,
摘要: CentOS下安装GitCentOS中yum里没有Git,需要手动安装。首先需要安装git的依赖包yum install curlyum install curl-develyum install zlib-develyum install openssl-develyum install perlyum install cpioyum install expat-develyum install gettext-devel下载最新的git包wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.g 阅读全文

vim配置php开发环境

2012-07-22 21:27 by tetang1230, 1377 阅读, 收藏,
摘要: 一:配置目录树1.安装vimapt-get install vimvim /root/.vimrc:set hlsearchsyntax onset tabstop=4set softtabstop=4set shiftwidth=4set autoindentset cindentset cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1sset nuif &term=="xterm"set t_Co=8set t_Sb=^[[4%dmset t_Sf=^[[3%dmendiflet Tlist_Ctags_Cm 阅读全文

nginx + php 配置

2012-07-19 23:19 by tetang1230, 781 阅读, 收藏,
摘要: 本文参考了http://blog.s135.com/nginx_php_v6/ 大量内容,感谢张宴!我的centos6是64位的版本 安装步骤: (系统要求:Linux 2.6+ 内核,本文中的Linux操作系统为CentOS 5.3,另在RedHat AS4上也安装成功) 一、获取相关开源程序: 【适用CentOS操作系统】利用CentOS Linux系统自带的yum命令安装、升级所需的程序库(RedHat等其他Linux发行版可从安装光盘中找到这些程序库的RPM包,进行安装):sudo -sLANG=Cyum -y install gcc gcc-c++ autoconf... 阅读全文

centos6安装配置samba服务

2012-07-19 22:57 by tetang1230, 601 阅读, 收藏,
摘要: 本文参考了大量网络资源,据来自于百度搜索yum install samba关掉防火墙,selinux配置samba(/etc/samba/smb.conf)找到[global] # ----------------------- Network Related Options ------------------------- workgroup = WORKGROUP#这是设置服务器所要加入的工作组的名称,会在Windows 的“网上邻居”中能看到MYGROUP工作组,可以在此设置所需要的工作组的名称。 server string = Samba Server Versio... 阅读全文

PHP: Get start and end dates of a week from date(‘W’) [转]

2012-07-10 16:03 by tetang1230, 347 阅读, 收藏,
摘要: PHP: Get start and end dates of a week from date(‘W’)First off, from thePHP.net Manual, the ‘W’ inside the date() function returns the week number for a year.WeekISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)Example: 42 (the 42nd week in the year)A quick example of date( 阅读全文