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 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 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, " ")) |
This file contains 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
public class GlobalWebApiExceptionFilter : ExceptionFilterAttribute | |
{ | |
public override void OnException(HttpActionExecutedContext context) | |
{ | |
base.OnException(context); | |
if (context.Exception is NotImplementedException) | |
{ | |
context.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.OK); | |
context.Response.Content = new System.Net.Http.StringContent("not implement"); | |
} |
This file contains 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
public class GlobalErrorActionFilter : IExceptionFilter | |
{ | |
public void OnException(ExceptionContext filterContext) | |
{ | |
Exception ex = filterContext.Exception; | |
filterContext.ExceptionHandled = true; | |
var response = filterContext.HttpContext.Response; | |
response.Clear(); | |
response.StatusCode = 200; |
This file contains 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
@echo off | |
SET st2Path=C:\Program Files\Sublime Text 3\sublime_text.exe | |
rem add it for all file types | |
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f | |
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f | |
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f | |
rem add it for folders | |
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f |
This file contains 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
using System; | |
using System.Collections; | |
using System.Net; | |
using System.Net.Security; | |
using System.Net.Sockets; | |
using System.Security.Authentication; | |
using System.Text; | |
using System.Security.Cryptography.X509Certificates; | |
using System.IO; |
This file contains 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
using System; | |
using System.Text; | |
using System.IO; | |
using System.Net; | |
using System.Net.Sockets; | |
public class GetSocket | |
{ | |
private static Socket ConnectSocket(string server, int port) | |
{ |
This file contains 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
//TODO | |
/** | |
* filter | |
* map | |
* skip | |
* take | |
* aggregate | |
* sum | |
* order |