Skip to content

Instantly share code, notes, and snippets.

View shhider's full-sized avatar

Shi Haohong shhider

  • DingTalk Docs / 钉钉文档
  • Hangzhou / 杭州
View GitHub Profile
library(tidyverse)
library(gganimate)
NUMPLAYERS = 45
ROUNDS = 5000
INITWEALTH = 45
#initialize the bank
#columns wealths of the NUMPLAYERS players
#rows show wealths of each of the ROUNDS ticks of the clocks
@shhider
shhider / common-shell-cmds.sh
Last active March 22, 2018 09:02
一些可能会用到,但老记不住的 Linux 命令
# 查看Linux的发行版本
lsb_release -a
uname -a
cat /etc/issue
cat /proc/version
# 列出本地已经安装了的 package
dpkg --get-selections | grep -v deinstall
groups # 查看本机所有的组
@shhider
shhider / po2json.js
Created August 16, 2017 07:25 — forked from zaach/po2json.js
PO parser from http://jsgettext.berlios.de/lib/Gettext.js adapted for Node.js and modified to be more like po2json.pl
#!/usr/bin/env node
/*
PO parser from http://jsgettext.berlios.de/lib/Gettext.js
adapted for Node.js and modified to be more like po2json.pl
- Zach Carter <zcarter@cse.usf.edu>
*/
/*
Pure Javascript implementation of Uniforum message translation.

sed 命令在 macOS 下使用存在两个问题:

-i参数之后必须带参数值

-i参数表示直接对文件进行操作,可提供一个参数值作为后缀名,使 sed 在替换前对文件进行备份,如sed -i ".bak" "s/aaa/bbb/g" filename。这个在 macOS 下必需,不需要备份的传空。

可能会出现编码问题

执行命令后,可能出现sed: RE error: illegal byte sequence的报错。

set: function (key, val, options) {
    // ...
    
    // You might be wondering why there's a `while` loop here. Changes can
    // be recursively nested within `"change"` events.
    if (changing) return this;
    if (!silent) {
        while (this._pending) {
 this._pending = false;

1、

if (x === undefined) { ... }

不严谨,undefined 关键字是可以被更改的。

2、

/**
* 时间格式化
* 今天的,显示“今天 08:08”
* 昨天、前天
* 3天前,显示具体日期
* @param {Number} _time UNIX时间戳
*/
_p._$timeFormat = (function () {
// 一天的毫秒数
var _oneDay = 24 * 60 * 60 * 1000;
@shhider
shhider / toUnicode.js
Last active July 29, 2021 08:52 — forked from littlee/toUnicode.js
[JavaScript convert string to unicode format] #tounicode
const toUnicode = (str) => str.split('').map((char) => {
const temp = char.charCodeAt(0).toString(16).toUpperCase();
if (temp.length > 2) {
return '\\u' + temp;
}
return char;
}).join('');
console.log(toUnicode('转换成 Unicode'));
@shhider
shhider / dirname-and-filename-in-nodejs-modules.js
Last active November 21, 2022 08:13
[paths in Node.js] #nodejs #path #__dirname #__filename
// https://stackoverflow.com/a/62892482/3676413
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);