Skip to content

Instantly share code, notes, and snippets.

View Fireforge's full-sized avatar

David Salter Fireforge

View GitHub Profile
@Fireforge
Fireforge / C# Marshal Extensions
Created July 7, 2016 20:58
Useful extensions to the Marshal utilities in C#
public static class MarshalExt
{
// Only needed for .NET 4.5 and earlier
public static T PtrToStructure<T>(IntPtr ptr)
{
return (T)Marshal.PtrToStructure(ptr, typeof(T));
}
public static T[] PtrToStructureArray<T>(IntPtr ptr, int count)
{
@Fireforge
Fireforge / push.ps1
Last active December 16, 2016 22:17
Nuget push script, more advanced
#
# push.ps1
#
# Push all Nuget packages to Artifactory if the package version has been updated. Checks to make sure that there was not a
# previous push of the same version using Git tags.
##### USER PARAMETERS
param (
[string[]]$csproj_list = $(gci *.csproj),
[string]$source = "artifactory-vt",
@Fireforge
Fireforge / Sequential.cs
Created December 13, 2016 23:49
A Sequential.Invoke function to use as a baseline for Parallel.Invoke performance test
public static class Sequential
{
public static void Invoke(params System.Action[] actions)
{
foreach (var a in actions)
a.Invoke();
}
}
@Fireforge
Fireforge / backup.ps1
Last active January 27, 2026 10:58
Powershell backup script using Robocopy
#
# ROBOCOPY Script
#
# This script calls robocopy over a few folders, and then emails you when they're done
Param(
[Parameter(Mandatory=$true)]
[string]$basesrc, #"G:\",
[Parameter(Mandatory=$true)]
[string]$basedst, #
@Fireforge
Fireforge / runtask.ps1
Last active October 17, 2023 10:55
powershell task runner
# A simple task runner implemented in Powershell
Param(
[String]$TaskName, # The name of the task to run
[parameter(ValueFromRemainingArguments=$true)][String[]]$TaskArgs # The list of repos to run the task on
)
# Define the tasks
$tasks = @{}
@Fireforge
Fireforge / get_installed_programs.ps1
Created October 29, 2017 14:01
Script to get list of installed programs seen in Control Panel
# Script adapted from the answers in this thread:
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/1fd035f3-a170-4721-a6b5-d4809ca2e39d/getting-list-of-installed-software-that-matches-control-panels-addremove-programs-or-programs?forum=winserverpowershell
# Formatting taken from:
# https://www.howtogeek.com/165293/how-to-get-a-list-of-software-installed-on-your-pc-with-a-single-command/
if (!([Diagnostics.Process]::GetCurrentProcess().Path -match '\\syswow64\\')) {
$unistallPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$unistallWow6432Path = "\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
@(
@Fireforge
Fireforge / DeferredSynchronizeInvoke.cs
Last active March 2, 2018 17:43 — forked from JakubNei/DeferredSynchronizeInvoke.cs
Implementation of ISynchronizeInvoke for Unity3D game engine. Can be used to invoke anything on main Unity thread. ISynchronizeInvoke is used extensively in .NET forms, it's is elegant and quite useful in Unity as well. I implemented it so i can use it with System.IO.FileSystemWatcher.SynchronizingObject.
/*
Implementation of ISynchronizeInvoke for Unity3D game engine.
Can be used to invoke anything on main Unity thread.
ISynchronizeInvoke is used extensively in .NET forms, it's is elegant and quite useful in Unity as well.
I implemented it so i can use it with System.IO.FileSystemWatcher.SynchronizingObject.
help from: http://www.codeproject.com/Articles/12082/A-DelegateQueue-Class
example usage: https://gist.github.com/aeroson/90bf21be3fdc4829e631
version: aeroson 2017-07-13 (author yyyy-MM-dd)
@Fireforge
Fireforge / serve-files.sh
Created December 1, 2019 07:20
Quick serve current directory over HTTP with Apaxy and Docker
docker run -d -v `pwd`:/data/webroot -p 8080:80 --name apaxy-home xetusoss/apaxy
@Fireforge
Fireforge / create_resources.cmake
Created December 22, 2019 03:10
C/C++ Embedded Resources using CMake: This is a short CMake function that copies a folder of data files into a single header file that can be used in an application as embedded resources. This is an easy, cross-platform way to include a bunch of text data into an executable.
# Creates C resources file from files in given directory
function(create_resources dir output)
# Create empty output file
file(WRITE ${output} "")
# Collect input files
file(GLOB bins ${dir}/*)
# Iterate through input files
foreach(bin ${bins})
# Get short filename
string(REGEX MATCH "([^/]+)$" filename ${bin})
@Fireforge
Fireforge / git_cheetsheet.sh
Created December 22, 2019 03:13
Git Cheatsheet
# Update all the submodules to the latest version:
git submodule foreach git pull origin master
# Prune a git repo of all folders EXCEPT the listed ones
git filter-branch --index-filter 'git rm --cached -qr --ignore-unmatch -- . && git reset -q $GIT_COMMIT -- apps/AAA libs/XXX' --prune-empty -- --all
# Remove all empty commits, but keep the commit info (author, date, etc.)
git filter-branch --prune-empty --parent-filter \
'sed "s/-p //g" | xargs -r git show-branch --independent | sed "s/\</-p /g"'
#Git command to multiple dirs:
git add .; git commit -m "Removed unecessary dependencies and moved to snapshots"; git push origin master