解決 laradock pathinfo PATHINFO_BASENAME 不支持中文開頭的檔名

  • 先透過 locale -a 查詢作業系統支援那些語系編碼
  • 若未安裝額外語系編碼,則至 laradock .env 設置
    • PHP_FPM_INSTALL_ADDITIONAL_LOCALES=true
    • PHP_FPM_ADDITIONAL_LOCALES=”zh_TW.UTF-8″
  • 重新編譯 PHP-FPM:docker-compose build php-fpm
  • setlocale(LC_ALL,’zh_TW.utf8′);

Javascript 幾種 Array 填充 0 的方式

# Array push
for (var i = 0, a = []; i < 100; i++) a.push(0);

# Array assign
for (var i = 0, a = new Array(100); i < 100;) a[i++] = 0;

# Typed array conversion (最慢)
[].slice.call(new Uint8Array(100));

# Binary concatenation
for (var i = 100, a = [], add = [0]; i; i >>=1) {
    if (i & 1) a.push.apply(a, add);
    add.push.apply(add, add);
}

# Array Apply
Array.apply(null, new Array(100)).map(Number.prototype.valueOf,0);

# Array.fill() (最快)
new Array(100).fill(0);

Most efficient way to create a zero filled JavaScript array? – Stack
Overflow Zero filled array creation

Responsive iFrames with jQuery

HTML
iframe {
    max-width: 100%;
}
Javascript
function adjustIframes() {
    $('iframe').each(function() {
        var
            $this = $(this),
            proportion = $this.data('proportion'),
            w = $this.attr('width'),
            actual_w = $this.width();

        if (!proportion) {
            proportion = $this.attr('height') / w;
            $this.data('proportion', proportion);
        }

        if (actual_w != w) {
            $this.css('height', Math.round(actual_w * proportion) + 'px');
        }
    });
}

$(window).on('resize load', adjustIframes);