Skip to content

Instantly share code, notes, and snippets.

View Kyle-Muir's full-sized avatar

Kyle Muir Kyle-Muir

  • Auckland, New Zealand
View GitHub Profile
@Kyle-Muir
Kyle-Muir / numbersOnlyDirective.ts
Created September 7, 2015 20:01
Creates an angular 1.x directive to remove non-numerical input from input fields
directives.directive('intergenNumbersOnly', () => {
'use strict';
return {
require: 'ngModel',
link: (scope, element, attrs, modelCtrl) => {
modelCtrl.$parsers.push(inputValue => {
if (inputValue === undefined) {
return '';
}
@Kyle-Muir
Kyle-Muir / PSakeNUnitExtensions.ps1
Last active September 21, 2015 23:40
Methods for copying C# projects into an Artefacts directory and then running NUnit Console runner across them
function Copy-FilesFromDirectories($exclude, $dest, $sourceDir, $config) {
$folders = Get-ChildItem -Path $sourceDir -Directory -Exclude $exclude | ? { $_.Name.EndsWith("Test") -or $_.Name.EndsWith("Tests") }
Foreach($folder in $folders) {
$binDirectory = "$($folder.FullName)\bin\$config"
if ((Test-Path $binDirectory)) {
Write-Host "Coyping folder $($folder.Name) to $dest" -ForegroundColor "Yellow"
$destinationProjectDirectory = "{0}\{1}" -f $dest,$folder.Name
New-Item $destinationProjectDirectory -ItemType Directory
Copy-Item -Path "$binDirectory\*" -Dest $destinationProjectDirectory
@Kyle-Muir
Kyle-Muir / PSakeOctopusExtensions.ps1
Created September 21, 2015 20:48
Used for creating Nuget packages and pushing to a remote Nuget server secured with an API key
function Build-Octopack ($thingToBuild, $configuration, $buildNumber, $nugetServer, $nugetApiKey, $visualStudioVersion = "12.0") {
set-alias msb "$env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
exec {
msb $thingToBuild /t:Build /p:Configuration=$configuration /p:AllowedReferenceRelatedFileExtensions=none /p:RunCodeAnalysis=Never /p:DebugSymbols=false /p:DebugType=None /m /nologo /p:VisualStudioVersion=$visualStudioVersion /p:RunOctopack=true "/p:OctoPackNuGetProperties=buildNumber=$buildNumber" /p:OctoPackPublishApiKey=$nugetApiKey /p:OctoPackPublishPackageToHttp=$nugetServer /p:OctoPackPackageVersion=$buildNumber
}
}
@Kyle-Muir
Kyle-Muir / dirtyFields.js
Last active November 4, 2015 21:04
Get all dirty fields in CRM 2011
var attributes = Xrm.Page.data.entity.attributes.get(), dirtyFields = [];
for (var i in attributes) {
var attribute = attributes[i];
if (attribute.getIsDirty()) {
dirtyFields.push(attribute.getName());
}
}
console.log(dirtyFields.join(', '));
@Kyle-Muir
Kyle-Muir / stringformat.js
Created November 5, 2015 22:06
String.format for js
if (!String.format) {
String.format = function(format) {
var args = Array.prototype.slice.call(arguments, 1);
return format.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
@Kyle-Muir
Kyle-Muir / synchronous.ts
Created February 29, 2016 22:39
AngularJS\Typescript - Synchronously execute promises
private synchronouslyExecuteCommands = (commands: Array<IProductModificationCommand>, product: Model.Product): ng.IPromise<any> => {
var commandPromises = this.$q.when();
_.each(commands, (command: IProductModificationCommand) => {
commandPromises = commandPromises.then(() => {
return command.execute(product);
});
});
return commandPromises;
}
@Kyle-Muir
Kyle-Muir / hon.md
Last active October 26, 2024 10:11
Heroes of Newerth - client commands to create games

Prerequisites - not covered here

To host games you need the server running locally and have forwarded port 11235 from your router. See instructions here: https://github.com/honserver/honserver

  • Press ctrl + f8 to open the console
  • Type connect 127.0.0.1. You should see the server output indicating you have connected
  • Type one of the following startgame commands to launch the game
  • Once the lobby has loaded have other people connect to your public IP address - e.g. connect [public IP address]. You can find your public IP from typing "what is my IP" into google.
  • It is best to restart the server between games. There are lots of niggly things that can happen such as:
  • Other people being considered the "host" even though they can't start games if they don't disconnect from the game in time.