Skip to content

Instantly share code, notes, and snippets.

View JamesIgoe's full-sized avatar

James J. Igoe JamesIgoe

View GitHub Profile
var htmlEncode = function htmlEncode(s) {
var ntable = {
"&": "amp",
"<": "lt",
">": "gt",
"\"": "quot"
};
s = s.replace(/[&<>"]/g, function (ch) {
return "&" + ntable[ch] + ";";
});
var sleep = function sleep(ms) {
var date = Date.now();
var currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < ms);
};
var sleepPromise = function newSleep(ms)
{
@JamesIgoe
JamesIgoe / SingleInstance.vb
Created July 17, 2019 13:17
Guarantees single instance of app using mutex via threading
Imports System.Threading
Class Application
''' if app is already running, exiting the application
Private Shared _mutex As System.Threading.Mutex = Nothing
Protected Overrides Sub OnStartup(e As StartupEventArgs)
Const appName As String = "SWD_IPConfigTool"
Dim createdNew As Boolean
_mutex = New Mutex(True, appName, createdNew)
Imports System.ComponentModel
Imports System.Windows
Namespace Wpf
Public Class SharedDependencyObject
Inherits DependencyObject
Implements INotifyPropertyChanged
#Region "INotifyImplementation"
Dim dpiWidthProperty = GetType(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic Or BindingFlags.[Static])
Dim dpiHeightProperty = GetType(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic Or BindingFlags.[Static])
Dim dpiX = CInt(dpiWidthProperty.GetValue(Nothing, Nothing))
Dim dpiY = CInt(dpiHeightProperty.GetValue(Nothing, Nothing))
Width = SystemParameters.PrimaryScreenWidth * (dpiX / 96)
Height = SystemParameters.PrimaryScreenHeight * (dpiY / 96)
Imports System.ComponentModel.DataAnnotations
Public Class EnumHelpers
Public Class RequiredEnumAttribute
Inherits RequiredAttribute
Public Overrides Function IsValid(ByVal value As Object) As Boolean
If value Is Nothing Then Return False
If CInt(value) = 0 Then Return False
Imports log4net
Imports System.Management
Imports System.Linq
Namespace GhostImaging
Public Class WmiResult
Property Name As String
Property ProcessId As Int32
<!--
Office CDN and fallback
CSS and JS are copies of referenced CDN's
If the CDN's change, the fallbacks must change'
-->
<link rel="preconnect" href="https://appsforoffice.microsoft.com">
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
<script>
if (!window.OSF) {
document.write('<script src="../../Scripts/Office/1/office.js">\x3C/script>');
@JamesIgoe
JamesIgoe / SettingsManager.js
Last active November 19, 2018 15:05
Settings manager providing add delete and update for Outlook mailbox settings
var settingsManager = (function () {
"use strict";
var settingsManager = {};
var _settings;
settingsManager.initialize = function () {
//global for custom property
@JamesIgoe
JamesIgoe / screenMultipliers.js
Created November 12, 2018 20:09
Screen Multiplier Used in Office Add-in to Scale Dialogs
function screenMultipliers (scaledForHeight, scaledForWidth) {
var _currentScreenHeight = screen.height;
var _currentScreenWidth = screen.width;
//reverse values of screen is in portrait mode
if (_currentScreenHeight > _currentScreenWidth) {
var tempHolder = _currentScreenHeight;
_currentScreenHeight = _currentScreenWidth;
_currentScreenWidth = tempHolder;