###Clustered Force Layout using D3 v4
Modified from Mike Bostock's original.
Looks more like the version with custom gravity.
Compare with Shan Carter's v4 adaptation.
function fetchData(url, cb) { | |
var xhr = new XMLHttpRequest() // 新建一个请求对象,如果需要文档,查XMLHttpRequest | |
xhr.open('GET', url) // get类型, url;注意此时请求还没有发送 | |
xhr.onload = function() {cb(xhr.responseText)} // 写好callback回调函数,因为js是异步的,只用通过回调函数接收参数来获取。 | |
xhr.send() // 发送请求,这里才是真的开始请求,请求成功的话回调就成功了;post在这里发送数据 | |
} | |
(function () { | |
var callback = function (str) { | |
var data = JSON.parse(str) // JSON.parse, JSON.stringify 互相转换 |
function [varargout]=rp_sliceviewer(AOperation, varargin) | |
% Show a brain's slice. "rp_sliceviewer" can be opened more than one instance like MRIcro, and supports multi-slice, overlay and so on. by Xiao-Wei Song | |
%Usage: hFig =rp_sliceviewer('ShowImage', AFilename, CallBack); | |
% rp_sliceviewer('Delete', AFigHandle); | |
%Detailed usage is the code file "rp_sliceviewer.m" | |
%------------------------------------------------------------------------------------------------------------------------------ | |
% Copyright(c) 2007~2012 | |
% State Key Laboratory of Cognitive Neuroscience and Learning, Beijing Normal University | |
% Written by Xiao-Wei Song | |
% http://www.restfmri.net |
const fs = require('fs') | |
function rmPath(path, cb) { | |
fs.lstat(path, (err, stats) => { | |
//console.log('retrieve:', path) | |
if (stats.isDirectory()) { | |
fs.readdir(path, (err, files) => { | |
let len = files.length + 1 | |
let checkDir = () => { | |
//console.log(path + ' left:', len-1) |
var svgString = new XMLSerializer().serializeToString(root); | |
var width = root.clientWidth, height = root.clientHeight; | |
var canvas = document.createElement("canvas"); | |
canvas.width = width; | |
canvas.height = height; | |
var ctx = canvas.getContext('2d'); | |
var DOMURL = self.URL || self.webkitURL || self; | |
var img = new Image(); |
var system = require('system'), | |
fs = require('fs'), | |
process = require("child_process"); | |
var children = {}; | |
var port = system.args[1]; | |
var isParent = system.args[2]; | |
console.log('[process] port:', port); |
// parseSearch('?gws_rd=ssl') | |
// {gws_rd: "ssl"} | |
function parseSearch (str) { | |
str = str.split('?').pop() | |
var search = {} | |
str && str.replace( | |
/([^?=&]+)(=([^&]*))?/g, | |
function ($0, $1, $2, $3) { | |
search[ $1 ] = $3 |
from datetime import timedelta | |
from flask import make_response, request, current_app | |
from functools import update_wrapper | |
# replaced 'basestring' width 'str' for python3 | |
def crossdomain(origin=None, methods=None, headers=None, | |
max_age=21600, attach_to_all=True, | |
automatic_options=True): | |
if methods is not None: |
function jsonStringify (obj) { | |
var cache = [] | |
function filter (key, value) { | |
if (typeof value === 'object' && value != null) { | |
if (cache.includes(value)) { | |
return // may circular | |
} | |
cache.push(value) | |
} | |
return value |
#!/usr/bin/env python | |
import os | |
# Return CPU temperature as a character string | |
def getCPUtemperature(): | |
res = os.popen('vcgencmd measure_temp').readline() | |
return(res.replace("temp=","")) | |
# Return RAM information (unit=kb) in a list | |
# Index 0: total RAM |
###Clustered Force Layout using D3 v4
Modified from Mike Bostock's original.
Looks more like the version with custom gravity.
Compare with Shan Carter's v4 adaptation.