Skip to content

Instantly share code, notes, and snippets.

View fengdi's full-sized avatar

tangoboy fengdi

View GitHub Profile
@fengdi
fengdi / test
Created March 16, 2020 07:53
vscode
//test
@fengdi
fengdi / index.html
Created September 3, 2019 08:38
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
@fengdi
fengdi / index.html
Created September 3, 2019 08:38
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
@fengdi
fengdi / index.html
Created September 3, 2019 08:37
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
@fengdi
fengdi / index.html
Created October 16, 2018 12:31
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
// An example of using yield to simplify the callback hell.
// The limitation is, this only apply to whose callbacks take the normal form of function(err, result), more arguments are ignored.
// Maybe there are many workarounds, but keep it simple, the ECMAScript 6 is around the corner.
function Async(task) {
var gen = task(callback);
function callback(err, result) {
@fengdi
fengdi / gist:5330459
Last active December 15, 2015 22:09
根据路径对一个json对象设置值 忽略异常
function setValueByPath(obj, path, value){
var temp, k, re = obj;
if(!obj || (typeof obj!="object" && typeof obj!="function"))
return obj;
(path+"").replace(/([^.:]+)([.:])?/g, function(m, n, sign){
temp = obj;
k = n;
obj = obj[n] = (obj!=void 0 && (typeof obj=="object" || typeof obj=="function") && n in obj) ? obj[n] : sign ==":" ? [] : {};
});
if(k && temp){
@fengdi
fengdi / gist:5326735
Last active December 15, 2015 21:38
根据路径获取json对象的值 忽略异常返回值友好
function getValueByPath(obj, path){
(path+"").replace(/[^.:]+/g,function(n){
obj = (obj!=void 0 && (typeof obj=="object" || typeof obj=="function") && n in obj) ? obj[n] : void 0;
});
return obj;
}
// getValueByPath({a:[{c:"r"}]}, "a.0.c"); // r