删除 jigsaw-demo-description 相关内容
168344
function fixDemoComponentHtml(component, folder) {
    var re = /<!-- ignore the following lines[\s\S]*<!-- start to learn the demo from here -->\r?\n/;
    component.code = component.code.replace(re, '');

    if (component.code.indexOf('jigsaw-demo-description') != -1) {
        console.error('ERROR: can not strip "jigsaw-demo-description" from html!');
        console.error(`       path=${folder}`);
        process.exit(1);
    }
}
283688
function tree() {
  let bodyHeight = 400;
  let keyDef = d => d.id;
  let parentDef = d => d.parent;
  let defaultLevel = 99999;
  let nodeEnterFactory = () => {};
  let nodeMergeFactory = () => {};

  // Recursively append child nodes
  function nextLevel(selection, data) {
    if (!selection.select('.childlist').size()) {
      selection.append('ul')
        .classed('childlist', true)
        .style('list-style-type', 'none');
    }
    const items = selection.select('.childlist')
      .selectAll('li')
        .data(data, keyDef);
    items.exit().remove();
    items.enter()
      .append('li')
        .each(function (d) {
          d3.select(this).call(nodeEnterFactory, d.data);
        })
      .merge(items)
        .each(function (d) {
          const node = d3.select(this);
          node.call(nodeMergeFactory, d.data);
          if (d.hasOwnProperty('children')) {
            node.call(nextLevel, d.children)
              .select('.arrow')
                .text(d => d.depth - 1 >= defaultLevel ? '▶ ' : '▼ ')
                .on('click', function () {  // Collapse on click
                  const childList = node.select('.childlist');
                  const expanded = childList.style('display') !== 'none';
                  d3.select(this).text(expanded ? '▶ ' : '▼ ');
                  childList.style('display', expanded ? 'none' : 'inherit');
                });
            node.select('.childlist')
                .style('display',
                  d => d.depth - 1 >= defaultLevel ? 'none' : 'inherit');
          } else {
            node.select('.childlist').remove();
          }
        });
  }

  function _tree(selection, records) {
    const root = d3.stratify()
        .id(keyDef)
        .parentId(parentDef)(records);
    selection
        .style('overflow-y', 'scroll')
        .style('height', `${bodyHeight}px`);
    if (!selection.select('.body').size()) {
      selection.append('div').classed('body', true);
    }
    selection.select('.body')
        .call(nextLevel, root.children || []);
    selection.selectAll('.body > ul')
        .style('padding-left', 0);
    selection.selectAll('.body > ul > li')
        .classed('my-2', true);
  }

  _tree.bodyHeight = function (h) {
    bodyHeight = h;
    return _tree;
  };

  _tree.keyDef = function (f) {
    keyDef = f;
    return _tree;
  };

  _tree.defaultLevel = function (lv) {
    defaultLevel = lv;
    return _tree;
  };

  _tree.nodeEnterFactory = function (f) {
    nodeEnterFactory = f;
    return _tree;
  };

  _tree.nodeMergeFactory = function (f) {
    nodeMergeFactory = f;
    return _tree;
  };

  return _tree;
}
629513
def demo(nums=[]):
    ""

    nums = nums or [3, 1, 4, 1, 5, 9, 2, 6]
    fmt = lambda num: '{0:g}'.format(num) if isinstance(num, (float, int)) else 'None'
    nums1 = list(map(fmt, nums))

    if __name__ == '__main__':
        prog = sys.argv[0]
    else:
        prog = 'sparklines'

    result = []


    result.append('Usage examples (command-line and programmatic use):')
    result.append('')

    result.append('- Standard one-line sparkline')
    result.append('{0!s} {1!s}'.format(prog, ' '.join(nums1)))
    result.append('>>> print(sparklines([{0!s}])[0])'.format(', '.join(nums1)))
    result.append(sparklines(nums)[0])
    result.append('')

    result.append('- Multi-line sparkline (n=2)')
    result.append('{0!s} -n 2 {1!s}'.format(prog, ' '.join(nums1)))
    result.append('>>> for line in sparklines([{0!s}], num_lines=2): print(line)'.format(', '.join(nums1)))
    for line in sparklines(nums, num_lines=2):
        result.append(line)
    result.append('')

    result.append('- Multi-line sparkline (n=3)')
    result.append('{0!s} -n 3 {1!s}'.format(prog, ' '.join(nums1)))
    result.append('>>> for line in sparklines([{0!s}], num_lines=3): print(line)'.format(', '.join(nums1)))
    for line in sparklines(nums, num_lines=3):
        result.append(line)
    result.append('')

    nums = nums + [None] + list(reversed(nums[:]))
    result.append('- Standard one-line sparkline with gap')
    result.append('{0!s} {1!s}'.format(prog, ' '.join(map(str, nums))))
    result.append('>>> print(sparklines([{0!s}])[0])'.format(', '.join(map(str, nums))))
    result.append(sparklines(nums)[0])
    return '\n'.join(result) + '\n'
