Skip to content

Instantly share code, notes, and snippets.

@ankur0101
ankur0101 / sap-cpi-set-trace.js
Last active June 4, 2025 09:34
Setting TRACES for multiple iflows in SAP CPI
async function startPing(aiflows) {
const promise = $.ajax({
url: '/itspaces/ping',
method: 'GET',
headers: {
'Content-type': 'application/json',
'x-csrf-token': Global.CSRF_TOKEN.value
}
})
@ankur0101
ankur0101 / consume_function_locally.js
Created January 20, 2025 08:34
SAP CAP - Calling function internally with headers
const oFuncResponse = await myService.myFunc1({
param1 : 'value1',
param2 : 'value2'
});
//If it is required to pass any custom headers, then use .send method with event paraeter as below:
const oFuncResponse = await myService.send({
"event": 'myFunc1',
"data": {
param1 : 'value1',
@ankur0101
ankur0101 / npm.sh
Created November 29, 2023 07:35
Running npm to install package inside Cloud Foundry deployed application
#!/bin/bash
./deps/0/bin/node ./deps/0/node/bin/npm $@
# Now "./npm.sh install express" will work
@ankur0101
ankur0101 / node.sh
Created November 29, 2023 07:34
Running node-cli inside Cloud Foundry Application
#!/bin/bash
./deps/0/bin/node $@
# Now ./node.sh server.js will work
@ankur0101
ankur0101 / updteCORS.py
Last active September 2, 2023 07:18
AWS API Gateway resource CORS configuration updater
import boto3
# Initialize the Boto3 client for API Gateway
client = boto3.client('apigateway')
# Define the API Gateway resource ID and the new CORS settings
resource_id = 'your-resource-id'
new_cors_settings = {
"allowOrigins": ['https://example.com'],
"allowHeaders": ['Authorization', 'Content-Type'],
@ankur0101
ankur0101 / lambda2git.py
Created July 31, 2023 14:34
A python snippet to retrieve all lambda functions to store under git
import boto3
import os
import sys
import requests
from pathlib import Path
import zipfile
fn_client = boto3.client("lambda")
dir_name = 'lambda_functions'
Path("./"+str(dir_name)).mkdir(parents=True, exist_ok=True)
#!/bin/bash
# Replace with your actual API Gateway ID
API_GATEWAY_ID="your-id-here"
# Header for CSV format
echo "Resource ID,Resource Path,HTTP Method,Integration,Authorizer Name,Authorizer Type"
# Step 1: Get a list of resources and paths
resources_info=$(aws apigateway get-resources --rest-api-id "$API_GATEWAY_ID" --query 'items[].{id: id, path: path}' --output json)
@ankur0101
ankur0101 / grecaptchav2.js
Created May 29, 2023 07:44
SAPUI5 custom control for Google reCaptcha V2
sap.ui.define([
'sap/ui/core/Control'
], function(Control, ) {
'use strict';
return Control.extend("enkompass.control.grecaptchav2", {
metadata : {
properties: {
key: {type: "string", defaultValue : 0},
size: {type: "string", defaultValue : "normal"}
}
@ankur0101
ankur0101 / layer.sh
Created February 20, 2023 10:55
Building layers for Lambda Layers
$ pip install \
--platform manylinux2010_x86_64 \
--implementation cp \
--python 3.9 \
--only-binary=:all: --upgrade \
--target awsbundle \
cryptography
@ankur0101
ankur0101 / concurrency.py
Created February 20, 2023 06:29
Python concurrency
import time
from multiprocessing import Process, Pipe
def sleeper(seconds, conn):
time.sleep(seconds)
conn.send("Got up after "+str(seconds)+" seconds")
conn.close()
print("Processed: "+str(seconds))
if __name__ == '__main__':