Skip to content

Instantly share code, notes, and snippets.

View koladilip's full-sized avatar

Dilip Kola koladilip

View GitHub Profile
{"code":"// Enter your JsonTemplate code here\n{\n dontBatchEvents: .events{.metadata.dontBatch},\n batchEvents: .events{!.metadata.dontBatch}\n}\n","name":"dontbatch","type":"JsonTemplate","data":"{\n \"events\": [\n {\n \"field1\": \"unique_value1\",\n \"field2\": \"unique_value2\",\n \"field3\": \"unique_value3\",\n \"metadata\": {\n \"dontBatch\": true\n }\n },\n {\n \"field1\": \"unique_value4\",\n \"field2\": \"unique_value5\",\n \"field3\": \"unique_value6\",\n \"metadata\": {\n \"dontBatch\": false\n }\n },\n {\n \"field1\": \"unique_value7\",\n \"field2\": \"unique_value8\",\n \"field3\": \"unique_value9\",\n \"metadata\": {\n \"dontBatch\": true\n }\n },\n {\n \"field1\": \"unique_value10\",\n \"field2\": \"unique_value11\",\n \"field3\": \"unique_value12\",\n \"metadata\": {\n \"dontBatch\": false\n }\n },\n {\n \"field1\": \"unique_
{
"code": "# Enter your Workflow code here\nsteps:\n - name: productCosts\n template: |\n .orders.products.(.price * .quantity)\n - name: computeTotal\n template: |\n $.sum($.outputs.productCosts)\n\n",
"name": "OrdersWorkflow",
"type": "Workflow",
"data": "{\n \"orders\": [\n {\n \"order_id\": \"OD123456789\",\n \"customer_id\": \"CUS987654321\",\n \"order_date\": \"2024-03-01\",\n \"products\": [\n {\n \"product_id\": \"PROD001\",\n \"name\": \"Smartphone\",\n \"price\": 99,\n \"quantity\": 3\n },\n {\n \"product_id\": \"PROD002\",\n \"name\": \"Laptop\",\n \"price\": 999.99,\n \"quantity\": 1\n }\n ]\n },\n {\n \"order_id\": \"OD987654321\",\n \"customer_id\": \"CUS123456789\",\n \"order_date\": \"2024-03-02\",\n \"products\": [\n {\n \"product_id\": \"PROD002\",\n \"name\": \"Laptop
{
"code": "// Enter your JsonTemplate code here\n^[email protected]@product.({\n order_id: order.order_id,\n product_id: product.product_id,\n product_name: product.name,\n quantity: product.quantity,\n price: product.price,\n amount: product.price * product.quantity\n})",
"name": "Order-example",
"type": "JsonTemplate",
"data": "{\n \"orders\": [\n {\n \"order_id\": \"OD123456789\",\n \"customer_id\": \"CUS987654321\",\n \"order_date\": \"2024-03-01\",\n \"products\": [\n {\n \"product_id\": \"PROD001\",\n \"name\": \"Smartphone\",\n \"price\": 99,\n \"quantity\": 3\n },\n {\n \"product_id\": \"PROD002\",\n \"name\": \"Laptop\",\n \"price\": 999.99,\n \"quantity\": 1\n }\n ]\n },\n {\n \"order_id\": \"OD987654321\",\n \"customer_id\": \"CUS123456789\",\n \"order_date\": \"2024-03-02\",\n \"products\": [\n {\n
@koladilip
koladilip / squad-cast-json-to-csv.js
Last active December 30, 2022 06:25
Squad cast json export to csv with tags extracted from description
const fs = require("fs");
const jsonFilePath = process.argv[2] || "incidents.json";
const isDir = fs.lstatSync(jsonFilePath).isDirectory();
if(!isDir) {
const csv = getCSV(jsonFilePath);
csv.unshift("Title,DestType,Priority,Service,Namespace,WorkspaceId,CreatedAt");
fs.writeFileSync("incidents.csv", csv.join("\n"));
} else {
const files = fs.readdirSync(jsonFilePath);
const csv = files.map(file => {
@koladilip
koladilip / aws-s3-cfn.yaml
Last active May 11, 2022 04:22
AWS S3 Bucket Creation using Cloudformation with conditional properties
AWSTemplateFormatVersion: 2010-09-09
Description: S3 Bucket
Parameters:
BucketName:
Description: Name of the Bucket
Type: String
StorageClass:
Description: Storage class of the Bucket
Type: String
Default: Standard
@koladilip
koladilip / universal-profiles.md
Last active February 13, 2022 15:29
Universal messaging/Profile protocol proposal

Universal Messaging/Profile protocol (Social email protocol)

Email gives freedom to choose the client software to the user. In an email conversation, multiple parties can be involved and they can use different email platforms and client software. Most of the email clients support the management of multiple email accounts from different platforms. All these are possible because there is a common protocol for emails and all platforms and clients just need to be compatible with the protocol. With social media emerging, communication patterns have changed and all communications are now platform-centric. There is no support for cross-platform interaction so there is a disconnect. This is happening because there is no common protocol and all platforms are working in silos hence the communication gap is increasing. To bridge this gap, we need to come up with a common protocol for all social communication.

Features

  1. Users will have a globally identifiable universal profile(UP) that enables the communication
const puppeteer = require('puppeteer');
async function wait(timeInMills) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, timeInMills);
});
}
@koladilip
koladilip / phantonjs-infinite-scroll.js
Last active June 11, 2023 23:58
Scrap a webpage with Infinite scrolling using phantomjs
const phantom = require('phantom');
async function wait(timeInMills) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, timeInMills);
});
}
@koladilip
koladilip / get-rows-count-by-table-of-mysql-db.sql
Created July 1, 2019 16:16
Get Rows counts from all the tables of MySQL DB
DELIMITER $$
CREATE PROCEDURE `COUNT_ROWS_COUNTS_BY_TABLE`(dbName varchar(128))
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE TNAME CHAR(255);
DECLARE table_names CURSOR for
SELECT CONCAT("`", TABLE_SCHEMA, "`.`", table_name, "`") FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = dbName;
@koladilip
koladilip / aws-cognito-refresh-tokens-from-brower.js
Last active August 22, 2023 20:13
Code for refreshing AWS Cognito user pool tokens using refresh token from browser.
fetch("https://cognito-idp.<cognito-user-pool-region>.amazonaws.com/", {
headers: {
"X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth",
"Content-Type": "application/x-amz-json-1.1",
},
mode: 'cors',
cache: 'no-cache',
method: 'POST',
body: JSON.stringify({
ClientId: "<cognito-user-pool-client-id>",