Skip to content

Instantly share code, notes, and snippets.

View gjyoung1974's full-sized avatar
🎯
Focusing

Gordon Young gjyoung1974

🎯
Focusing
View GitHub Profile
@gjyoung1974
gjyoung1974 / f_Is_In_Array.js
Created October 23, 2016 15:21
A function test if an element is present in an Array.
// A function test if an element is present in an Array.
// Arrays.asList(Array).contains(string);
function f_Is_In_Array(elem, array, i) {
var len;
var indexOf = Array.prototype.indexOf;
if (array) {
if (indexOf) {
return indexOf.call(array, elem, i);
}
@gjyoung1974
gjyoung1974 / f_CreateZip.js
Created October 23, 2016 15:23
JScript create a zip file of a log directory in MSFT Windows
// create a zip file of the log directory..
function f_CreateZip() {
var shell = new ActiveXObject("Shell.Application");
var fs_obj = new ActiveXObject("Scripting.FileSystemObject");
var zipFilename = strLogPath.path + '\\' + sActiveConfig + '-LogFiles.zip';
// create an empty zipfile :-)
var zipFile = fs_obj.CreateTextFile(zipFilename, 1, 0);
zipFile.Write('PK' + String.fromCharCode(5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));
//call a REST Api
var http = require('http');
var sAPIKey = '939f36408065e19b83f5f8352573257e'
var options = {
hostname: 'api.openweathermap.org',
port: 80,
path: '/data/2.5/weather?lat=33.265014&lon=-111.839105&appid=' + sAPIKey,
method: 'POST',
headers: {
@gjyoung1974
gjyoung1974 / Call_Soap_API.js
Created October 24, 2016 02:36
Call a SOAP API from Javascript
//post to a SOAP API
var http = require('http');
var s_Pan = '378282246310005'; //get the unprotected PAN from the form
var s_DPFormat = 'CC'; //get the data protection Format
var s_Identity = 'user@domain.com'; //get the data protection Format
var s_AuthInfo = 'p3ssw3rd'; //get the data protection Format
//Marshal up a ProtectFormattedData SOAP Mesage:
var soapRequest =
@gjyoung1974
gjyoung1974 / json_post.js
Created October 28, 2016 15:51
JSON Post on Windows
//get a web resource: REST Api Post
var apiKey = '939f36408065e19b83f5f8352573257e';
function c3rl() {
try {
var xhr = new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
xhr.open("POST", 'http://api.openweathermap.org/data/2.5/weather?lat=33.265019&lon=-111.839103&appid=' + apiKey, false);
xhr.setRequestHeader('Content-Type', 'application/json'); xhr.setRequestHeader('Accept', 'application/json');
@gjyoung1974
gjyoung1974 / call_liebsoft_erpm_api.js
Last active March 8, 2017 23:53
Call a Lieberman ERPM API and return the auth token
/*
2016 Gordon Young, gjyoung1974@gmail.com
An example for calling the LiebSoft ERPM REST API
This Javascript calls the DoLogin2 method
and returns an API token for calling further methods
*/
var http = require('https'); //Call the API over HTTPS
//ignore Self-Signed SSL Certificate in test environment *** NEVER DO THIS IN PRODUCTION ***
@gjyoung1974
gjyoung1974 / read_reg_multi_sz_value.js
Last active December 15, 2016 08:23
read a MSFT Windows reg_multi_sz windows registry key/value and compare with expected setting
// Gordon Young 2016 gyoung@svb.com
// This script :
// 1. Reads the given Windows registry subkey value reg_multi_sz data type
// 2. Compares it to the provided expected setting
// if the configured setting is compliant the script returns 'pass',
// if the setting is non-compliant the script returns 'fail'
//The registry path we want to test
var hklm = 0x80000002, KeyName = "SYSTEM\\CurrentControlSet\\Control\\SecurePipeServers\\winreg\\AllowedExactPaths", ValueName = "Machine";
// Gordon Young 2016 gyoung@svb.com
// This script :
// 1. Reads the given Windows registry subkey value reg_multi_sz data type
// 2. Compares it to the provided expected setting
// if the configured setting is compliant the script returns 'pass',
// if the setting is non-compliant the script returns 'fail'
//The registry path we want to test
var hklm = 0x80000002, KeyName = "SYSTEM\\CurrentControlSet\\services\\Netlogon\\Parameters", ValueName = "RequireStrongKey";
/**
* Gordon Young gjyoung1974@gmail.com
* Windows Registry Write template
*/
// Instantiate a Windows Shell
var objShell = new ActiveXObject("WScript.Shell");
//disable DisableWindowsConsumerFeature
objShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Policies\\Microsoft\\Windows\\System\\AllowDomainPINLogon", 0, "REG_DWORD");
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormer Beta - template creation prototype application. This tool allows you to create an AWS CloudFormation template from the AWS resources in your AWS account. **Warning** This template creates a single EC2 instance in your account to run the application - you will be billed for the instance at normal AWS EC2 rates.",
"Parameters": {
"Username": {
"Description": "Username to log in to CloudFormer",
"Type": "String"
},
"Password": {
"Description": "Password to log in to CloudFormer",