722345
function onlyCreateFrom(summaryFilePath){
    /**
     * @var {string} agm 额外需要写入文件的内容。
     */
    var agm = arguments[1];
    var ostpye = require('os').type;
    if(fs.existsSync(summaryFilePath)){
        var rl = readline.createInterface({
            input: fs.createReadStream(summaryFilePath)
        });
        rl.on('line', function (line) {
            var title = line.match(/\[[\s\S]*\]\B/g);
            title = '# ' + title[0].replace(/^\[|\]$/g, "");
            var filePath = line.match(/\]\([\w\W]*\)\B/g);
            var fileName = filePath[0].replace(/[\]\(\)]/g,"");
            if(ostpye=="Windows_NT" && agm!==undefined){
                var wData = title + '\r\n'+agm;
                nNmc.fs_wfSync(fileName,wData,false)
            }else if(ostpye !=="Windows_NT" && agm!==undefined){
                var wData = title + '\n'+agm;
                nNmc.fs_wfSync(fileName,wData,false)
            }else{
                nNmc.fs_wfSync(fileName,title,false)
            }
            console.log(`${chalk.yellow('summarybuilder:  ')}`+fileName+'.........created!');
        });
    }else{
        console.log(`${chalk.yellow('summarybuilder:  ')}找不到文件(No such file)--`+summaryFilePath)
    }
}
990413
function drawEmptySlice() {

            if (slices) {
                svg.selectAll('g.arc').remove();
            }
            slices = svg.select('.chart-group')
                .selectAll('g.arc')
                .data(layout(emptyDonutData));

            let newSlices = slices.enter()
                .append('g')
                  .each(storeAngle)
                  .each(reduceOuterRadius)
                  .classed('arc', true)
                  .append('path');

            newSlices.merge(slices)
                .attr('fill', emptyDataConfig.emptySliceColor)
                .attr('d', shape)
                .transition()
                .ease(ease)
                .duration(pieDrawingTransitionDuration)
                .attrTween('d', tweenLoading);

            slices.exit().remove();
        }
371716
function (s) {
          s = Tools.trim(s);

          function rep(re, str) {
            s = s.replace(re, str);
          }

          // example: [b] to <strong>
          rep(/\n/gi, "<br />");
          rep(/\[b\]/gi, "<strong>");
          rep(/\[\/b\]/gi, "</strong>");
          rep(/\[i\]/gi, "<em>");
          rep(/\[\/i\]/gi, "</em>");
          rep(/\[u\]/gi, "<u>");
          rep(/\[\/u\]/gi, "</u>");
          rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, "<a href=\"$1\">$2</a>");
          rep(/\[url\](.*?)\[\/url\]/gi, "<a href=\"$1\">$1</a>");
          rep(/\[img\](.*?)\[\/img\]/gi, "<img src=\"$1\" />");
          rep(/\[color=(.*?)\](.*?)\[\/color\]/gi, "<font color=\"$1\">$2</font>");
          rep(/\[code\](.*?)\[\/code\]/gi, "<span class=\"codeStyle\">$1</span>&nbsp;");
          rep(/\[quote.*?\](.*?)\[\/quote\]/gi, "<span class=\"quoteStyle\">$1</span>&nbsp;");

          return s;
        }
