title | layout | category | tags |
---|---|---|---|
JS prototype-based OO key steps |
post |
coding |
javascript |
// 1. define the Person Class
function Person() {
title | layout | category | tags |
---|---|---|---|
JS prototype-based OO key steps |
post |
coding |
javascript |
// 1. define the Person Class
function Person() {
for filename in ./_drafts/*.md; do | |
echo $filename | |
date=$(echo $filename | cut -c 11-20) | |
title=$(echo $filename | cut -c 22- | rev | cut -c 4- | rev) | |
geeknote create --title "$title" --created "$date" --content "$filename" | |
done |
var fs = require('fs'); | |
const contents = fs.readFileSync('CardDiary-JSON.json', 'utf8'); | |
const obj = JSON.parse(contents); | |
for (const d of obj.diaryExports) { | |
const diary = JSON.parse(d.content); | |
const date = d.createDate.substring(0, 10); | |
const filename = `${date}-${diary.title || 'log'}`; |
var anim = this.node.getChildByName("flashLight").getComponent(cc.Animation); | |
// these 3 steps must in order to play and pause the animation at 0.5s | |
anim.setCurrentTime(0.5, 'flashLight'); | |
anim.play("flashLight"); | |
anim.pause('flashLight'); | |
this.render().then(() => { | |
// these 2 steps must in order to resume the animation from 0.5s | |
anim.setCurrentTime(0.5, 'flashLight'); | |
anim.resume("flashLight"); | |
}); |
// how to find all Person records | |
// 如何查找所有人的记录 | |
Person.find() // or Person.all() | |
// how to find Person records with surname beginning with word "Gr" | |
// 如何查找surname以“Gr"字母开头的人的记录 | |
Person.find({ surname: orm.like("Gr" + "%") }) |
// in module1.js | |
function a(){ | |
console.log('hello'); | |
} | |
module.exports.a = a; | |
// in module2.js |
'use strict'; | |
function printReceipt(inputs){ | |
let purchaseSequence = getPurchaseSequence(inputs); | |
let itemGroups = groupItems(inputs); | |
let receiptView = buildReceiptString(itemGroups, purchaseSequence); | |
displayReceiptView(receiptView); | |
} | |
function getPurchaseSequence(items){ |
example-of-ejs-in-browser
分支npm run web
命令将web server跑起来naive sort
?lvl=27&code=c11:4f0;c12:4f0;c13:10f0;r11:7f1;c11:8f2;b11:9f2;b12:6f3;p12:7f0;c12:8f3;p12:9f3;c13:7f0;c13:9f2;r14:6f2;p14:7f1;c14:8f1;p14:9f2;b14:10f1;c15:6f2;b15:7f0;r15:9f3;c15:10f3;c16:6f3;c16:7f3;c16:8f3;c16:9f0;q12:10f0;c15:11f0;c14:11f0;c13:11f1;c11:5f2;c12:5f2;c13:5f2;c14:5f3;c11:6f1;c10:4f3;c10:5f3;c10:6f3;c10:7f3;g10:8f2;
bubble sort
?lvl=27&code=c9:7f1;c9:8f1;c9:9f1;c9:10f1;c9:11f1;b10:9f0;b10:10f0;r10:11f0;b11:9f0;p11:10f0;b11:11f0;c12:9f3;p12:10f3;r13:9f2;p13:10f2;b13:11f2;r14:9f2;r14:10f2;r14:11f2;c15:7f1;c15:8f1;c15:9f1;c15:10f1;c15:11f1;c10:7f3;c10:8f2;b11:7f3;c11:8f2;p12:7f3;c12:8f3;r13:7f3;c13:8f0;c10:6f3;c9:6f1;c15:6f1;g12:4f2;c13:4f3;c14:4f0;c15:4f0;c15:5f1;c13:5f0;q11:5f0;c12:5f0;c11:4f3;c10:4f2;c9:4f2;c9:5f1;g11:6f2;c12:6f3;c10:5f3;