Skip to content

Instantly share code, notes, and snippets.

View dr2009's full-sized avatar
🐑
type-safe

dr2009 dr2009

🐑
type-safe
View GitHub Profile
@dr2009
dr2009 / .npmrc
Created June 24, 2019 06:29
.npmrc
// .npmrc
disturl=https://npm.taobao.org/dist
registry=https://registry.npm.taobao.org
@xxx:registry=http://registry.npm.xxx.com
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
fse_binary_host_mirror=https://npm.taobao.org/mirrors/fsevents
chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
@dr2009
dr2009 / TopView.tsx
Created April 15, 2019 14:50
rn-topview
/*
*
* Top View
*
*/
import React, { isValidElement } from 'react';
import { AppRegistry, DeviceEventEmitter, View } from 'react-native';
export interface TopViewProps {
children?: React.ReactNode
@dr2009
dr2009 / decorate.ts
Last active January 10, 2019 08:23
兼容支持 @log,@log(...args)的装饰器
type TArgs = any[];
type TObjArgs = [object, string | symbol, TypedPropertyDescriptor<any>];
function log(...args: TArgs | TObjArgs): any {
return isDescriptor(args)
? decorate(...args)
: (...decoArgs: TObjArgs) => {
const params = [...decoArgs, ...args] as [object, string | symbol, TypedPropertyDescriptor<any>, any];
decorate(...params);
};
@dr2009
dr2009 / demo.js
Created March 21, 2018 15:48
ES6 Singleton
// 单例
var instanceA = Singleton.getInstance("小王");
var instanceB = Singleton.getInstance("小张");
console.log(instanceA === instanceB);
console.log(instanceA.name,instanceB.name);
// 非单例
var instanceC = new Singleton("小王");
var instanceD = new Singleton("小张");
.flex {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.flex.flex--reverse {
-webkit-box-orient: horizontal;