Skip to content

Instantly share code, notes, and snippets.

View johngrant's full-sized avatar
🛹

John Grant johngrant

🛹
View GitHub Profile
@johngrant
johngrant / reset-wmi.bat
Last active October 6, 2022 18:40
Reset WMI files. Useful script to get Docker Desktop running again.
REM Turn winmgmt service Startup type to Disabled
sc config winmgmt start = disabled
REM Stop winmgmt service
net stop winmgmt /y
REM Register / Reregister Service DLLs
regsvr32 /s %systemroot%\system32\scecli.dll
regsvr32 /s %systemroot%\system32\userenv.dll
@johngrant
johngrant / total-black-jack-hand.ipynb
Created August 29, 2021 20:40
Total Black Jack Hand.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johngrant
johngrant / flattenNested.js
Created April 11, 2017 17:31
This snippet of javascript code will flatten an array with nested arrays of any arbitrary depth.
var arr = [1,2,3,[2,[9,9],5],[4,5,5]];
function flatten(input) {
var output = [];
for (var i = 0; i < input.length; i++) {
output = Array.isArray(input[i])
? [...output, ...flatten(input[i])]
: [...output, ...input[i]];
}
return output;
@johngrant
johngrant / Interrogating script bundle
Created March 24, 2015 18:27
Prototype code used to enumerate the files in a bundle at runtime then serialize to JS array the bundle or the contents based on the DEBUG symbols
@{
var includes = "[]";
var bundleName = "~/bundles/agent-profile";
if (!BundleTable.EnableOptimizations)
{
var resolver = new BundleResolver();
var url = resolver.GetBundleContents(bundleName).Select(s => string.Format("'{0}'", Url.Content(s)));
includes = "[" + string.Join(",", url) + "]";
}
else
@johngrant
johngrant / hybrid razor code and script loader code
Created March 24, 2015 18:23
Loading minified and compressed bundles of 3rd party code then my own code.
@section scriptloader {
$script(['https://code.jquery.com/ui/1.9.2/jquery-ui.min.js'], 'jquery-ui');
$script.ready('jquery-ui', function() {
$script([
'@Url.Content("~/bundles/ko-js")',
'@Url.Content("~/bundles/jqueryval")',
'@Url.Content("~/bundles/jquery-cropbox")',
'@Url.Content("~/bundles/jquery-file-upload")',