No more IE!請試著使用FirefoxGoogle Chrome等瀏覽器瀏覽
標頭的可愛Alaskan Malamute來自維基百科~

2017年5月8日 星期一

Vue.js: How to watch a shared state

Using Vue, we can store states outside instances for better management, like this:
HTML:
<div id="a" v-show="managedState.showA">This is A</div>
<div id="b" v-show="managedState.showB">This is B</div>
JavaScript:
var stateManager = {
  states: {
    showA: true,
    showB: false,
  },
  whichOn: 'showA',
  toggle: function (opt) {
    if (!this.states.hasOwnProperty(opt)) {
      console.log('Error');
      return;
    }
    this.states[this.whichOn] = false;
    this.states[opt] = true;
    this.whichOn = opt;
  }
};

new Vue({
  el: '#a',
  data: {
    managedState: stateManager.states
  }
});
new Vue({
  el: '#b',
  data: {
    managedState: stateManager.states
  }
});
With above settings, this code works fine:
JavaScript:
stateManager.toggle('showB');

Nice, but somehow if you needs to "watch" on just one of these shared states, you can watch on a "Computed Property" instead.
Rewrite these Vue instances (not a good case, just for example):
JavaScript:
new Vue({
  el: '#a',
  data: {
    managedState: stateManager.states
  },
  computed: {
    show: function () {
      return this.managedState.showA;
    }
  },
  watch: {
    show: function () {
      if (this.show) document.body.style.backgroundColor = 'lightblue';
    }
  }
});
new Vue({
  el: '#b',
  data: {
    managedState: stateManager.states
  },
  computed: {
    show: function () {
      return this.managedState.showB;
    }
  },
  watch: {
    show: function () {
      if (this.show) document.body.style.backgroundColor = 'pink';
    }
  }
});

Now, the background color of body will change after you call stateManager.toggle accordingly.

2015年1月22日 星期四

[Linux指令] 如何抓取FTP目錄下的資料夾

Linux下的 ftp 工具可以用 mget 來抓取複數檔案,但是遇到資料夾時卻行不通,面對一層層的資料夾,要怎樣才能簡單的快速抓取全部檔案呢?

使用 wget 就可以了! 可以參考以下的指令:
wget -r ftp://user:pass@server//absolute/path/to/directory
user 要換成你的帳號,pass 則是密碼
如果是匿名登入不需要帳密,將 user:pass@ 省略,只留下路徑即可


進階版:
wget -r -nH --cut-dirs=5 -nc ftp://user:pass@server//absolute/path/to/directory
多出來幾個選項,而且server後面多一條斜線(\),可以讓 wget 的行為更合理


來源及詳情參照:


2015年1月12日 星期一

Install climate data operators (cdo) on Ubuntu with netCDF4 and hdf5 support


Nikolay Koldunov
koldunovn@gmail.com
@oceanographer
CDOs can be installed from Ubuntu repositories, but they are compiled without netCDF4 and HDF5 support. As a result you can get:

Unsupported file type (library support not compiled in)

error. To solve this we have to compile cdo by ourselves.

Uninstal cdo if you have them installed from Ubuntu repositories:sudo apt-get purge cdo


Install netcdf andf HDF5 libraries:sudo apt-get install libnetcdf-dev libhdf5-dev


Download latest stable version of cdo from here

Unpack it

cd to unpacked directory

If you want to install cdo in to your system directory:./configure --enable-netcdf4 --enable-zlib --with-netcdf=/usr/ --with-hdf5=/usr/ make sudo make install


If you don't have administrative rights, of would like to have installation of cdo in other folder for any other reason, you can provide prefix:./configure --enable-netcdf4 --enable-zlib --prefix=/dir/where/to/put/cdo --with-netcdf=/usr/ --with-hdf5=/usr/ make make install


In the last case you should also add this path to your $PATH in .bashrc file:export PATH=/dir/where/to/put/cdo/bin:$PATH


note bin at the end!

Hope it will work for you :)

2013年3月20日 星期三

Ubuntu Flash 中文亂碼方格

本文說的就是這種情形:
Youtube影片字幕及選項的中文亂碼

有些人的亂碼方塊裡有打叉叉,那不重要,都是一樣意思

以Ubuntu 12.10來講,Flash是不應該會有亂碼了
所以如果你用的是12.10或更新的版本(12.04或許也是,我不確定能往前幾個版本)請檢查
  1. 出現亂碼的時候,你使用的瀏覽器是否為Google Chrome (icon為藍黃綠紅四色)
  2. 換用其他瀏覽器開啟一樣的影片,是否正常 (若未安裝Flash plugin,請找軟體中心)

Chrome的佈景主題

這幾個似乎都因不明原因掛了~變成徹底的廢文ㄎ