Skip to content

Instantly share code, notes, and snippets.

View Satak's full-sized avatar

Sami Koskivaara Satak

View GitHub Profile
@Satak
Satak / clientScript.js
Last active July 7, 2020 09:21
Password generator function
function onLoad() {
var generatePassword = new GlideAjax('x_fstfs_fj_cmp.TfSCMPClientUtils');
function setPassword (password) {
g_form.setValue('AWS_Windows_UserPassword', password);
}
generatePassword.addParam('sysparm_name', 'generateRandomPassword');
generatePassword.getXMLAnswer(setPassword);
}
@Satak
Satak / vmware.ps1
Last active June 24, 2020 06:46
VMware REST API functions
$username = 'username'
$password = 'password'
$vcenter = 'localhost'
$authURL = "https://$vcenter/rest/com/vmware/cis/session"
$apiBaseURL = "https://$vcenter/rest/vcenter"
$vmAPIURL = $apiBaseURL + '/vm'
$ct = 'application/json'
$sec = ConvertTo-SecureString -AsPlainText $Password -Force
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $sec
@Satak
Satak / app.py
Last active June 17, 2022 17:45
Python xml
import xml.etree.ElementTree as ET
def indent(elem, level=0):
i = "\n" + level*" "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
elem.tail = i
@Satak
Satak / eslint_prettier_airbnb.md
Last active April 20, 2020 20:12
ESLint, Prettier & Airbnb Setup

ServiceNow Extension for VSCode

Install ServiceNow® Extension for VS Code

Open VS Code and install this extension and follow the instructions how to authenticate and pull application from ServiceNow

Set Custom file types

Policy Rule Action Script (sn_cmp_pol_action_script) & Resource Pool Filter (sn_cmp_rp_filter) are custom file types which you need to explicitly import in your application. This can be done by adding the file config to the application & configuring the file to enable import and sync.

@Satak
Satak / GitHub.md
Last active January 22, 2020 09:15
@Satak
Satak / tf.log
Created January 20, 2020 12:48
Terraform vcsim log
2020/01/20 14:48:01 [INFO] Terraform version: 0.12.18
2020/01/20 14:48:01 [INFO] Go runtime version: go1.12.13
2020/01/20 14:48:01 [INFO] CLI args: []string{"C:\\Program Files\\Terraform\\terraform.exe", "apply", "-auto-approve"}
2020/01/20 14:48:01 [DEBUG] Attempting to open CLI config file: C:\Users\a.fisamkosk3\AppData\Roaming\terraform.rc
2020/01/20 14:48:01 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/01/20 14:48:01 [INFO] CLI command args: []string{"apply", "-auto-approve"}
2020/01/20 14:48:01 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2020/01/20 14:48:01 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2020/01/20 14:48:01 [DEBUG] New state was assigned lineage "6d8caa9e-e384-7950-d2f5-228f87ae78f4"
2020/01/20 14:48:01 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
@Satak
Satak / main.tf
Last active January 20, 2020 12:32
provider "vsphere" {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = var.vsphere_server
allow_unverified_ssl = true
}
data "vsphere_datacenter" "dc" {
name = var.datacenter
}
@Satak
Satak / cosmos_db.py
Created December 31, 2019 11:48
Example how to use Azure CosmosDB Python SDK
from os import getenv
from azure.cosmos import CosmosClient, PartitionKey
import uuid
AZ_DB_ENDPOINT = getenv('AZ_DB_ENDPOINT')
AZ_DB_PRIMARYKEY = getenv('AZ_DB_PRIMARYKEY')
DATABASE_NAME = 'Tasks'
CONTAINER_NAME = 'Items'
AZ_DB_CLIENT = CosmosClient(AZ_DB_ENDPOINT, AZ_DB_PRIMARYKEY)
@Satak
Satak / github_action.md
Created December 4, 2019 12:24
GitHub action dev guide
@Satak
Satak / Invoke-GistDeployment.ps1
Created December 1, 2019 11:25
Gets file content from repository and deploys that as a Gist
<#
.Synopsis
Gets file content from repository and deploys that as a Gist.
.DESCRIPTION
Used in a GitHub action that automatically deploys your private repository file content as a secret Gist for example.
You must provide GitHub Personal access Token, target Gist ID and Gist filename
.PARAMETER Token
GitHub Personal Access Token with Gist scope
.PARAMETER GistID
GitHub Gist ID