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
var driveQuery = new ManagementObjectSearcher("select * from Win32_DiskDrive"); | |
foreach (ManagementObject d in driveQuery.Get()) | |
{ | |
var deviceId = d.Properties["DeviceId"].Value; | |
//Console.WriteLine("Device"); | |
//Console.WriteLine(d); | |
var partitionQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_DiskDriveToDiskPartition", d.Path.RelativePath); | |
var partitionQuery = new ManagementObjectSearcher(partitionQueryText); | |
foreach (ManagementObject p in partitionQuery.Get()) | |
{ |
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
module StateMachine = | |
type State<'Event> = | |
| Next of ('Event -> State<'Event>) | |
| Stop | |
let feed state event = | |
match state with | |
| Stop -> failwith "Terminal state reached" | |
| Next handler -> event |> handler |
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
param([String]$url, [String]$path="") | |
# It is a poor man's cURL, but can be used to download cURL | |
# powershell -file download.ps1 -url https://dl.uxnr.de/build/curl/curl_winssl_cross_x64/curl-7.50.3/curl-7.50.3.zip | |
# powershell -file download.ps1 -url https://cdn.rawgit.com/martinrotter/7za/master/7za.exe | |
# NOTE: may require "Set-ExecutionPolicy RemoteSigned" | |
if ($path -eq "") { | |
$path = [System.IO.Path]::GetFileName($url) | |
} |
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.Concurrent; | |
using System.Linq; | |
using System.Runtime.CompilerServices; | |
using System.Text; | |
namespace K4os.Fx; | |
internal static class ReflectionExtensions | |
{ |
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
// NOTE: this method does not throw it just "prepares to be thrown" | |
static Exception Rethrow(this Exception ex) | |
{ | |
try | |
{ | |
typeof(Exception) | |
.GetMethod("PrepForRemoting", BindingFlags.NonPublic | BindingFlags.Instance) | |
.Invoke(ex, new object[0]); | |
} | |
catch (Exception) |
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 NLog; | |
using NLog.Config; | |
using NLog.Targets; | |
using System.IO; | |
namespace ProductName | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
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
## NOTE: pip install requests | |
import requests | |
import sys | |
import argparse | |
from shutil import copyfileobj | |
from urllib.parse import urlparse | |
from os.path import basename, isfile | |
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.Linq; | |
// ReSharper disable once CheckNamespace | |
namespace System; | |
/// <summary> | |
/// Adhoc disposable from action. | |
/// </summary> | |
public class Disposable: IDisposable | |
{ |
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 | |
setlocal | |
set target=%~dp0\.paket | |
set paket=%target%\paket.exe | |
if not exist %paket% ( | |
rmdir /q /s %temp%\nuget\paket.bootstrapper 2> nul | |
nuget install -out %temp%\nuget -excludeversion paket.bootstrapper | |
xcopy %temp%\nuget\paket.bootstrapper\tools\* %target%\ |
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
#r ".fake/FakeLib.dll" | |
open Fake | |
let build = MSBuild "" "Build" [ ("Configuration", "Release"); ("Platform", "Any CPU") ] >> ignore | |
Target "Clear" (fun _ -> | |
!! "**/bin/" ++ "**/obj/" |> DeleteDirs | |
) |
OlderNewer