396844
function setCanvas_main(puzzle, type){
	/* fillTextが使えない場合は強制的にSVG描画に変更する */
	if(type==='canvas' && !!pzpr.Candle.enable.canvas && !CanvasRenderingContext2D.prototype.fillText){ type = 'svg';}
	
	pzpr.Candle.start(puzzle.canvas, type, function(g){
		pzpr.util.unselectable(g.canvas);
		g.child.style.pointerEvents = 'none';
		if(g.use.canvas && !puzzle.subcanvas){
			var canvas = puzzle.subcanvas = createSubCanvas('canvas');
			if(!!document.body){
				canvas.id = "_"+(new Date()).getTime()+type; /* 何か他とかぶらないようなID */
				canvas.style.position = 'absolute';
				canvas.style.left = '-10000px';
				canvas.style.top = '0px';
				document.body.appendChild(canvas);
			}
		}
		if(puzzle.ready){ postCanvasReady(puzzle);}
	});
}
948763
function Edge(n1, n2, dataIndex) {

    /**
     * 节点1，如果是有向图则为源节点
     * @type {module:echarts/data/Graph.Node}
     */
    this.node1 = n1;

    /**
     * 节点2，如果是有向图则为目标节点
     * @type {module:echarts/data/Graph.Node}
     */
    this.node2 = n2;

    this.dataIndex = dataIndex == null ? -1 : dataIndex;
}
927939
function heapSnapShotCalculateP(heapData, options) {
        return co(_heapSnapShot, heapData, options)

        /**
         * 内部方法，具体处理逻辑
         */
        function* _heapSnapShot(heapData, options) {
            const jsHeapSnapShot = new common.worker.JSHeapSnapshot(heapData, {
                updateStatusP(msg, end) {
                    const cb = options.callback;
                    const params = options.params.apply(options, [msg, Date.now(), end]);
                    return cb(params.message, params.socket);
                },

                consoleWarn(str) {
                    // console.warn(str);
                }
            });
            //load data
            yield jsHeapSnapShot.initializeP();

            const needed = [`_statistics`, `_aggregates`, `_metaNode`, `nodes`, `containmentEdges`, `strings`, `_nodeFieldCount`, `_edgeFieldsCount`, `_firstEdgeIndexes`, `_retainedSizes`, `_nodeDistances`];
            //taken out
            Object.keys(jsHeapSnapShot).forEach(key => { if (!~needed.indexOf(key)) jsHeapSnapShot[key] = null; });
            //release heapData
            heapData = null;

            return jsHeapSnapShot;
        }
    }
