Skip to content

Instantly share code, notes, and snippets.

View jtyjty99999's full-sized avatar

Adams jtyjty99999

  • Tencent
  • Shenzhen China
View GitHub Profile
function isFunction(func) {
return func && typeof func === 'function';
}
export default class Sandbox {
constructor(props = {}) {
this.multiMode = false;
this.eventListeners = {};
this.timeoutIds = [];
this.intervalIds = [];
this.propertyAdded = {};
jiangtianyi@jiangtinyideMBP shuhe2 % yarn build sample
yarn run v1.22.4
$ node scripts/build.js sample
$ yarn workspace @alife/shuhe2-core build
warning package.json: No license field
$ rimraf lib/ && tsc
$ yarn workspace @alife/shuhe2-schema-form build
warning package.json: No license field
$ rimraf lib/ && babel src -d lib && cp -r src/types.d.ts lib
jiangtianyi@jiangtinyideMBP shuhe2 % yarn start sample
yarn run v1.22.4
$ node scripts/start.js sample
$ concurrently --names @alife/shuhe2-core,@alife/shuhe2-schema-form,@alife/shuhe2-data-sources,@alife/shuhe2-edit,sample --prefix-colors green,yellow,magenta,bgGreen,bgYellow "yarn workspace @alife/shuhe2-core start" "yarn workspace @alife/shuhe2-schema-form start" "yarn workspace @alife/shuhe2-data-sources start" "yarn workspace @alife/shuhe2-edit start" "yarn workspace sample start"
warning package.json: No license field
warning package.json: No license field
warning package.json: No license field
warning package.json: No license field
$ tsc -w --preserveWatchOutput
/*
var YijiConfig = {
// 商户id
partner:"20170413020014185029",
// 密钥
key:"21a121c1ca7c146581292c28892971f8",
// 网管
url:"https://openapi.yijifu.net/gateway.html?"
};
*/
@jtyjty99999
jtyjty99999 / 1.js
Created June 15, 2017 02:09
join with normalize
const benchmark = require('benchmark');
const suite = new benchmark.Suite;
const join = require('path').join;
const normalize = require('path').normalize;
const p = '/ddd/../../../aaa/bbb/ccc';
function getRandomStr() {
return '__' + Math.floor(Math.random() * 16777215).toString(16) + '__';
@jtyjty99999
jtyjty99999 / getCSSPath.js
Last active August 29, 2015 14:13
getCSSPath
var getCSSPath = function(elem, detail) {
var detail = detail || {};
var path = '', nextElem = elem;
if (detail.withAttrs) {
path += convertAttrsToCSS(elem);
}
if (detail.withIndex) {
path += ':nth-child(' + getSiblingIndex(elem) + ')';
}
/*
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
@jtyjty99999
jtyjty99999 / iebase64.js
Created September 23, 2014 07:58
ie base64
var x= new ActiveXObject("Msxml2.XMLHTTP.6.0");
x.onreadystatechange=function(){
if(x.readyState<4)return;
var xml_dom = new ActiveXObject("MSXML2.DOMDocument");
var tmpNode = xml_dom.createElement("tmpNode");
tmpNode.dataType = "bin.base64";
tmpNode.nodeTypedValue = x.responseBody;
base64string=tmpNode.text.replace(/\n/g,"");
document.write("<img src=\"data:image/bmp;base64,"+base64string+"\">")
@jtyjty99999
jtyjty99999 / save as
Created September 23, 2014 04:38
save as
function saveAs(blob, filename) {
var type = blob.type;
var force_saveable_type = 'application/octet-stream';
if (type && type != force_saveable_type) { // 强制下载,而非在浏览器中打开
var slice = blob.slice || blob.webkitSlice;
blob = slice.call(blob, 0, blob.size, force_saveable_type);
}
var url = URL.createObjectURL(blob);
var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
@jtyjty99999
jtyjty99999 / worker.js
Created August 11, 2014 03:49
跨域webworker
function XHRWorker(url, ready, scope) {
var oReq = new XMLHttpRequest();
oReq.addEventListener('load', function() {
var worker = new Worker(window.URL.createObjectURL(new Blob([this.responseText])));
if (ready) {
ready.call(scope, worker);
}
}, oReq);
oReq.open("get", url, true);
oReq.send();