Skip to content

Instantly share code, notes, and snippets.

View michel-pi's full-sized avatar

Michel michel-pi

View GitHub Profile
@michel-pi
michel-pi / WindowExtensions.cs
Last active May 29, 2019 18:10
Provides extension methods for WPF windows such as Invoke, enabling drag move, control sliders through the mouse wheel and enumerating controls.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Media3D;
namespace System.Windows.Extensions
{
@michel-pi
michel-pi / HashProvider.cs
Created May 29, 2019 18:01
Provides static methods to use hash algorithms in a generic way.
using System;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
namespace System.Security.Cryptography.Provider
{
/// <summary>
/// Provides static methods to use hash algorithms in a generic way.
/// </summary>
function DiscordWidgetData() {
this.load = async function (guildId) {
return new Promise(function (resolve, reject) {
fetch("https://discordapp.com/api/v6/guilds/" + guildId + "/widget.json", {
method: "GET",
mode: "cors",
cache: "reload",
redirect: "follow"
}).then(response => {
if (!response.ok) {
@michel-pi
michel-pi / TimerService.cs
Created March 6, 2020 01:10
Windows timer resolution and high accuracy Sleep
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace Testing
{
internal static class StopwatchExtensions
{
public static long GetElapsedNanoseconds(this Stopwatch watch)
@michel-pi
michel-pi / EnvironmentEx.cs
Created April 24, 2020 05:26
Retrieves all Environment Variables
using System;
using System.Collections.Generic;
using System.Threading;
using System.Runtime.InteropServices;
namespace System
{
public static class EnvironmentEx
{
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
@michel-pi
michel-pi / DateTimeFormat.php
Created October 12, 2020 22:34
Formats DateTime for usage in JSON and MySQL Databases
<?php
namespace MichelPi\Utils;
use DateTime;
class DateTimeFormat
{
private static $_jsonFormatString = 'Y-m-d\\TH:i:s.v\\Z';
private static $_mysqlFormatString = 'Y-m-d H:i:s';
||consent.google.*
||consent.youtube.*
||www.gstatic.*/youtube/img/promos/growth/dmod_si_horizontal_ver1_240x400.png^
||policies.google.*
google.*##div#cnsw:remove()
google.*##div#swml:remove()
google.*##div#reviewDialog:remove()
google.*##div#lb:remove()
@michel-pi
michel-pi / wmi-events.txt
Created January 2, 2021 15:46
Windows 10 v2004 WMI Event Class List
__Event
__ExtrinsicEvent
Win32_DeviceChangeEvent
Win32_SystemConfigurationChangeEvent
Win32_VolumeChangeEvent
MSFT_WMI_GenericNonCOMEvent
MSFT_NCProvEvent
MSFT_NCProvCancelQuery
MSFT_NCProvClientConnected
MSFT_NCProvNewQuery
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
namespace ProcessMemoryTest.Native
{
[SuppressUnmanagedCodeSecurity]
public static unsafe class Kernel32
{
@michel-pi
michel-pi / cloudflare-dns.cmd
Created January 11, 2021 23:16
set cloudflare dns server with console
@echo off
netsh interface ipv4 set dnsservers name="Ethernet" validate=no static 1.1.1.1 primary > nul
netsh interface ipv4 add dnsservers name="Ethernet" validate=no 1.0.0.1 index=2 > nul
netsh interface ipv6 set dnsservers name="Ethernet" validate=no static 2606:4700:4700::1111 primary > nul
netsh interface ipv6 add dnsservers name="Ethernet" validate=no 2606:4700:4700::1001 index=2 > nul
ipconfig /flushdns > nul