Skip to content

Instantly share code, notes, and snippets.

View Fireforge's full-sized avatar

David Salter Fireforge

View GitHub Profile
@Fireforge
Fireforge / config.ssdf
Created March 29, 2014 20:11
config.ssdf for debug shortcuts for IEP
shortcuts2 = dict:
edit__comment = 'Ctrl+R,'
edit__copy = 'Ctrl+C,Ctrl+Insert'
edit__cut = 'Ctrl+X,Shift+Delete'
edit__dedent = 'Shift+Tab,'
edit__delete_line = 'Ctrl+D,'
edit__find_next = 'Ctrl+G,F3'
edit__find_or_replace = 'Ctrl+F,'
edit__find_previous = 'Ctrl+Shift+G,Shift+F3'
@Fireforge
Fireforge / acronator
Created April 12, 2014 02:01
Acronator Sudocode
def acronator(acronym, list_of_keywords):
pass
import argparse
parser = argparse.ArgumentParser(description='De-Generate Acronym')
parser.add_argument('acronym', metavar='ACR',
help='the acronym')
parser.add_argument('keywords', metavar='KEY', nargs='+',
help='some keywords')
args = parser.parse_args()
@Fireforge
Fireforge / INotifyPropertyChanged Boilerplate
Last active August 29, 2015 14:11
Intelligent boilerplate for INotifyPropertyChanged, mostly taken from http://stackoverflow.com/a/1316417
#region INotifyPropertyChanged Boilerplate
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propname)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propname));
}
@Fireforge
Fireforge / INotifyPropertyChanged Boilerplate
Last active September 6, 2017 15:48
Caliburn.Micro compliant PropChangedBase - https://dotnetfiddle.net/Fsiq61
// C# 6.0 and up:
public class PropertyChangedBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void NotifyOfPropertyChange(string name)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
@Fireforge
Fireforge / C# Resource Accessing Static Functions
Last active December 14, 2016 15:35
A class of helpful static functions for accessing files in the Resources folder in various ways
public class AssemblyResources
{
public static bool ResourceExists(string resourceName)
{
return Assembly.GetExecutingAssembly().GetManifestResourceNames().Contains(GetResourcePath(resourceName));
}
public static string GetResourcePath(string resourceName) => $"{Assembly.GetExecutingAssembly().GetName().Name}.Resources.{resourceName}";
public static Stream GetStream(string resourceName)
@Fireforge
Fireforge / push_replace.ps1
Last active October 25, 2019 18:59
Nuget Package push Powershell script with debug/release specific files
#
# push_replace.ps1
#
# This script is designed to produce customized release and debug nupkgs from a Visual Studio C# project. This is especially useful
# for nupkgs that include native DLLs that are different depending upon debug or release mode.
#
# How to use:
# In your .nuspec file in the <files> section, add the following line:
# <file src="$filelist$" target="lib\native" />
# That line is set to go to lib\native because this script was made for handling native DLLs, but that target can be anything.
@Fireforge
Fireforge / push.ps1
Last active January 27, 2016 21:48
Nuget Package push Powershell script
#
# push.ps1
#
# A simple script to package and push a Nuget package from a Visual Studio C# project.
# `nuget.exe` must be on the path or otherwise available to the script (Package Manager Console)
Set-Location -Path $PSScriptRoot
# project parameters
$projname = "MyProject"
@Fireforge
Fireforge / IEnumerableContinuous.cs
Created March 3, 2016 15:58
Simple IEnumerable functions to find continuous sections
/// <summary>
/// Finds sections of the given IEnumerable<bool> that are continuously true
/// </summary>
/// <param name="src">Any IEnumerable<bool></param>
/// <returns>An IEnumerable<Tuple<int, int> where each pair represents the start and end index that is continuously true</returns>
private IEnumerable<Tuple<int, int>> FindContinuousTrue(IEnumerable<bool> src)
{
var res = new Collection<Tuple<int, int>>();
var srclist = src.ToList();
@Fireforge
Fireforge / HTTPListener AddAddress
Created April 12, 2016 21:07
Using netsh to add the URL used by HTTPListener
/// <summary>
/// Reserve the URL we'll be using for this session for a given user on a given domain
/// Source: http://stackoverflow.com/questions/14962334/httplistenerexception-access-denied-for-non-admins on Oct 09, 2014
/// </summary>
/// <param name="address">URL (something like http://<ip_address>:<port>/)</param>
/// <param name="domain">Domain name (the current one is from Environment.UserDomainName)</param>
/// <param name="user">User name (the current one is from Environment.UserName)</param>
public static void AddAddress(this HttpListener listener, string address, string domain, string user)
{
string args = string.Format(@"http add urlacl url={0}", address) + " user=\"" + domain + "\\" + user + "\"";