This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 可搭配 pug 產生 version meta | |
// 例:<meta name="version" content="1589465168"> // content 可用 Date.now() 產生 | |
if (!Date.now) { | |
Date.now = function now() { | |
return new Date().getTime(); | |
}; | |
} | |
function checkVersionMatch() { | |
if (window.XMLHttpRequest) { // Mozilla, Safari, IE7+ ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"target": "ES5", | |
"removeComments": true, | |
"sourceMap": false, | |
"allowSyntheticDefaultImports": true, | |
"lib": [ | |
"dom", | |
"es5", | |
"es2015.promise" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./ffmpeg -y -i source.mov -vf fps=10,scale=480:-1:flags=lanczos,palettegen palette.png | |
./ffmpeg -i source.mov -i palette.png -filter_complex "fps=10,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse" ok.gif | |
fps : 每秒幾張 | |
scale : 等比例縮放至寬度480px | |
懶人 | |
https://ezgif.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../node_modules/@types/node/index.d.ts" /> | |
let path = require("path"); | |
let fs = require("fs"); | |
let sass = require('node-sass'); // SCSS 轉 CSS | |
let browserslist = require('../package.json').browserslist; | |
let autoprefixer = require('autoprefixer'); // 增加瀏覽器支援,依賴 postcss | |
let postcss = require('postcss'); // 增加瀏覽器支援 | |
let CleanCSS = require('clean-css'); // 壓縮 minify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../node_modules/@types/node/index.d.ts" /> | |
/// <reference path="../node_modules/@types/pug/index.d.ts" /> | |
/** | |
* | |
* node js/render // 使用測試站設置(預設) | |
* node js/render prod // 使用正式站設置 | |
*/ | |
let pug = require("pug"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../node_modules/@types/node/index.d.ts" /> | |
let path = require("path"); | |
let fs = require("fs"); | |
let sass = require('node-sass'); // SCSS 轉 CSS | |
let browserslist = require('../package.json').browserslist; | |
let autoprefixer = require('autoprefixer'); // 增加瀏覽器支援,依賴 postcss | |
//let plugin = autoprefixer({ browsers: ["> 1%", "last 2 version"] }); // browserslist 瀏覽器支援 (市佔大於 1% 的瀏覽器版本 或 所有瀏覽器最新兩個版本 要廣泛滿足所有條件) | |
//let plugin = autoprefixer({ browsers: ["last 2 version"] }); // browserslist 瀏覽器支援 (所有瀏覽器最新兩個版本) | |
//let plugin = autoprefixer({ browsers: ["> 0%"] }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 手機轉桌機 | |
const href1 = "https://www.example.com/m/index.html?utm_source=fb&utm_medium=linked#home"; | |
$("#p1-before").text(href1); | |
// 以陣列處理 | |
const arr1 = href1.split("/"); | |
const index1 = arr1.indexOf("m"); | |
arr1.splice(index1, 1); | |
$("#p1-after-1").text(arr1.join("/")); | |
// 正則 比較簡短 shorter! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 將數字每隔三位加上逗號 number_format | |
function formatNumber(str: number, glue?: string): string|number { | |
// 如果傳入必需為數字型參數,不然就噴 isNaN 回去 | |
if(isNaN(str)) { | |
return NaN; | |
} | |
// 決定三個位數的分隔符號 | |
var glue: string = (typeof glue == 'string') ? glue: ','; | |
var digits: string[] = str.toString().split('.'); // 先分左邊跟小數點 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. after main loading | |
$("head").append("<link href=\"http://fonts.googleapis.com/earlyaccess/notosanstc.css\" rel=\"stylesheet\">"); | |
// 2. use web font loader https://github.com/typekit/webfontloader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/24804928/singler-line-ffmpeg-cmd-to-merge-video-audio-and-retain-both-audios | |
// 先取出影片內聲音並另存聲音檔 | |
./ffmpeg -i source1.mp4 source1_out.mp3 | |
// 將兩段聲音合併並另存聲音檔(注意音量是否被另一個聲音壓掉了) | |
./ffmpeg -i source1_out.mp3 -i source1.wav -filter_complex amerge -c:a libmp3lame -q:a 4 source1_combine.mp3 | |
// 移除原影片聲音並另存影像檔 | |
./ffmpeg -i source1.mp4 -an source1_no_sound.mp4 |
NewerOlder