Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Gordon Young gjyoung1974

🎯
Focusing
View GitHub Profile
@gjyoung1974
gjyoung1974 / f_Is_In_Array.js
Created Oct 23, 2016
A function test if an element is present in an Array.
View f_Is_In_Array.js
// 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 Oct 23, 2016
JScript create a zip file of a log directory in MSFT Windows
View f_CreateZip.js
// 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));
View call_an_API.js
//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 Oct 24, 2016
Call a SOAP API from Javascript
View Call_Soap_API.js
//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 Oct 28, 2016
JSON Post on Windows
View json_post.js
//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');
View read_reg_dword_value.js
// 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";
@gjyoung1974
gjyoung1974 / read_reg_multi_sz_value.js
Last active Dec 15, 2016
read a MSFT Windows reg_multi_sz windows registry key/value and compare with expected setting
View read_reg_multi_sz_value.js
// 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";
View regwrite_template.js
/**
* 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");
View AWS_EC2_Linux_VPC_LoadBalancer.CFT
{
"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",
View mac_osx_certenroll.sh
#!/bin/bash
#====================================================================================
# Name : certenroll_mac.sh
# Author : Gordon Young, gjyoung1974@gmail.com
# Version : .01
# Copyright : 2016 Gordon Young
# Description : A script to enroll a Mac OSX 10.11 device for a machine certificate
# : via a Microsoft Certificate Services CA
# Reference : This script supports the requirements in