550719
function(gridCompColumn,i,begin,length, isFixedColumn){
			var oThis = this,renderType = gridCompColumn.options.renderType,
				sumCol = gridCompColumn.options.sumCol,
				sumRenderType = gridCompColumn.options.sumRenderType,
				dataType = gridCompColumn.options.dataType,
				precision = gridCompColumn.options.precision,
				format = gridCompColumn.options.format,field = gridCompColumn.options.field,
				end = begin,idSuffix = isFixedColumn === true ? '_content_fixed_tbody' : '_content_tbody',
				idStr = isFixedColumn === true? 'fixed_' : '';
			if(length >0){
				end = parseInt(begin + length - 1);
			}
			this.realtimeTableRows = document.getElementById(oThis.options.id + idSuffix).children;
			// 记录role不是row的行
			var notRowIndex = -1;
			for(var k = 0;k < oThis.realtimeTableRows.length;k++) {
				if(oThis.realtimeTableRows[k].getAttribute("role") != "row") {
					notRowIndex = k
				}
			}
			$.each(oThis.dataSourceObj.rows, function(j) {
				if((begin >= 0 && j >= begin && j <= end) || isNaN(begin)){
					var trIndex = j;
					if(notRowIndex != -1 && j >= notRowIndex) {
						trIndex++;
					}
					var tr = oThis.realtimeTableRows[trIndex],td = tr.children[i];
					if(td){
						if(td.children[0].innerHTML.indexOf('u-grid-content-tree-span')   !=  -1){
							var span =  td.children[0].children[1];
						}else{
							var span =  td.children[0];
						}
						if(span){
							var v = $(this.value).attr(field);
							if(typeof renderType == 'function' || dataType == 'Date' || dataType == 'Datetime' || dataType == 'Int' || dataType == 'Float'){
								span.innerHTML = '';
								if(typeof renderType == 'function'){
									v = oThis.getString(v,'');
									var obj = {};
									obj.value = v;
									obj.element = span;
									obj.gridObj = oThis;
									obj.row = this;
									obj.gridCompColumn = gridCompColumn;
									obj.rowIndex = j;
									renderType.call(oThis,obj);
								}else if(dataType == 'Date' || dataType == 'Datetime'){
									if(v == null || v == undefined || v == 'null' || v == 'undefined' || v == ""){
										v = "";
									}
									if (dataType == 'Date'){
										v = u.dateRender(v);
									}else{
										v = u.dateTimeRender(v);
									}
									span.innerHTML = v;
									td.title = v;
								}else if(dataType == 'Int'){
									v = parseInt(v);
									span.innerHTML = v;
									td.title = v;
								}else if(dataType == 'Float'){
									if(precision){
										var o = {};
										o.value = v;
										o.precision = precision;
										v = oThis.DicimalFormater(o);
									}else{
										v = parseFloat(v);
									}
									span.innerHTML = v;
									td.title = v;
								}else{ //此处逻辑放到渲染处，减少render执行次数。
									v = oThis.getString(v,'');
									var v1 = v.replace(/\</g,'\<');
									v1 = v1.replace(/\>/g,'\>');
									td.title = v;
									v = v.replace(/\</g,'&lt;');
									v = v.replace(/\>/g,'&gt;');

									span.innerHTML = v;
								}
							}else{
								v = oThis.getString(v,'');
								var v1 = v.replace(/\</g,'\<');
								v1 = v1.replace(/\>/g,'\>');
								td.title = v;
								v = v.replace(/\</g,'&lt;');
								v = v.replace(/\>/g,'&gt;');

								span.innerHTML = v;
							}
						}

					}
				}
			});
			this.renderTypeSumRow(gridCompColumn,i,begin,length, isFixedColumn);
		}
1056048
public List<List<Vertex>> biSegment(char[] sSentence, int nKind, WordNet wordNetOptimum, WordNet wordNetAll)
    {
        List<List<Vertex>> coarseResult = new LinkedList<List<Vertex>>();
        ////////////////生成词网////////////////////
        generateWordNet(wordNetAll);
//        logger.trace("词网大小：" + wordNetAll.size());
//        logger.trace("打印词网：\n" + wordNetAll);
        ///////////////生成词图////////////////////
        Graph graph = generateBiGraph(wordNetAll);
//        logger.trace(graph.toString());
        if (HanLP.Config.DEBUG)
        {
            System.out.printf("打印词图：%s\n", graph.printByTo());
        }
        ///////////////N-最短路径////////////////////
        NShortPath nShortPath = new NShortPath(graph, nKind);
        List<int[]> spResult = nShortPath.getNPaths(nKind * 2);
        if (spResult.size() == 0)
        {
            throw new RuntimeException(nKind + "-最短路径求解失败，请检查上面的词网是否存在负圈或悬孤节点");
        }
//        logger.trace(nKind + "-最短路径");
//        for (int[] path : spResult)
//        {
//            logger.trace(Graph.parseResult(graph.parsePath(path)));
//        }
        //////////////日期、数字合并策略
        for (int[] path : spResult)
        {
            List<Vertex> vertexes = graph.parsePath(path);
            generateWord(vertexes, wordNetOptimum);
            coarseResult.add(vertexes);
        }
        return coarseResult;
    }
