Skip to content

Instantly share code, notes, and snippets.

View heiswayi's full-sized avatar
👽

Heiswayi Nrird heiswayi

👽
View GitHub Profile
using System;
// it's required for reading/writing into the registry:
using Microsoft.Win32;
// and for the MessageBox function:
using System.Windows.Forms;
namespace Utility.ModifyRegistry
{
public class ModifyRegistry
{
@heiswayi
heiswayi / progress.ps1
Last active February 8, 2017 16:23
Update progress in PowerShell
$Num = 5
$Jobs = @()
ForEach ($Job in (1..$Num))
{ $Jobs += Start-Job -ScriptBlock {
$Count = 1
Do {
Write-Progress -Id 2 -Activity "Background Job" -Status $Count -PercentComplete 1
$Count ++
Start-Sleep -Seconds 4
@heiswayi
heiswayi / shell.asp
Created February 7, 2017 16:53
Shell script for ASP.NET
<%@ Language = VBScript
CodePage = 1252 %>
<%
Option Explicit
'/* --- Options --- */
Server.ScriptTimeout = 360 ' Seconds
Session.Timeout = 5 ' Minutes
Response.Expires = -1 ' Minutes (expires immediately)
Private sMD5Hash ' MD5("HitU")
@heiswayi
heiswayi / hnexplorer.php
Created February 7, 2017 15:51
Backup of HNExplorer source code -- a PHP file manager.
<?php
//
// Initialising variables. Don't change these.
//
$_CONFIG = array();
$_ERROR = "";
$_START_TIME = microtime(TRUE);
@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 / SystemErrorCode.csv
Last active July 26, 2023 22:46
Searchable System Error Codes: 1 to 15841
Error Code Description
Error Code 1 Incorrect function. [ERROR_INVALID_FUNCTION (0x1)]
Error Code 2 The system cannot find the file specified. [ERROR_FILE_NOT_FOUND (0x2)]
Error Code 3 The system cannot find the path specified. [ERROR_PATH_NOT_FOUND (0x3)]
Error Code 4 The system cannot open the file. [ERROR_TOO_MANY_OPEN_FILES (0x4)]
Error Code 5 Access is denied. [ERROR_ACCESS_DENIED (0x5)]
Error Code 6 The handle is invalid. [ERROR_INVALID_HANDLE (0x6)]
Error Code 7 The storage control blocks were destroyed. [ERROR_ARENA_TRASHED (0x7)]
Error Code 8 Not enough storage is available to process this command. [ERROR_NOT_ENOUGH_MEMORY (0x8)]
Error Code 9 The storage control block address is invalid. [ERROR_INVALID_BLOCK (0x9)]
@heiswayi
heiswayi / App.xaml.cs
Last active January 13, 2017 02:13
C# SmartDispatcher class by Jeff Wilcox for WPF MVVM
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
SmartDispatcher.Initialize(Deployment.Current.Dispatcher);
InitializeComponent();
}
@heiswayi
heiswayi / IniFile.cs
Last active March 25, 2023 18:42
C# utilities - .INI file helper class
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
namespace Utilities
{
public class IniFile
{
private string Path;
@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
@heiswayi
heiswayi / SubstringExtensions.cs
Created December 25, 2016 15:40
C# Utilities - Substring extensions
namespace Helpers
{
internal static class SubstringExtensions
{
/// <summary>
/// Get string value between [first] a and [last] b.
/// </summary>
public static string Between(this string value, string a, string b)
{
int posA = value.IndexOf(a);