Skip to content

Instantly share code, notes, and snippets.

View Fireforge's full-sized avatar

David Salter Fireforge

View GitHub Profile
@Fireforge
Fireforge / flask_checks.py
Created December 22, 2019 03:21
Liveness and readiness checks for Flask running in a container. Useful when running flask in a Kubernetes environment.
@app.route('/healthz/live', methods=['GET'])
def healthz_live():
return 'ok\n'
@app.route('/healthz/ready', methods=['GET'])
def healthz_ready():
if ready:
return 'ok\n'
else:
return 'not ready\n', 503
@Fireforge
Fireforge / filename-find-replace.ps1
Created December 22, 2019 03:17
Powershell batch find-replace in file names
# Replace the sub-string "foo" with "bar" in a bunch of files with different file names:
ls | %{ $new = $_ -replace "foo", "bar"; echo $new; mv $_ $new }
@Fireforge
Fireforge / robocopy.cmd
Created December 22, 2019 03:15
VisualStudio Robocopy post-build: A post-build command for running robocopy to copy over native dependencies
;; Silent: /NP /NFL /NDL /NJH /NJS /NC /NS
;; Copy native build into Debug and Release:
if $(ConfigurationName) == Debug ((robocopy $(SolutionDir)..\..\build\native $(TargetDir) *.dll *.pdb /NP ) ^& IF %ERRORLEVEL% LEQ 1 exit 0)
if $(ConfigurationName) == Release ((robocopy $(SolutionDir)..\..\build\native $(TargetDir) *.dll /XF *_d.dll /NP ) ^& IF %ERRORLEVEL% LEQ 1 exit 0)
@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
@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 / 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 / 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 / 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 / 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 / backup.ps1
Last active April 2, 2024 15:34
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, #