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
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
# 这个程序用来把/etc/fstab 文件的挂载项由 /dev/sd* 这样的标志改成uuid的标志 | |
# 修改的好处是不会因为非Linux上的分区的增加或者删除而导致的无法正常启动或正常挂载分区 | |
# 要求超级用户的权限 | |
print "程序运行需要超级用户的权限,尝试以root用户或者sudo方式运行\n" | |
and exit 1 if $< !=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
sudo apt install libssl-dev |
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
'use strict'; | |
const fs = require('fs'); | |
module.exports = function(sequelize, DataTypes) { | |
const tableName = 'something'; | |
const attr = JSON.parse(fs.readFileSync(__dirname + `/attributes/${tableName}`)); | |
const Something = sequelize.define('Something',attr, { | |
classMethods: { | |
getCacheFields: () => { return ['field1', 'field2', 'field3'] } // fields you want to cache |
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
Cache.proxyGetDBRecord = function *(model, id, field) { | |
if (!id) { | |
return null; | |
} | |
let key = genCacheKeyWithModel(model, id); // generate id with tableName and id | |
let result = null; | |
if (field) { | |
result = yield client.hgetAsync(key, field); | |
} else { |
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
let name = yield* cache.proxyGetDBRecord(db.Something, id, 'name'); | |
let record = yield* cache.proxyGetDBRecord(db.Something, id); |
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
{ | |
"name": "Run mocha", | |
"type": "node", | |
"request": "launch", | |
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", | |
"stopOnEntry": false, | |
"args": ["test/**/*.js", "--no-timeouts"], | |
"cwd": "${workspaceRoot}", | |
"runtimeExecutable": null, | |
"env": { "NODE_ENV": "testing"} |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Launch", | |
"program": "${workspaceRoot}/index.ts", | |
"sourceMaps": true, | |
"outFiles": [] |
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 sequelize = require('sequelize') | |
const db = new sequelize('test', 'test', '', { | |
dialect: 'postgres', | |
host: '127.0.0.1', | |
port: 5432, | |
}) | |
const Foo = db.define('foo') | |
const Bar = db.define('bar') |
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
class User { | |
constructor() { | |
// do nothing | |
} | |
*createUser(params) { | |
// TODO: implement this function | |
} | |
*getUser(params) { |
OlderNewer