Skip to content

Instantly share code, notes, and snippets.

@xiaoli
xiaoli / Ping.cs
Last active September 15, 2017 02:58 — forked from Mailaender/Ping.cs
Ping a host and calculate packet loss.
void GetNetworkStats(string host, int pingAmount, int timeout, out int averagePing, out int packetLoss)
{
Ping pingSender = new Ping();
PingOptions options = new PingOptions(); // default is: don't fragment and 128 Time-to-Live
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data); // 32 bytes of data
var failedPings = 0;
var latencySum = 0;
@xiaoli
xiaoli / SwiftUI-TextView.swift
Last active September 19, 2020 08:52 — forked from shaps80/SwiftUI-TextView.md
A SwiftUI view that wraps a UITextView but provides almost all functionality though modifiers and attempts to closely match the Text/TextField components.
/*
Notes:
The font modifier requires the following gist:
https://gist.github.com/shaps80/2d21b2ab92ea4fddd7b545d77a47024b
*/