2017年1月18日 星期三

Docker in mac hostconfig.json

https://www.softwareab.net/wordpress/docker-macosx-modify-hostconfig-existing-container/

screen /Users/#USER/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

cd /var/lib/docker/containers/${container_hash}/hostconfig.json

to reset docker

http://stackoverflow.com/questions/19335444/how-to-assign-a-port-mapping-to-an-existing-docker-container

1) stop the container 
2) change the file
3) restart your docker engine (to flush/clear config caches)
4) start the container

node.js ruby grunt project

http://gruntjs.com/getting-started


1. npm install
2. npm run build-local

2017年1月6日 星期五

VM centos eth0 not found

Ref:http://www.ntueees.tp.edu.tw/wordpress/?p=454



部署完LINUX OS啟動後會出現下列error:
Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization [FAILED]
修改設定如下:
1. 將ESXI分配的MAC keyin到ifcfg-eth0
2.刪除/etc/udev/rules.d/70-persistent-net.rules
3.reboot

2016年12月13日 星期二

php array to html table

function build_table($array){
        // start table
        $html = '<table>';
        // header row
        $html .= '<tr>';
        foreach($array[0] as $key=>$value){
                $html .= '<th>' . $key . '</th>';
            }
        $html .= '</tr>';

        // data rows
        foreach( $array as $key=>$value){
            $html .= '<tr>';
            foreach($value as $key2=>$value2){
                $html .= '<td>' . $value2 . '</td>';
            }
            $html .= '</tr>';
        }

        // finish table and return it

        $html .= '</table>';
        return $html;
    }

2016年11月24日 星期四

log4php and phpunit

https://hackpad.com/ep/pad/static/i2nReTrh1wr

log4php_config.xml:


<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://logging.apache.org/log4php/">
        <appender name="default" class="LoggerAppenderDailyFile">
                <layout class="LoggerLayoutPattern">
                        <param name="conversionPattern" value="%date{m-d-Y H:i:s,u} [%process] %logger %-5level %file (%class.%method line: %line): %msg%n" />
                </layout>
                <param name="file" value="/var/log/apache2/php_addressbook-%s.log" />
                <param name="datePattern" value="Y-m-d" />
        </appender>
        <appender name="echo" class="LoggerAppenderEcho">
                <layout class="LoggerLayoutPattern">
                        <param name="conversionPattern" value="%date{m-d-Y H:i:s,u} [%process] %logger %-5level %file (%class.%method line: %line): %msg%n" />
                </layout>
                <param name="htmlLineBreaks" value="false" />
        </appender>
        <root>
                <level value="trace" />
                <appender_ref ref="default" />
        </root>
        <logger name="unittest">
                <level value="trace" />
                <appender_ref ref="echo" />
        </logger>
</configuration>


sampleTest.php

<?php
include_once(’log4php/Logger.php’);

$log4php_config_path = "./resources/log4php_config.xml";
Logger::configure($log4php_config_path);

class baseTestCase extends PHPUnit_Framework_TestCase
{
        protected static $testlog;

        public function __construct() {
                $this->testlog = Logger::getLogger(’unittest’);
        }
        
        public static function setUpBeforeClass() {
                $testlog = Logger::getLogger(’unittest’);
                $testlog->trace(’Setting up simpleTest class’);
        }

        public static function tearDownAfterClass() {
                $testlog = Logger::getLogger(’unittest’);
                $testlog->trace(’Tearing down simpleTest class’);
        }

        protected function setUp() {
                $this->testlog->trace(’Setting up function’);
        }

        protected function tearDown() {
                $this->testlog->trace(’Tearing down function’);
        }
}
?>