Skip to content

Instantly share code, notes, and snippets.

@alex6dj
alex6dj / NativeMembers.cs
Created November 28, 2017 15:13 — forked from mlaily/NativeMembers.cs
Find which process have a file opened using the Restart Manager API
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable InconsistentNaming
namespace RestartManager
@alex6dj
alex6dj / ProcessExtensions.cs
Created January 23, 2018 17:25
Extension method to show the childs and parent of a process
public static class ProcessExtensions
{
/// <summary>
/// Get the child processes for a given process
/// </summary>
/// <param name="process"></param>
/// <returns></returns>
public static List<Process> GetChildProcesses(this Process process)
{
var results = new List<Process>();
@alex6dj
alex6dj / ShowSelectedInExplorer.cs
Created January 23, 2018 17:28
Open windows explorer with with some specific files or folder selected
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
static class ShowSelectedInExplorer
{
[Flags]
/// From https://www.codeproject.com/Tips/1231324/How-to-Get-a-Files-Encoding-with-Csharp
/// &lt;summary
/// Get File's Encoding
/// &lt;/summary>
/// &lt;param name="filename">The path to the file
private static Encoding GetEncoding(string filename)
{
// This is a direct quote from MSDN:
// The CurrentEncoding value can be different after the first
using System.Runtime.InteropServices;
public class FileOperationAPIWrapper
{
/// <summary>
/// Possible flags for the SHFileOperation method.
/// </summary>
[Flags]
public enum FileOperationFlags : ushort
{
@alex6dj
alex6dj / simpleAwaitableQueue
Created June 25, 2018 16:34 — forked from Acapla/simpleAwaitableQueue
simple awaitable queue
public class AwaitableQueue<T>
{
private readonly ConcurrentQueue<T> _queue = new ConcurrentQueue<T>();
private long _count = 0;
private readonly ConcurrentQueue<TaskCompletionSource<T>> _pending = new ConcurrentQueue<TaskCompletionSource<T>>();
/// <summary>
/// Enqueue the specified item. Blocking operation.
/// </summary>
/// <param name="item">Item.</param>
@alex6dj
alex6dj / App.xaml
Created July 26, 2019 15:13 — forked from dbuksbaum/App.xaml
Bootstrapping Caliburn.Micro with Autofac
<Application x:Class="HelloAutofac.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:HelloAutofac">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:MyBootStrapper x:Key="bootstrapper" />
</ResourceDictionary>
@alex6dj
alex6dj / GetProcessList.cs
Created April 11, 2021 16:51 — forked from mubix/GetProcessList.cs
Get a process listing with the command line arguments
using System;
using System.Linq;
using System.Diagnostics;
using System.Management;
namespace GetProcessList
{
public static class Program
{
static void Main(string[] args)
@alex6dj
alex6dj / AlignableWrapPanel.cs
Created May 1, 2021 22:46 — forked from gmanny/AlignableWrapPanel.cs
WrapPanel that respects HorizontalAlignment of its children, and fallbacks on the HorizontalContentAlignment property, when child doesn't have the alignment. Base upon this answer: http://stackoverflow.com/a/7747002
public class AlignableWrapPanel : Panel
{
public HorizontalAlignment HorizontalContentAlignment
{
get { return (HorizontalAlignment)GetValue(HorizontalContentAlignmentProperty); }
set { SetValue(HorizontalContentAlignmentProperty, value); }
}
public static readonly DependencyProperty HorizontalContentAlignmentProperty =
DependencyProperty.Register("HorizontalContentAlignment", typeof(HorizontalAlignment), typeof(AlignableWrapPanel), new FrameworkPropertyMetadata(HorizontalAlignment.Left, FrameworkPropertyMetadataOptions.AffectsArrange));
@alex6dj
alex6dj / Office2016_TelemetrySettings.ps1
Created December 6, 2021 02:41
Disable Office Telemetry Agent and other data collection and Block Macros in files downloaded from the Internet.
#requires -Version 1.0
<#
.SYNOPSIS
Disable Office Telemetry Agent and other data collection
.DESCRIPTION
Disable Office Telemetry Agent and other data collection and Block Macros in files downloaded from the Internet.
Makes Office less spying on us...