Skip to content

Instantly share code, notes, and snippets.

View dcb9's full-sized avatar

Du, Chengbin dcb9

View GitHub Profile
@dcb9
dcb9 / boot2docker-mount-host-share-dir.sh
Created March 17, 2015 04:01
boot2docker mount host share directory【Boot2docker 挂载主机里面的目录】
Mac os $ mkdir -p /Users/bob/Documents/github/docker
Mac os $ boot2docker --vbox-share="/Users/bob/Documents/github/docker" start
Mac os $ boot2docker ssh
boot2docker $ mkdir data
boot2docker $ sudo mount -t vboxsf Users/bob/Documents/github/docker data
# refer https://github.com/boot2docker/boot2docker-cli/issues/314
@dcb9
dcb9 / MySqlSessionHandlerExample.php
Created February 26, 2015 16:03
用 MySQL 来记录 Session 数据实例
<?php
ob_end_clean();
if((int)ini_get('session.auto_start') > 0)
{
ini_set('session.auto_start',0);
}
class MySqlSessionHandler implements SessionHandlerInterface
{
private $_db;
@dcb9
dcb9 / SplDoublyLinkedListTest.php
Last active April 18, 2016 10:15
学习 SplDoublyLinkedList ,使用 phpunit 来学习,判断每一个点与自己预期的值是一致的,这里应该不能够会发现 SPL 的 BUG,主要是用来看我自己哪里有不对的。
<?php
class SplDoublyLinkedListTest extends PHPUnit_Framework_TestCase
{
public function testSplDoublyLinkedListPart1()
{
$obj = new SplDoublyLinkedList();
// Pushes value at the end of the doubly linked list.
$obj->push(0);
$obj->push(1);
@dcb9
dcb9 / composer.json
Created January 26, 2015 07:16
测试使用 Neon 配置,感觉非常棒
{
"require": {
"nette/neon": "*"
}
}
<?php
# filepath src/
class MyArray
{
public static function sumCountByIdentity($items, $identityKey, $countKey){
$tmp = $newItems = [];
foreach($items as $row){
@dcb9
dcb9 / use_Yii2_createObject.php
Created January 10, 2015 06:08
Yii2 独立使用是验证器
$news_id = 1;
$existValidator = Yii::createObject([
'class' => '\yii\validators\ExistValidator',
'targetClass' => '\common\models\News',
'targetAttribute' => 'id',
]);
if( ! $existValidator->validate($news_id, $error)){
var_dump($error);
@dcb9
dcb9 / gist:72da5e8412dfd97cff99
Created January 8, 2015 03:25
查看与 GitHub 服务器连接的信息
 ~/ ssh -vT [email protected]
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/bob/.ssh/config
debug1: /Users/bob/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to github.com [192.30.252.129] port 22.
debug1: Connection established.
debug1: identity file /Users/bob/.ssh/id_rsa type 1
debug1: identity file /Users/bob/.ssh/id_rsa-cert type -1
@dcb9
dcb9 / yii2-reset-password.php
Created December 31, 2014 04:22
yii2 给用户重新设置密码的步骤
use common\models\User;
$user = User::findOne($user_id);
$user->setPassword($your_password);
$user->generateAuthKey();
$user->save();
@dcb9
dcb9 / solved-angularjs-chromedriver-could-not-find
Last active August 29, 2015 14:11
学习Angularjs的时候运行 e2e 的时候,无法找到chromedriver.exe 在Mac OS X 中的解决办法
[launcher] Error: Could not find chromedriver at /Users/bob/Documents/github/angular-phonecat/node_modules/protractor/selenium/chromedriver.exe
npm ERR! [email protected] protractor: `protractor test/protractor-conf.js`
npm ERR! Exit status 1
# 本人是Mac OS X 的解决办法:
1. 首先去拿到 chromedriver 的下载URL:https://code.google.com/p/chromedriver/downloads/list
2. 打开txt 中的路径,下载最新的 chromedriver,并解压。
3. 把解压出来的 chromedriver 命令复制到相应目录下并重命名 chromedriver.exe
$ cp -a ~/Downloads/chromedriver ~/Documents/github/angular-phonecat/node_modules/protractor/selenium/chromedriver.exe
安装zsh
brew install zsh
设置zsh为默认shell
mate /etc/shells
在文末增加:
/usr/local/bin/zsh
将zsh设置为默认的Shell: