Skip to content

Instantly share code, notes, and snippets.

View heiswayi's full-sized avatar
👽

Heiswayi Nrird heiswayi

👽
View GitHub Profile
@heiswayi
heiswayi / powershell.ps1
Created April 23, 2024 03:58
Execute PowerShell script with administrator privileges
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@heiswayi
heiswayi / utilities.cs
Last active April 3, 2024 14:29
C# utilities functions
// parse enum
public static T ParseEnum<T>(string value)
{
return (T)Enum.Parse(typeof(T), value, true);
}
// double to SI prefix
public string ToSI(double d, string format = null, bool spacing = true)
{
if (d == 0)
@heiswayi
heiswayi / MVVM.cs
Last active April 3, 2024 14:28
C# MVVM common classes in a single file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Windows;
using System.Windows.Input;
namespace HeiswayiNrird.MVVM
{
@heiswayi
heiswayi / Program.cs
Last active April 3, 2024 14:27
C# Multithreadings (Thread, Threadpool, Task & BackgroundWorker) vs single threading experiment. https://nrird.com/blog/multithreading-programming
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace MultithreadingVsSingleThreading
{
internal class Program
{
@heiswayi
heiswayi / JS LOIC.md
Last active April 3, 2024 14:25
JS LOIC
@heiswayi
heiswayi / singleton.cs
Created April 3, 2024 13:57
a simple singleton pattern class using .NET 4's Lazy type
using System;
namespace SingletonExample
{
public sealed class Singleton
{
private static volatile Singleton instance;
private static object syncRoot = new Object();
private Singleton() {}
@heiswayi
heiswayi / atari.css
Created March 26, 2024 07:10
Atari ST 8x16 System Font
@font-face {
font-family: 'Atari ST 8x16 System Font';
src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAABZkAA4AAAAAh4AAABYHAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGiYGYACHZggEEQgKgeo0gcl0C4QEAAE2AiQDhAoEIAWHVQeIYRtBdHWGHGwcAHD9CrMRFWwcgAjZ9lFRskn17P//mqDGEdXyU3TgNajIaElGuPDT6svhKnys5ed2p0TdtW3YRc7fw28sORJanphupo8OV1FIXjv8zlR1UbGQgYTex56+alsojGa6FZZWn439LHH111OGphmaPr1lpRg3j8j+x2hMPJNLBK1FVs/M7gOhInLAmoTB/U9UFLKPREKJwiBfAgTQ+X3TdK4ioXQ5pUopo5SbF96hUZpEJLIfsHCjlL5KG8DDjFL66Zy3S7BRmqtEbgfnlvOuZkAk41xvYgIVcybFdcv/3zglzrYjyOC4WrqQgslgv4AC/zfpxMLgIBAIHBQOHg4KgUJgUCwMhsMBDlz2aipVDpls+HbbeT4RZk5CJ8gxzzckc5IapnfcA8uDaXvvxaN7PrH6URTC5O6bj0IYLQL+XHuzP7/EspJSYCMqXJ1J0sxbSAlwfLo7HQAQmlwdKwDSZSE7FaZzwpxR7ozwZ98vS7HDnKStUYBnAE2oQkRmbNT3t3+dt2bPYXcUUqSu+u+/N3Ojmb24p1UKyCEVN4zcmLkMgWwkaGzADF81/cTZzhQchapf7SiHBKAJ1uzrmR92L0kmEJyJagfSWg8m+WFSE5EFlFvX0uVCvFJJmAxpSFZkcMVNueuPr33P5F+7w/Eddpjvm6mIiIiKiIqKTmNaDXEnufvq1uwNaUQIzYrSFGJhT4TA1/2qM+CDdxcdMXdbertgImZbrIiEaPizYLBzq0vzq442tR3Ft7B95UBuoujHUY5juBVnOnhq/+AVWf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@heiswayi
heiswayi / SimpleLogger.cs
Last active March 14, 2024 00:19
Simple C# logger utility class
/*
MIT License
Copyright (c) 2016 Heiswayi Nrird
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is