2014/03/21

jQuery Video Creator Plugin

้€™ๅ€‹ plugin ๅฏไปฅๅˆๅง‹ๆ“ๆœ‰ YouTube ๆˆ– Vimeo ็š„่ถ…้€ฃ็ต้ปž้ธไน‹ๅพŒๅฐ‡่‡ชๅทฑๆˆ–ๆŒ‡ๅฎš็š„็›ฎๆจ™่ฝ‰ๆ›ๆˆๅฝฑ็‰‡。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Video</title>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="js/jquery.video_creator.js"></script>
    <script>
    $(function() {
        $('a').video_creator({
            width: 200,
            height: 100,
            target: '#video'
        });
    });
    </script>
</head>
<body>
<a href="https://www.youtube.com/watch?v=p6oaqY6flJg">Youtube</a>
<a href="http://vimeo.com/89495751">Vimeo</a>
<div id="video"></div>
</body>
</html>
(function() {
    $.fn.video_creator = function(options) {
        var params = {
            width: 640,
            height: 360,
            target: ''
        }

        var set = $.fn.extend(params, options);

        return this.each(function() {
            var url = $(this).prop('href'),
                id = '',
                matches = '',
                result = '';

            // Youtube
            if (-1 !== url.toLowerCase().indexOf('youtube')) {
                matches = url.match(/[\\?\\&]v=([^\\?\\&]+)/);
                id = matches[1];
                result = '<iframe width="' + set.width + '" height="' + set.height + '" src="//www.youtube.com/embed/' + id + '" frameborder="0" allowfullscreen></iframe>';
            }

            // Vimeo
            if (-1 !== url.toLowerCase().indexOf('vimeo')) {
                matches = url.match(/\/\/(www\.)?vimeo.com\/(\d+)($|\/)/);
                id = matches[2];
                result = '<iframe src="http://player.vimeo.com/video/' + id + '?title=0&amp;byline=0&amp;portrait=0&amp;badge=0&amp;color=ffffff" width="' + set.width + '" height="' + set.height + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
            }

            $(this).on('click', function() {
                if ('' === set.target) {
                    $(this).replaceWith(result);
                } else {
                    $(set.target).html(result);
                }

                return false;
            });
        });
    }
}(jQuery));

2014/03/06

Show Directory

ๆˆ‘ๅ€‘้ƒฝ็Ÿฅ้“่ฆ็ง€ๅ‡บ็›ฎๅ‰็›ฎ้Œ„ไธ‹็š„ๆช”ๆกˆๆˆ–็›ฎ้Œ„ๅ…งๅฎนๆ˜ฏ็”จ ls,ไฝ†ๅฆ‚ไฝ•ๅฟซ้€Ÿ็ฒพ็ขบ็š„ๅช็ง€ๅ‡บ็›ฎ้Œ„ๅ‘ข

ls -lF | grep '/'

ๆˆ‘ๅ€‹ไบบ่ฆบๅพ—้€™ๅ€‹ๆŒ‡ไปคๅธธๅธธ็”จๅˆฐ,ๆ‰€ไปฅๅฐฑๆŠŠไป–ๅŠ ๅ…ฅ .bashrc ๅง

alias ld='ls -lF | grep "/"' # ไฝฟ็”จ ld ็•ถไฝœๆŒ‡ไปคๅ็จฑ

็„ถๅพŒ่จ˜ๅพ— source .bashrc,ๅคงๅŠŸๅ‘Šๆˆ