- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
This file contains 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
pct create <id> /var/lib/vz/template/cache/centos-7-default_20170504_amd64.tar.xz \ | |
-arch amd64 \ | |
-ostype <centos|ubuntu|etc> \ | |
-hostname <hostname> \ | |
-cores <cores> \ | |
-memory <memory(MB)> \ | |
-swap <swap(MB)> \ | |
-storage local-lvm \ | |
-password \ | |
-net0 name=eth0,bridge=<bridge>,gw=<gateway>,ip=<cidr>,type=veth &&\ |
This file contains 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 Web3 = require('web3') | |
const Tx = require('ethereumjs-tx').Transaction | |
// connect to Infura node | |
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/INFURA_KEY')) | |
// the address that will send the test transaction | |
const addressFrom = '0x1889EF49cDBaad420EB4D6f04066CA4093088Bbd' | |
const privateKey = new Buffer('PRIVATE_KEY', 'hex') |
This file contains 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
Show hidden characters
{ | |
"presets": ["es2015"], | |
"plugins": ["transform-runtime"] | |
} |
This file contains 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
# 21 lines, gutter at 80, for a fully functional coffeescript templater. | |
global.compiledHTML = '' | |
makeTagFunc = (tagName, isSelfClosing) -> | |
(args...) -> | |
selfEndingTag = if isSelfClosing then ' /' else '' | |
attrs = args.filter((i) -> typeof i is 'object').reduce(((i, j) -> | |
i + ("#{key}='#{val}'" for key, val of j).join ' '), '') | |
inner = args.filter((i) -> | |
typeof i != 'function' and typeof i != 'object').map((i) -> i).join ' ' | |
global.compiledHTML += "<#{(tagName + ' ' + attrs).trim()}#{selfEndingTag}>" |
This file contains 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
Array.prototype.forEachAsync = function (callback, complete) { | |
var raiseComplete/*: (arg?: bool) => void*/ = complete ? (function (arg) { | |
complete(arg); | |
}) : (function () { }); | |
function next (self, index, length) { /* rec */ | |
if (index === length) { | |
raiseComplete(true); | |
} else { | |
process.nextTick(function () { |
This file contains 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
/* | |
A simple and elegant function to synchronize multiple functions that expect callback as their last parameter. | |
example: | |
sync(func1, [parms], func2, func3, func4, [parms], callback); | |
Public domain!! | |
please leave me a comment if you like it! | |
*/ |
This file contains 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
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
This file contains 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
# Modelo base | |
class @Model | |
constructor: (defaults,urls) -> | |
@__defaults = if typeof defaults is "object" then defaults else {} | |
@__urls = if typeof urls is "object" then defaults else {} | |
@set(@__defaults) | |
get: (attr) -> | |
ko.unwrapObservable @[attr] |