Skip to content

Instantly share code, notes, and snippets.

Gaubee Gaubee

Block or report user

Report or block Gaubee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 解决 Git 在 windows 下中文乱码的问题.md

解决 Git 在 windows 下中文乱码的问题

原因

中文乱码的根源在于 windows 基于一些历史原因无法全面支持 utf-8 编码格式,并且也无法通过有效手段令其全面支持。

解决方案

  1. 安装
@Gaubee
Gaubee / account.chain.ts
Last active May 18, 2018
使用数组来链式记录账户的余额
View account.chain.ts
import { MongoClient } from 'mongodb';
const url = 'mongodb://localhost:27017';
const dbName = 'test-set';
import { ConsolePro } from "console-pro";
const console = new ConsolePro();
/**等待n毫秒 */
function sleep(ms: number) {
return new Promise(cb => setTimeout(cb, ms));
}
@Gaubee
Gaubee / remove-term-color.js
Created May 16, 2018
remove terminal color.
View remove-term-color.js
const color_flag_reg = /((\u001b\[\d+m)+)([\s\S]+?)((\u001b\[\d+m)+)/;
s.replace(color_flag_reg, "$3");
@Gaubee
Gaubee / worker.example.js
Last active Jan 11, 2018
separate read and write 读写分离
View worker.example.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cluster = require("cluster"); // const cluster = require("cluster")
const os = require("os"); // const os = require("os")
/* Share code */
const prepare_job_promise = new Promise((resolve, reject) => {
// bootstrap modules
setTimeout(resolve, 1000);
});
// or write like this
@Gaubee
Gaubee / keyboard-attach.ts
Last active Nov 3, 2017
ionic2+更好地处理软键盘弹出的方案
View keyboard-attach.ts
import { Directive, ElementRef, Input } from '@angular/core';
import { Content, Platform } from 'ionic-angular';
import { Keyboard } from '@ionic-native/keyboard';
import { Subscription } from 'rxjs/rx';
/**
* @name KeyboardAttachDirective
* @description
* The `keyboardAttach` directive will cause an element to float above the
* keyboard when the keyboard shows. Currently only supports the `ion-footer` element.
@Gaubee
Gaubee / PromisePool.js
Created Oct 29, 2017
JS实现+=/-=操作符号的重载
View PromisePool.js
// __op_temp_null_: 说明缓存取中没有东西
Object.defineProperty(global, "__op_temp_null_", {
value: Symbol("Operators Object NULL")
});
const op_temp_key = Symbol("Operators Object TEMP");
Object.defineProperty(global, "__op_temp__", {
get() {
const res = this[op_temp_key];
// 取值后马上移除引用关系
this[op_temp_key] = global.__op_temp_null_;
@Gaubee
Gaubee / H5lock.md
Last active Mar 1, 2018
Pattern Lock Base on Canvas
View H5lock.md

How to use

const lock = new H5lock({
  width: number,
  height: number,
  container: Element|id,
  chooseType ?: 2|3|4|5, // default is 3: 3×3
  inputEnd(pwd){
    console.log('Pattern Lock Value Is:', pwd);
  }
View Capture DOM.MD
domToImg.dom = document.body;
domToImg.download(location.protocol + "//" + location.host + "/build/main.css");
@Gaubee
Gaubee / Flow of Find PWD.js
Last active Oct 7, 2017
基于Generator的流程控制实践
View Flow of Find PWD.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* 流程的状态机
*/
var FLOW_PROCESS_STATUS;
(function (FLOW_PROCESS_STATUS) {
FLOW_PROCESS_STATUS[FLOW_PROCESS_STATUS["BEFORE_START"] = 0] = "BEFORE_START";
FLOW_PROCESS_STATUS[FLOW_PROCESS_STATUS["INPUT_EMAIL"] = 1] = "INPUT_EMAIL";
FLOW_PROCESS_STATUS[FLOW_PROCESS_STATUS["INPUT_CODE"] = 2] = "INPUT_CODE";
@Gaubee
Gaubee / firebase-pagination.js
Last active Apr 9, 2017
Firebase pagination
View firebase-pagination.js
const admin = require("./firebase-admin");
admin.initializeApp({
credential: **yourCredential**
databaseURL: **yourDatabaseURL**
});
const db = admin.database();
const dbPromise = (db_ref, options = {}) => {
const {
can_null,
You can’t perform that action at this time.