Skip to content

Instantly share code, notes, and snippets.

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");
});
@goooooouwa
goooooouwa / node-orm-demo.js
Last active August 2, 2017 03:58
demo on how to use node.js orm to find all records and match text with LIKE. 关于如何使用node.js orm查询全部记录和LIKE文本匹配的demo。 https://github.com/dresende/node-orm2
// 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" + "%") })
@goooooouwa
goooooouwa / node_module.js
Last active March 13, 2019 08:14
nodejs basic module syntax
// in module1.js
function a(){
console.log('hello');
}
module.exports.a = a;
// in module2.js
@goooooouwa
goooooouwa / pos v0.1.js
Created April 10, 2017 09:24
my code for pos v0.1
'use strict';
function printReceipt(inputs){
let purchaseSequence = getPurchaseSequence(inputs);
let itemGroups = groupItems(inputs);
let receiptView = buildReceiptString(itemGroups, purchaseSequence);
displayReceiptView(receiptView);
}
function getPurchaseSequence(items){
@goooooouwa
goooooouwa / README-for-ejs-in-browser.md
Last active March 16, 2017 14:32
如何在浏览器里渲染Ejs模版

如何在浏览器里渲染Ejs模版

  1. 将我的student-management-system项目代码git clone到电脑上
  2. git checkout到example-of-ejs-in-browser分支
  3. 通过npm run web命令将web server跑起来
  4. 访问http://localhost:3000/便可以看到《如何在浏览器里渲染Ejs模版》的说明和实例。

以下是页面截图

screen shot 2017-03-16 at 10 28 22 pm

@goooooouwa
goooooouwa / shadowsocks-README.md
Last active January 25, 2017 14:43
How to use shadowsocks

Server Side

Install

Mac

easy_install pip pip install shadowsocks

Linux

apt-get install python-pip pip install shadowsocks

@goooooouwa
goooooouwa / code.md
Last active September 14, 2016 03:48
Manufactoria game code

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;