| # iex (iwr "https://gist.githubusercontent.com/anonhostpi/1cc0084b959a9ea9e97dca9dce414e1f/raw/webserver.ps1").Content | |
| function New-Webserver { | |
| param( | |
| [string] $Binding = "http://localhost:8080/", | |
| [string] $BaseDirectory = "$(Get-Location -PSProvider FileSystem)", | |
| [string] $Name = "PowerShell Web Server", | |
| [System.Collections.IDictionary] $Routes = @{ | |
| Before = { param( $Server, $Command, $Listener, $Context ) return $true } |
| <%* | |
| //v1.1: Changed to using the new "view.editor" instead of deprecated "view.sourceMode.cmEditor" | |
| let cmEditorAct = this.app.workspace.activeLeaf.view.editor; | |
| let curLine = cmEditorAct.getCursor().line; | |
| cmEditorAct.setSelection({ line: curLine, ch: 0 }, { line: curLine, ch: 9999 }); | |
| function createBlockHash() { | |
| let result = ''; | |
| var characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; |
Check out User.cs down below. It's a pretty simple class with three constructors: the default (parameterless) one, and one each taking the user name, and id. PowerShell will cast using the constructors of a type, so in this case, you can cast either a string or a number --or a hashtable-- to User.
We can add this type to our PowerShell session using Add-Type:
Add-Type -path User.csCoroutines or async/await is not a new concept as it was named in 1958 by Melvin Conway. Coroutines had support in languages such as Simula(1962), Smalltalk(1972) and Modula-2(1978) but I think one can argue that coroutines came into mainstream with C# 5(2012) when Microsoft added async/await to C#.
A thread can only execute a single subroutine at a time as a subroutine starts and then runs to completion. In a server environment subroutines can be problematic as in order to service connections concurrently we would usually would start a thread per connection, this was the idiom a few years ago. A thread depending on the operating system and settings needs about 1 MiB of user stack space meaning 1,024 threads needs 1 GiB of for just user stack space. In addition there's the cost of kernel stack space, book-keeping and scheduling of threads. This drives cost of VM/hardwa
Enter this in the search box along with your search terms:
Get all gists from the user santisbon.
user:santisbon
Find all gists with a .yml extension.
extension:yml
Find all gists with HTML files.
language:html
David Wilson - @daviwil Software Engineer, PowerShell Team
- Visual Studio Code overview
- Configuring the editor
- Extensions
| class DependsOn : System.Attribute { | |
| [string[]]$Name | |
| DependsOn([string[]]$name) { | |
| $this.Name = $name | |
| } | |
| } | |
| function Invoke-Step { |
| # Moved to https://github.com/nightroman/FarGit |
| /// <summary> | |
| /// Helper to encode and set HTML fragment to clipboard.<br/> | |
| /// See http://theartofdev.com/2014/06/12/setting-htmltext-to-clipboard-revisited/.<br/> | |
| /// <seealso cref="CreateDataObject"/>. | |
| /// </summary> | |
| /// <remarks> | |
| /// The MIT License (MIT) Copyright (c) 2014 Arthur Teplitzki. | |
| /// </remarks> | |
| public static class ClipboardHelper | |
| { |