Skip to content

Instantly share code, notes, and snippets.

View dcb9's full-sized avatar

Du, Chengbin dcb9

View GitHub Profile
@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 / 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 / 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 / get-local-wan-ip.sh
Created April 2, 2015 09:02
获取本机的外网出口IP是多少
curl http://1111.ip138.com/ic.asp 2>/dev/null | grep '\[' | awk -F'[' '{print $2}' | awk -F']' '{print $1}'
@dcb9
dcb9 / get-yii2-ar-raw-sql.php
Last active May 18, 2018 05:36
如何获取 YII2 AR 执行的 SQL 语句,直接用程序输出,而不是通过日志去查看
<?php
$query = User::find()
->where(['id'=>[1,2,3,4])
->select(['username'])
// get the AR raw sql in YII2
$commandQuery = clone $query;
echo $commandQuery->createCommand()->getRawSql();
@dcb9
dcb9 / import-centos-vagrant-box.sh
Created April 7, 2015 17:01
Centos 导入 vagrant box 出错
使用打包的 vagrant box 启动时报以下错误
Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/ifup eth1 2> /dev/null
解决办法
vagrant ssh
rm -f /etc/udev/rules.d/70-persistent-net.rule
package main
import (
"fmt"
"strings"
)
type IPAddr [4]byte
// TODO: Add a "String() string" method to IPAddr.
@dcb9
dcb9 / get-wan-ip.sh
Last active June 6, 2016 08:50
get WAN IP script using ip138
curl ip.cn
@dcb9
dcb9 / boot2docker-change-ip-error.sh
Created May 22, 2015 04:17
boot2docker 把默认IP改成了桥接到路由器并自动获取IP后运行出错
$ docker images
FATA[0000] An error occurred trying to connect: Post https://192.168.199.243:2376/v1.18/containers/create: x509: certificate is valid for 127.0.0.1, 10.0.2.15, not 192.168.199.243
# Answer https://github.com/docker/machine/issues/531
$ docker --tlsverify=false images
@dcb9
dcb9 / a.json
Last active August 29, 2015 14:25
json-decode-Control-character-error
{"msg_item":[{"id":204993425,"type":9,"fakeid":"3076920206","nick_name":"敢玩","date_time":1427459682,"content":"","source":"mass","msg_status":2,"title":"敢玩初体验 | 告别不靠谱的副机长!普通人也能开飞机!","desc":"听到前两的德法坠机事件你对飞行产生恐惧?告别那些不靠谱的副机长吧,自己也可以亲身做一回副机长。看了视频你就","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MzA3NjkyMDIwNg==&mid=204993424&idx=1&sn=3d49b4e5d8c688a1858c7fdb6bd65f88#rd","show_type":1,"file_id":204978640,"app_sub_type":3,"comment_url":"","has_reply":0,"refuse_reason":"","multi_item":[{"seq":0,"cover":"https:\/\/mmbiz.qlogo.cn\/mmbiz\/Nbw8zgku2MiaIF7hSpax7Vb75Ze2gZfJt2uDQ1v72Ds9RhlYT0hEE1L4YUJdA1zVwUqzBqI0ks8Dw0RIw8P53GA\/0","title":"敢玩初体验 | 告别不靠谱的副机长!普通人也能开飞机!","digest":"听到前两的德法坠机事件你对飞行产生恐惧?告别那些不靠谱的副机长吧,自己也可以亲身做一回副机长。看了视频你就","content_url":"http:\/\/mp.weixin.qq.com\/s?__biz=MzA3NjkyMDIwNg==&amp;mid=204993424&amp;idx=1&amp;sn=3d49b4e5d8c688a1858c7fdb6bd65f88#rd","file_id":204978640,"content":"","source_url":"","author":"I Love","show_cover_pic":0,"del_flag":0,"vote_id":[],"copyright_status":100,"copyright_type