276392
private void initNShortPath(Graph inGraph, int nValueKind)
    {
        graph = inGraph;
        N = nValueKind;

        // 获取顶点的数目
        vertexCount = inGraph.vertexes.length;

        fromArray = new CQueue[vertexCount - 1][];  // 不包含起点
        weightArray = new double[vertexCount - 1][];

        //每个节点的最小堆
        for (int i = 0; i < vertexCount - 1; i++)
        {
            fromArray[i] = new CQueue[nValueKind];
            weightArray[i] = new double[nValueKind];

            for (int j = 0; j < nValueKind; j++)
                fromArray[i][j] = new CQueue();
        }
    }
265409
function(x, y, isSmooth) {
                //顶点
                this.vertex = new ShapePoint(x, y);
                //控制点
                this.forward = new ShapePoint(x, y);
                this.backward = new ShapePoint(x, y);
                //是否平滑
                this.setSmooth(isSmooth === undefined || isSmooth);
                this.setSymReflaction(true);
            }
572386
def part_show(self, part, printout=False):
        '''
        
        '''

        result = self._e.parts_match(
            queries=[{'mpn_or_sku': part}],
            exact_only=True,
            show_mpn=True,
            show_octopart_url=True
        )
        if result[1][0]['hits'] == 0:
            print("No result")
            return ReturnValues.NO_RESULTS
        result = result[1][0]['items'][0]
        if not printout:
            print("Opening page for part '{}'.".format(result['mpn']))
            webbrowser.open(result['octopart_url'], 2)
        else:
            print("Webpage for part '{}':".format(result['mpn']))
            print("    → URL:      {}".format(result['octopart_url']))
        return ReturnValues.OK
12372
function(g,g2,x1,y1,x2,y2){
		// source側はtaranslateのぶん足されていないので、加算しておきます
		var sx1 = this.x0+x1*this.bw-1, sy1 = this.y0+y1*this.bh-1,
			sx2 = this.x0+x2*this.bw+2, sy2 = this.y0+y2*this.bh+2;
		if(sx1<0){ sx1=0;} if(sx2>g2.child.width) { sx2=g2.child.width;}
		if(sy1<0){ sy1=0;} if(sy2>g2.child.height){ sy2=g2.child.height;}
		g.drawImage(g2.child, sx1, sy1, (sx2-sx1), (sy2-sy1), sx1-this.x0, sy1-this.y0, (sx2-sx1), (sy2-sy1));
	}
982432
def get_random_parts(image, options={})
      # 图片切割份数
      part_count = options.fetch(:part_count, rand(5..10)).to_i.abs

      part_count.times.map do |index|
        tmp_height = (image.height / part_count).to_i

        x = rand(1...image.width)
        y = rand(1...tmp_height) + index * tmp_height

        part_width = options.fetch(:part_width, rand(10..30)).to_i.abs
        part_height = options.fetch(:part_height, rand(10..30)).to_i.abs

        [x, y, part_width, part_height]
      end
    end
899816
private static int getMachinePiece() {
		// 机器码
		int machinePiece;
		try {
			StringBuilder netSb = new StringBuilder();
			// 返回机器所有的网络接口
			Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
			// 遍历网络接口
			while (e.hasMoreElements()) {
				NetworkInterface ni = e.nextElement();
				// 网络接口信息
				netSb.append(ni.toString());
			}
			// 保留后两位
			machinePiece = netSb.toString().hashCode() << 16;
		} catch (Throwable e) {
			// 出问题随机生成,保留后两位
			machinePiece = (RandomUtil.randomInt()) << 16;
		}
		return machinePiece;
	}