Skip to content

Instantly share code, notes, and snippets.

View mark05e's full-sized avatar

mark05E mark05e

View GitHub Profile
// https://github.com/choraria/gas-url-shortener/blob/master/apps-script/Helper.gs
function removeEmptyColumns(sheetName) {
var activeSheet = ss.getSheetByName(sheetName)
var maxColumns = activeSheet.getMaxColumns();
var lastColumn = activeSheet.getLastColumn();
if (maxColumns-lastColumn != 0){
activeSheet.deleteColumns(lastColumn+1, maxColumns-lastColumn);
}
}
@mark05e
mark05e / jsconfig.json
Created April 6, 2022 20:49
This file tells VS Code to treat all *.js files in the workspace as part of the same project. However it will not enable intellisense between javascript in <script> blocks and regular js files. https://stackoverflow.com/questions/49184790/how-to-using-vscode-javascripts-go-to-definition-cross-files
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
@mark05e
mark05e / launchPowerShellScript.cmd
Created March 8, 2022 22:58
Launch Powershell Script with same name in the same path
::====================================================================
:: Powershell script launcher
:: ref: https://stackoverflow.com/questions/10137146/is-there-a-way-to-make-a-powershell-script-work-by-double-clicking-a-ps1-file
::=====================================================================
:MAIN
@echo off
for /f "tokens=*" %%p in ("%~p0") do set SCRIPT_PATH=%%p
pushd "%SCRIPT_PATH%"
powershell.exe -sta -c "& {.\%~n0.ps1 %*}"
@mark05e
mark05e / quickServerAudit.ps1
Created February 15, 2022 17:41
A quick audit script to run on multiple machines
$ComputersToWorkOn = @("Server11","Server12","Server13","Server14","Server15")
$report = @()
foreach ($computer in $ComputersToWorkOn) {
Write-Host "Working on $computer ..."
$obj = Invoke-Command -ComputerName $computer -ScriptBlock {
# Count services with the name 'Integration Client Service'
$InstalledServices = (Get-Service -DisplayName '*Integration Client Service*').Count
# Count folders on the E drive location -- hope all the servers have ICs installed here
$InstallationFoldersOnDriveE = (Get-ChildItem -Path 'E:\SoftwareInstallation\' -Directory).Count
@mark05e
mark05e / decodeHtmlEntities.js
Created January 31, 2022 16:05
Decode HTML Entities
var decodeEntities = (function() {
// this prevents any overhead from creating the object each time
var element = document.createElement('div');
function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
// strip script/html tags
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, '');
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, '');
element.innerHTML = str;
str = element.textContent;
@mark05e
mark05e / parseXml.js
Last active January 27, 2022 17:49
Parse xml string to xml
// https://stackoverflow.com/questions/11563554/how-do-i-detect-xml-parsing-errors-when-using-javascripts-domparser-in-a-cross
function parseXml(xmlString) {
var parser = new DOMParser();
// cleanup Xml
xmlString = cleanupXml(xmlString);
// attempt to parse the passed-in xml
var dom = parser.parseFromString(xmlString, 'application/xml');
if(isParseError(dom)) {
@mark05e
mark05e / hnl.mobileConsole.js
Created January 19, 2022 15:45 — forked from c-kick/hnl.mobileConsole.js
hnl.mobileConsole.js - extends JavaScript's console to display a visual console inside the webpage. Very usefull for debugging JS on mobile devices with no real console. Info and demo: http://www.hnldesign.nl/work/code/mobileconsole-javascript-console-for-mobile-devices/
/*!
* hnl.mobileConsole - javascript mobile console - v1.3.8 - 04/01/2021
* Adds html console to webpage. Especially useful for debugging JS on mobile devices.
* Supports 'log', 'trace', 'info', 'warn', 'error', 'group', 'groupEnd', 'table', 'assert', 'clear'
* Inspired by code by Jakub Fiala (https://gist.github.com/jakubfiala/8fe3461ab6508f46003d)
* Licensed under the MIT license
*
* Changelog:
* 1.3.8
* - fixed bug when logging numbers
@mark05e
mark05e / utcToLocalDateTime.js
Created January 12, 2022 21:42
Convert a UTC datetime to browser local datetime.
var utcDatetime = "01/12/2022 07:57 PM"
var options = {day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute:'2-digit' };
var myDateTime = new Date(utcDatetime + ' UTC').toLocaleString("en-US",options)
// myDateTime : 01/12/22, 02:57 PM
@mark05e
mark05e / currentTimezoneText.js
Created January 12, 2022 21:37
Get the current 3 digit timezone name
// https://stackoverflow.com/a/15304657
// https://stackoverflow.com/questions/1091372/getting-the-clients-time-zone-and-offset-in-javascript
// With Options
var options = {timeZoneName:'short'};
new Date().toLocaleString('en-US', options).toString().match(/([A-Z]){3}/)[0]
// Without Options
new Date().toString().match(/\(([A-Za-z\s].*)\)/)[1]