├── SO答题计划回答汇总.md ├── build-SublimeText3-for-php-develope-environment.md ├── deep-in-laravel-bootstrap.php.png ├── git-command-line.md ├── javascript-gist ├── laravelNotes └── introduce-laravel.md ├── lottery-php.gist ├── readme.md └── solve-clone-from-github-get-error-permission-denied-publickey.md /SO答题计划回答汇总.md: -------------------------------------------------------------------------------- 1 | * date:2016-06-04 2 | 3 | [Store a PHP variable once throughout a webpage.](http://stackoverflow.com/a/37626025/1969039) 4 | -------------------------------------------------------------------------------- /build-SublimeText3-for-php-develope-environment.md: -------------------------------------------------------------------------------- 1 | ### Sublime Text 3 配置适合PHP的开发环境 2 | 3 | > 虽然有很多优秀的PHP集成开发环境,但是我自己比较喜欢使用文本编辑器来进行PHP开发。 4 | 一方面原因是文本编辑器启动迅速、轻量;另一方面原因是PHP集成开发环境如Zend Studio这类基于Eclispe开发的集成环境经常抽风。 5 | 所以Sublime Text便成了我的开发首选文本编辑器。 6 | 7 | 话不多说,开启我们的Sublime Text的配置之旅吧: 8 | 9 | ##### 一、下载Sublime Text 3 10 | Sublime Text [下载地址](http://www.sublimetext.com/3) 11 | 12 | ##### 二、安装Sublime Text包管理工具:Package Control 13 | * 2.1 通过工具栏View -> Show Console 或简单的 *"Ctrl + `"*快捷键调起控制台,并输入 14 | 15 | `` import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read()) `` 16 | 17 | * 2.2 安装完成就可以在Preferences工具栏下看到 *Package Control* 及*Package Setting*选项 18 | 19 | **Pcakage Control使用** 20 | 21 | 使用*" Ctrl + Shift + P "*快捷键唤起命令行输入框,输入``install``选择*Package Control:install package*选项进入包安装命令行 22 | 23 | #### 三、下面开始下载PHP开发的插件 24 | ###### 3.1 PHP开发插件 25 | DocBlockr:自动给函数变量增加注释功能,它支持的语言有Javascript, PHP, ActionScript, CoffeeScript, Java, Objective C, C, C++ 26 | 27 | Sublime CodeIntel::代码自动提示 28 | 29 | Alignment :代码对齐 30 | 31 | ConvertToUTF8:支持 GBK, BIG5, EUC-KR, EUC-JP, Shift_JIS 等编码的插件 32 | 33 | ###### 3.2 JavaScript插件 34 | JsFormat:JS格式化 35 | 36 | ###### 3.3 Html插件 37 | Emmet:HTML代码生成器 38 | 39 | ###### 3.4 其它插件 40 | FileDiffs:文件夹比较插件 41 | [Side Bar](https://github.com/titoBouzout/SideBarEnhancements):增强边侧栏 42 | [AutoFileName](https://github.com/BoundInCode/AutoFileName):自动补全文件路径 43 | 44 | #### 四、编程字体及主题 45 | 字体:InputMono[Input: Fonts for Code](http://input.fontbureau.com/) 46 | 47 | 主题: 48 | 49 | 50 | ##### 参考资料 51 | 52 | 1. [Sublime Text 3设置吊炸天PHP开发环境](http://blog.csdn.net/heiyeshuwu/article/details/51859571) 53 | 2. [sublime text 3 插件:package control] (http://frontenddev.org/article/sublime-does-text-3-plug-in-package-control.html) 54 | 3. [Sublime Text 3 绝对神器](http://www.cnblogs.com/bananaplan/p/Sublime-Text-3-Powerful.html) 55 | 4. [使用Emmet加速Web前端开发] (http://www.w3cplus.com/tools/using-emmet-speed-front-end-web-development.html) 56 | 5. [超全Sublime Text指南](https://github.com/jikeytang/sublime-text) 57 | 6. [有哪些适合用于写代码的西文字体](https://www.zhihu.com/question/20299865) 58 | -------------------------------------------------------------------------------- /deep-in-laravel-bootstrap.php.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huliuqing/phpnotes/5dcc3c506d924c5a0ea9352ebb1bc30e23af22e3/deep-in-laravel-bootstrap.php.png -------------------------------------------------------------------------------- /git-command-line.md: -------------------------------------------------------------------------------- 1 | ## Git常用命令 2 | 3 | 4 | #### 提交|更新一个文件到远程版本库 5 | * 新增一个文件 6 | > git add filename 7 | 8 | * 新增所有文件 9 | > git add * 10 | 11 | * 将新增的文件提交到HEAD 12 | > git commit -m 'your comment' 13 | 14 | * 将本地仓库HEAD中的文件,推送到远程仓库 15 | > git push origin master 16 | 17 | 18 | #### 查看状态 19 | > git status 20 | 21 | #### 参考资料 22 | [git - 简易指南](http://www.bootcss.com/p/git-guide/) 23 | 24 | [Git Book](https://git-scm.com/book/zh/v2) 25 | 26 | [Git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000) -------------------------------------------------------------------------------- /javascript-gist: -------------------------------------------------------------------------------- 1 | var clearTimer; 2 | /** 3 | * 设置计时器, 4 | * duration:计时时间 5 | * display: 元素对象 6 | */ 7 | function startTimer(duration, display) { 8 | if( clearTimer!==false ) return; 9 | var timer = duration, minutes, seconds; 10 | clearTimer = setInterval(function () { 11 | if (--timer <= 0) { 12 | clearInterval(clearTimer); 13 | clearTimer=false; 14 | return; 15 | // timer = duration; 16 | } 17 | minutes = parseInt(timer / 60, 10); 18 | seconds = parseInt(timer % 60, 10); 19 | 20 | minutes = minutes < 10 ? "0" + minutes : minutes; 21 | seconds = seconds < 10 ? "0" + seconds : seconds; 22 | 23 | display.addClass("disabled"); 24 | display.attr("disabled", true); 25 | display.css({"background":"#CCCCCC"}); 26 | display.text("(" + seconds + ")"); 27 | 28 | 29 | }, 1000); 30 | } 31 | 32 | 33 | //-------------------------------------------------------- 34 | //thinkphp jump 35 |

36 | 页面自动 跳转 等待时间: 37 |

38 | 39 | (function(){ 40 | var wait = document.getElementById('wait'),href = document.getElementById('href').href; 41 | var interval = setInterval(function(){ 42 | var time = --wait.innerHTML; 43 | if(time == 0) { 44 | location.href = href; 45 | clearInterval(interval); 46 | }; 47 | }, 1000); 48 | })(); 49 | 50 | 51 | //---------------------------------------- 52 | //javascript trim 53 | txt.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,''); 54 | //@link http://stackoverflow.com/a/498995/1969039 55 | -------------------------------------------------------------------------------- /laravelNotes/introduce-laravel.md: -------------------------------------------------------------------------------- 1 | ### Laravel 入门 2 | 3 | 1、github克隆Laravel项目,git bash执行 4 | 5 | ```sh 6 | git clone git@github.com:laravel/laravel 7 | ``` 8 | 2、 加载laravel依赖,项目根目录执行 9 | 10 | ```sh 11 | composer install 12 | ``` 13 | 14 | 3、laravel项目中的.env.example重命名为.env文件 15 | 16 | 4、laravel项目更目录执行,php artisan key:generate 参考: [laravel No supported encrypter found. The cipher and / or key length are invalid](http://stackoverflow.com/questions/31512970/laravel-no-supported-encrypter-found-the-cipher-and-or-key-length-are-invalid) 17 | 18 | 5、启动Laravel内置服务器 Homestead,默认监听localhost:8000 19 | 20 | ```sh 21 | php artisan serve 22 | ``` 23 | 24 | 6、项目命名空间重命名 25 | 26 | ```sh 27 | php artisan app:name Blog //将命名空间命名为Blog 28 | ``` 29 | 30 | 7、开启/关闭维护模式 31 | ```sh 32 | php artisan down //开启维护模式 33 | 维护模式模版文件:resources/views/errors/503.blade.php 34 | php artisan up //关闭维护模式 35 | ``` 36 | -------------------------------------------------------------------------------- /lottery-php.gist: -------------------------------------------------------------------------------- 1 | StartTime = $this->get_microtime(); 13 | } 14 | 15 | private function get_microtime() 16 | { 17 | list($usec, $sec) = explode(' ', microtime()); 18 | return ((float)$usec + (float)$sec); 19 | } 20 | 21 | public function end() 22 | { 23 | $this->StopTime = $this->get_microtime(); 24 | return round(($this->StopTime - $this->StartTime) * 1000, 1); 25 | } 26 | 27 | } 28 | 29 | //开始计时 30 | $runtime= new runtime(); 31 | 32 | //你的代码开始 33 | 34 | /* 35 | * 经典的概率算法, 36 | * $proArr是一个预先设置的数组, 37 | * 假设数组为:array(100,200,300,400), 38 | * 开始是从1,1000 这个概率范围内筛选第一个数是否在他的出现概率范围之内, 39 | * 如果不在,则将概率空间,也就是k的值减去刚刚的那个数字的概率空间, 40 | * 在本例当中就是减去100,也就是说第二个数是在1,900这个范围内筛选的。 41 | * 这样 筛选到最终,总会有一个数满足要求。 42 | * 就相当于去一个箱子里摸东西, 43 | * 第一个不是,第二个不是,第三个还不是,那最后一个一定是。 44 | * 这个算法简单,而且效率非常 高, 45 | * 关键是这个算法已在我们以前的项目中有应用,尤其是大数据量的项目中效率非常棒。 46 | */ 47 | function get_rand($prize_arr) { 48 | 49 | /* 50 | * 每次前端页面的请求,PHP循环奖项设置数组, 51 | * 通过概率计算函数get_rand获取抽中的奖项id。 52 | * 将中奖奖品保存在数组$res['yes']中, 53 | * 而剩下的未中奖的信息保存在$res['no']中, 54 | * 最后输出json个数数据给前端页面。 55 | */ 56 | foreach ($prize_arr as $key => $val) { 57 | $proArr[$val['id']] = $val['v']; 58 | } 59 | 60 | $result = ''; 61 | //概率数组的总概率精度 62 | $proSum = array_sum($proArr); 63 | //概率数组循环 64 | foreach ($proArr as $key => $proCur) { 65 | $randNum = mt_rand(1, $proSum); 66 | if ($randNum <= $proCur) { 67 | $result = $key; 68 | break; 69 | } else { 70 | $proSum -= $proCur; 71 | } 72 | } 73 | unset ($proArr); 74 | 75 | $rid = $result; 76 | 77 | $res['yes'] = $prize_arr[$rid-1]['prize']; //中奖项 78 | unset($prize_arr[$rid-1]); //将中奖项从数组中剔除,剩下未中奖项 79 | shuffle($prize_arr); //打乱数组顺序 80 | for($i=0;$i array('id'=>1,'prize'=>'平板电脑','v'=>1), 101 | '1' => array('id'=>2,'prize'=>'数码相机','v'=>5), 102 | '2' => array('id'=>3,'prize'=>'音箱设备','v'=>10), 103 | '3' => array('id'=>4,'prize'=>'4G优盘','v'=>12), 104 | '4' => array('id'=>5,'prize'=>'10Q币','v'=>22), 105 | '5' => array('id'=>6,'prize'=>'下次没准就能中哦','v'=>50), 106 | ); 107 | 108 | for($i = 1; $i<11; $i++){ 109 | $rid[] = get_rand($prize_arr); //根据概率获取奖项id 110 | } 111 | 112 | 113 | print_r($rid); 114 | 115 | //计时结束 116 | echo "页面执行时间: ".$runtime->end()." 毫秒"; 117 | ?> 118 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## 这个一个个人博客项目 2 | 主要用户记录工作中遇到的技术问题、整理内容夯实的技术文章 3 | 4 | 本人现在上海卓悠网络从事PHP开发工作,主要负责开发应用平台Android服务器接口及支付功能 5 | 6 | 本项目所有的博客内容都在Issues模块内,由于工作关系博客内容比较集中于PHP技术、Web前端技术、MySQL及服务器架构等方向的技术整理与分享 7 | 8 | ## 开始本项目的原因 9 | 1 之前有尝试过在博客平台写技术文章,但限制太多,而且编辑器用的不顺手 10 | 11 | 2 使用的GitHub Page静态博客功能,由于前端UI自从写过之后看久了腻了,并且需要提交自己的博文代码,技术整理和总结起来也不够纯粹了也就 12 | 13 | 3 Issues功能已经很强大了,完全可以满足我整理技术的需求 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /solve-clone-from-github-get-error-permission-denied-publickey.md: -------------------------------------------------------------------------------- 1 | # 从GitHub克隆版本库提示Permission denied (publickey)错误时,如何解决 2 | 3 | 操作系统: Windows XP 4 | 5 | Git工具 : Git Bash 6 | 7 | 克隆命令: git clone git@github.com:huliuqing/phpnotes 8 | 9 | 错误消息: 10 | 11 | > Permission denied (publickey) 12 | fatal:Could not read from remote repository 13 | 14 | ** 解决思路:** 15 | 16 | 1. 是否设置GitHub SSH公钥信息 17 | 2. 如果已设置SSH 公钥信息,确认是不是最新生成的SSH公钥信息 18 | 19 | ## 解决方案: 20 | 21 | ### 解决问题1 22 | 如果是未设置SSH公钥信息 23 | step1. 我们需要使用Git工具[生成SSH宻钥数据](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) 24 | 25 | > 1 打开 Git Bash工具 26 | 27 | > 2 输入命令: *ssh-keygen -t -ras -b 4096 -C 'your_email@examle.com'* 28 | 29 | > 3 当看到"Enter a file in which to save the key"提示消息,*直接按回车键*。 30 | 表示使用默认的目录生成宻钥数据 31 | 32 | > 4 当看到 33 | **Enter passphrase (empty for no passphrase): [Type a passphrase]** 34 | **Enter same passphrase again: [Type passphrase again]** 35 | 提示时:*输入你的密码* 36 | 37 | step2. 将SSH宻钥添加到ssh-agent 38 | > 1 确认ssh-agent是否可用,执行命令: *eval $(ssh-agent -s)* 39 | 你将看到"**Agent pid 59566**"提示消息 40 | 41 | > 2将SSH宻钥添加到ssh-agent,执行命令**ssh-add ~/.ssh/id_rsa** 42 | 43 | step3 [将SSH宻钥配置到GitHub帐号](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/) 44 | >1 将生成的SSH宻钥(id_rsa.pub文件内容)复制到粘贴板 45 | 46 | >2 进入**GitHub>Setting**选项 47 | 48 | >3 进入**SSH and GPG keys**选项 49 | 50 | >4 点击**New SSH key**按钮 51 | 52 | >5 键入"Title"信息,将id_rsa.pub数据粘贴进**"Key"** 53 | 54 | >6 点击**Add SSH key** 55 | 56 | ### 解决问题2 57 | 找到你的id_rsa.pub文件,按照step3的步骤将SSH宻钥配置到GitHub帐号 58 | 59 | 60 | ### 参考资料: 61 | [Git - Permission denied (publickey)](http://stackoverflow.com/a/2643584/1969039) 62 | 63 | [Generating a new SSH key and adding it to the ssh-agent](https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/) 64 | 65 | [Adding a new SSH key to your GitHub account](https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/) 66 | 67 | [github提示Permission denied (publickey),如何才能解决?](https://www.zhihu.com/question/21402411) 68 | --------------------------------------------------------------------------------