| 😄 | 😆 | 😊 | 😃 |
😩 | 😔 | 😞 | 😖 | 😨 | 😰 | 😣 | 😢 | 😭 | 😂 | 😲 | 😱 | | 😫 | 😠 | 😡 | 😤 | 😪 | 😋 | 😷
😎 | 😵 | 👿 | 😈 | 😐 | 😶 | 😇 | 👽 | 💛 | 💙 | 💜 | ❤️ | 💚 | 💔 | 💓 | 💗 | 💕 | 💞 | 💘 | ✨
// # Date Helper | |
// Usage: `{{date format="DD MM, YYYY"}}`, `{{date updated_at format="DD MM, YYYY"}}` | |
// | |
// Formats a date using moment.js. Formats published_at by default but will also take a date as a parameter | |
var moment = require('moment'), | |
date; | |
date = function (context, options) { | |
if (!options && context.hasOwnProperty('hash')) { |
// # Excerpt Helper | |
// Usage: `{{excerpt}}`, `{{excerpt words="50"}}`, `{{excerpt characters="256"}}` | |
// | |
// Attempts to remove all HTML from the string, and then shortens the result according to the provided option. | |
// | |
// Defaults to words="50" | |
var hbs = require('express-hbs'), | |
_ = require('lodash'), | |
downsize = require('downsize'), |
var Promise = require("bluebird"); | |
return Promise.map(objects, function (object) { | |
sails.log.info('An object will be created:'); | |
sails.log.info(object); | |
return Comment.findOrCreate(object.id , object); | |
}).then(function (objects) { | |
sails.log.info('The objects created or found goes here: '); | |
sails.log.info(objects); | |
return objects; |
/** | |
* 邮箱字符遮罩 | |
* @param email | |
* @returns {string} | |
* @private | |
*/ | |
function _hideEmail(email) { | |
var accounts = email.split('@')[0]; | |
var suffix = email.split('@')[1]; | |
var hideNums = Math.floor(accounts.length/2); |
let chance = require('chance')(); | |
function generatePhone(nums) { | |
if (!nums){ | |
nums = 1; | |
} | |
return chance.unique(function generatePhone() { | |
let phone = '1'; | |
phone+= chance.string({length: 1, pool: '34578'}); | |
phone+= chance.string({length: 9, pool: '9876543210'}); |
| 😄 | 😆 | 😊 | 😃 |
😩 | 😔 | 😞 | 😖 | 😨 | 😰 | 😣 | 😢 | 😭 | 😂 | 😲 | 😱 | | 😫 | 😠 | 😡 | 😤 | 😪 | 😋 | 😷
😎 | 😵 | 👿 | 😈 | 😐 | 😶 | 😇 | 👽 | 💛 | 💙 | 💜 | ❤️ | 💚 | 💔 | 💓 | 💗 | 💕 | 💞 | 💘 | ✨
var unidecode = require('unidecode'); | |
var safeString = function (string) { | |
string = string.trim(); | |
// Remove non ascii characters | |
string = unidecode(string).trim(); | |
// Remove URL reserved chars: `:/?#[]@!$&'()*+,;=` as well as `\%<>|^~£"` | |
string = string.replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '') | |
// Replace dots and spaces with a dash |
git init # 初始化本地git仓库(创建新仓库) | |
git config --global user.name "xxx" # 配置用户名 | |
git config --global user.email "xxx@xxx.com" # 配置邮件 | |
git config --global color.ui true # git status等命令自动着色 | |
git config --global color.status auto | |
git config --global color.diff auto | |
git config --global color.branch auto | |
git config --global color.interactive auto | |
git config --global --unset http.proxy # remove proxy configuration on git | |
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库 |
/** | |
* 泄露V8 Heap内存 | |
*/ | |
let total = []; | |
function useMem() { | |
let size = 1024 * 1024 * 20; // Per 20MB | |
let arr = new Array(size); | |
for (let i = 0; i < size; i++) { |
// 实现 | |
const queuedObservers = new Set(); | |
const observe = fn => queuedObservers.add(fn); | |
const observable = obj => new Proxy(obj, {set}); | |
function set(target, key, value, receiver) { | |
const result = Reflect.set(target, key, value, receiver); | |
queuedObservers.forEach(observer => observer()); | |
return result; |