Skip to content

Instantly share code, notes, and snippets.

@jeremybeavon
jeremybeavon / ParallelTaskRunner.psm1
Last active April 16, 2025 09:57
Powershell parallel task runner using msbuild
function Invoke-ParallelPowershellFiles
{
[CmdletBinding()]
param(
[hashtable]$PowershellFiles,
[int]$NumberOfFilesToRunInParallel,
[string]$LogDirectory = ((Get-Location).Path)
)
if (!$NumberOfFilesToRunInParallel)
@jeremybeavon
jeremybeavon / StartProcessInfoCommand.cs
Last active September 16, 2016 02:32
Powershell cmdlet that prints outs output as it happens
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Management.Automation;
using System.Threading;
[Cmdlet(VerbsLifecycle.Invoke, "Process")]
public sealed class InvokeProcessCommand : Cmdlet
{
private bool isProcessFinishedOrTimedOut;
@jeremybeavon
jeremybeavon / pfx_to_keystore.bat
Created August 24, 2016 01:35
Convert pfx file into Java keystore
keytool -importkeystore -srckeystore C:\path_to_pfx.pfx -srcstoretype pkcs12 -destkeystore C:\path_to_keystore
@jeremybeavon
jeremybeavon / handycommands.ps1
Last active August 22, 2016 03:41
Handy powershell commands
# Test if type is loaded
if (-not ([System.Management.Automation.PSTypeName]'FixedIssues').Type)
{
# ...
}
# Convert array to string
$array | Out-String
# Access internet in powershell through proxy server
@jeremybeavon
jeremybeavon / subgit.txt
Created August 9, 2016 23:55
Run subgit with NTLM authentication
Run in command line:
set JAVA_OPTS=-Dsvnkit.http.methods=NTLM
@jeremybeavon
jeremybeavon / restore-teamcity.cmd
Last active May 5, 2016 03:34 — forked from grenade/restore-teamcity.cmd
Restore TeamCity from a backup file, preserving artifacts and plugins
:: set these variables to match TeamCity environment
SET TEAMCITY_DATA_PATH=D:\Config\TeamCity
SET TEAMCITY_DATA_BACKUP=D:\Temp\TeamCity
SET TEAMCITY_HOME=C:\TeamCity
SET TEAMCITY_BACKUP_FILE=D:\Config\TeamCity\TeamCity_Backup_xxx_xxx.zip
:: maintainDB expects these directories to be empty or absent.
move /Y %TEAMCITY_DATA_PATH%\config %TEAMCITY_DATA_BACKUP%\config
move /Y %TEAMCITY_DATA_PATH%\system %TEAMCITY_DATA_BACKUP%\system
Seq Read Seq Write 512K Read 512K Write 4K Read 4K Write 4K QD32 Read 4K QD32 Write Total:
Gizmo Drive 2.7.9, part of Gizmo Central 5626 6216 4281 4476 89.79 170.7 150.1 141 21150.59
Bond Disc 1.0.4.0 6984 7481 7530 8086 1352 946.7 968.3 324.2 33672.2
Gilisoft RAMDisk 4.7 7493 8069 7259 7608 1061 751 829.4 226.3 33296.7
Primo Ramdisk Standard Edition 5.6.0 (Direct IO) 6673 7135 6562 6865 929.2 706.5 143.4 121.3 29135.4
SuperSpeed RamDisk 11.6 6028 6409 4796 4908 552.3 440.3 465.8 163.4 23762.8
Dataram RAMDisk 4.0.0 6581 6904 5698 5749 218.1 175.4 203.1 110.1 25638.7
VSuite Ramdisk Free Edition 1.18.1531.1240 (SCSI) 6868 7453 5396 5713 153.7 147.2 149.5 142.5 26022.9
ImDisk 1.5.6 5345 5729 4220 4283 81.33 75.06 170 140.3 20043.69
Gavotte Ramdisk 1.1.0 7915 8342 7289 7471 504.7 430.3 436.8 183.2 32572
@jeremybeavon
jeremybeavon / RenameFiles.csx
Created February 13, 2016 20:15
C# Interactive function for renaming files
public static void RenameFiles(string directory, string fileMatch, string replacement)
{
foreach (string file in Directory.GetFiles(directory))
{
File.Move(file, Path.Combine(Path.GetDirectoryName(file), System.Text.RegularExpressions.Regex.Replace(Path.GetFileName(file), fileMatch, replacement)));
}
}
@jeremybeavon
jeremybeavon / msbuild.xml
Last active August 11, 2016 05:24
MSBuild Undocumented Metadata
<!-- Belongs under ProjectReference. Means the assembly is not referenced in the output assembly. -->
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<!-- Hard links:
http://atombrenner.blogspot.com.au/2011/11/speed-up-your-build-with.html
https://gist.github.com/jstangroome/734259
-->
<CreateHardLinksForAdditionalFilesIfPossible>true</CreateHardLinksForAdditionalFilesIfPossible>
<CreateHardLinksForCopyAdditionalFilesIfPossible>true</CreateHardLinksForCopyAdditionalFilesIfPossible>
<CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>true</CreateHardLinksForCopyFilesToOutputDirectoryIfPossible>
@jeremybeavon
jeremybeavon / ProxyBuilder.cs
Created December 23, 2015 01:38
Generate a Castle proxy for every type in a assembly and save the proxy assembly
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Castle.DynamicProxy;
private static void BuildProxyAssembly(string assemblyPath)
{
string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath) + ".Proxies";
string modulePath = Path.Combine(Path.GetDirectoryName(assemblyPath), assemblyName + ".dll");