Skip to content

Instantly share code, notes, and snippets.

@leoyoung07
leoyoung07 / HomeController.cs
Last active September 8, 2020 07:07 — forked from blueblip/HomeController.cs
File download with pause and resume support in ASP.NET MVC
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
namespace Sample.Controllers
{
public class HomeController : Controller
{
[HttpHead]
[HttpGet]
@leoyoung07
leoyoung07 / NetStatPortsAndProcessNames.cs
Created April 30, 2020 08:14 — forked from cheynewallace/NetStatPortsAndProcessNames.cs
C# Get Active Ports and Associated Process Names. This code will parse the output from a "netstat -a -n -o" and retrieve a list of active listening ports, along with the associated PID. The PID is then resolved to a process name so we can see exactly which port is attached to which process.
// ===============================================
// The Method That Parses The NetStat Output
// And Returns A List Of Port Objects
// ===============================================
public static List<Port> GetNetStatPorts()
{
var Ports = new List<Port>();
try {
using (Process p = new Process()) {
@leoyoung07
leoyoung07 / docker-cleanup-resources.md
Created April 3, 2019 07:13 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
'use strict';
const debug = require('debug')('network');
function Networker(socket, handler) {
this.socket = socket;
this._packet = {};
this._process = false;
this._state = 'HEADER';