function getAllPropertyNames(obj) {
const props = [];
do {
if (obj === Object.prototype)
break;
Object.getOwnPropertyNames(obj).forEach(prop => {
if (!props.includes(prop)) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const hostsFilePath = "/etc/hosts"; | |
const fs = require("fs"); | |
const path = require("path"); | |
fs.readFile(hostsFilePath, (err, data) => { | |
let lines = data.toString().split("\n"); | |
console.log("lines: " + lines.length); | |
let hosts = lines.map(line => line.replace(/\s+/g, " ")) |
function* createGenerator() {
let first = yield 1;
let second = yield first + 2;
yield second + 3;
}
let iterator = createGenerator();
iterator.next(); // { value: 1, done: false}
iterator.next(4);// { value: 6, done: false}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env dotnet-script | |
using System.Runtime.CompilerServices; | |
using System.IO; | |
using System.Text.RegularExpressions; | |
public static string GetScriptFolder([CallerFilePath] string path = null) => Path.GetDirectoryName(path); | |
static readonly var HOST_PATH = Environment.OSVersion.Platform == PlatformID.Unix ? "/etc/hosts" : @"C:\Windows\System32\drivers\etc\hosts"; | |
public static async Task<IDictionary<String, List<String>>> GetPrettyHosts() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: Newtonsoft.Json, 12.0.2" | |
using System.Net.Http; | |
using static System.Console; | |
using Newtonsoft.Json; | |
using static Newtonsoft.Json.JsonConvert; | |
if (Args.Count == 0) | |
{ | |
Console.WriteLine($@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 0. Your file name | |
FNAME="$2" | |
# 1. Somehow sanitize the file content | |
# Remove \r (from Windows end-of-lines), | |
# Replace tabs by \t | |
# Replace " by \" | |
# Replace EOL by \n | |
CONTENT=$(sed -e 's/\r//' -e's/\t/\\t/g' -e 's/"/\\"/g' "${FNAME}" | awk '{ printf($0 "\\n") }') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"globals" : | |
{ | |
"alwaysShowTabs" : true, | |
"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"initialCols" : 120, | |
"initialRows" : 30, | |
"keybindings" : | |
[ | |
{ |
编辑 /etc/apk/repositories
,然后在文件的最顶端添加(注意将 3.3 换成需要的版本)
http://mirrors.ustc.edu.cn/alpine/v3.3/main/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 所有Promise都被 settled | |
* @param {[{promise: function():Promise, data: {}}]} promises | |
* @retu {Promise<[{isResolve: boolean, isReject: boolean, error: {}, result: {}, data: {}}]>} | |
*/ | |
Promise.whenAllSettled = function (promises) { | |
const isPromise = function (obj) { | |
return obj && typeof obj.then === "function" && typeof obj.catch === "function"; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"), path = require("path"); | |
let debugMode = false; | |
//#region 日志函数 | |
function log(txt) { | |
if (debugMode) { | |
console.log(`[${new Date().toLocaleString()}] ${txt}`); | |
} | |
} | |
function warn(txt) { |