Skip to content

Instantly share code, notes, and snippets.

View swateek's full-sized avatar
🎯
One Small Step at a Time

Swateek Jena swateek

🎯
One Small Step at a Time
View GitHub Profile
@swateek
swateek / blobs_in_singlestore.md
Created April 17, 2025 08:20
Blobs In Singlestore
USE information_schema;

DESC MV_DATA_DISK_USAGE;

SELECT * FROM MV_DATA_DISK_USAGE;

SELECT DATABASE_NAME, FORMAT(SUM(`BLOBS_B`) / 1024/1024, 0) MB
FROM MV_DATA_DISK_USAGE
GROUP BY DATABASE_NAME
@swateek
swateek / agents.yaml
Created January 14, 2025 03:04
Crew AI with Bedrock LLMs
bedrock_agent:
role: >
Bedrock AI Assistant
goal: >
Help users generate responses using AWS Bedrock's LLM.
backstory: >
You are an advanced AI assistant powered by AWS Bedrock. You excel at processing
and generating meaningful insights from textual data.
tools:
- bedrock_tool
@swateek
swateek / working_with_jq.md
Last active August 24, 2023 07:55
working_with_jq.md

jq

  • Print all of the JSON content in a key value pair, like in an environment file.
echo '{"key1":"value1", "key2": "value2", "key3": "value3"}'\
| jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]'

echo '{"key1":"value1", "key2": "value2", "key3": "value3"}'\
| jq -r 'to_entries[] | "\(.key)=\(.value | tostring)"'
@swateek
swateek / random_file_creation.sh
Created July 16, 2023 14:04
Create Random Files & Folders to Test
#!/bin/bash
current_time=$(date "+%Y_%m_%dT%H_%M_%S")
rm -rf .my_job 2> /dev/null
mkdir -p .my_job
mkdir -p .my_job/{100,101,102,103,104,105,106,107,108,109,110}
ls -d .my_job/* | xargs -I {} bash -c "cd '{}' && touch sample_$random_$current_time.txt"
curl -s -X GET https://filesamples.com/samples/document/csv/sample4.csv -o .my_job/sample_$current_time.csv
curl -s -X GET https://filesamples.com/samples/document/pdf/sample2.pdf -o .my_job/sample_$current_time.pdf
curl -s -X GET https://filesamples.com/samples/document/xls/sample3.xls -o .my_job/sample_$current_time.xls
@swateek
swateek / json_with_singlestore.sql
Last active May 3, 2024 10:39
Working With JSON in SingleStore
-- Delete a key from JSON Object
-- INPUT: {"somekey":"somevalue", "meta": {"ui": false, "miscTest": {"unit": "kWh", "value": 10}}}
UPDATE myTable
SET meta=JSON_DELETE_KEY(meta, 'miscTest')
WHERE id="85c8a446-fe24-11ed-8abf-af2f19c7e27f";
-- RESULT: {"somekey":"somevalue", "meta": {"ui": false}}
-- Update a key in JSON Object
-- INPUT: {"somekey":"somevalue", "meta": {"ui": false}}
@swateek
swateek / create_test_files.bat
Created June 26, 2023 14:53
Working With Windows Task Scheduler From CLI
@echo off
echo %DATE% %TIME%>C:\Users\Swateek\Downloads\tmp\abc_%RANDOM%.txt
If you'r using MAC Intel CPU you want to use VMware to virtual your desired OS such Windows or Ubuntu on the MAC OS you need to download VMware Fusion Player first then it has two version Pro and Player, the Player version is free for personal use but you need to create VM account to download and licence key.
You can create account to download yourself here:
https://customerconnect.vmware.com/group/vmware/evalcenter?p=fusion-player-personal
If you don't want to create account to get license, you can try below original license key for VMware Fusion Player:
COMPONENT:
VMware Fusion Player – Personal Use
@swateek
swateek / vagrant-vmware-tech-preview-apple-m1-pro.md
Created April 16, 2022 04:56 — forked from sbailliez/vagrant-vmware-tech-preview-apple-m1-pro.md
Vagrant and VMWare Tech Preview on Apple M1 Pro

Vagrant and VMWare Tech Preview on Apple M1 Pro

This document summarizes notes taken while to make the VMWare Tech preview work on Apple M1 Pro, it originated from discussions in hashicorp/vagrant-vmware-desktop#22

Installing Rosetta

First install Rosetta if not already done, this is needed to run x86 code:

@swateek
swateek / postman_tests.js
Last active December 7, 2023 23:09
All POSTMAN functions that can be used to run tests
// pm.globals.clear(); // Be careful with this usage
// Save common tests in a global variable
postman.setGlobalVariable("commonTests", () => {
pm.test("Common Tests - Response Time", function(){
pm.expect(pm.response.responseTime).is.lessThan(500);
});
pm.test("Common Tests - Content Type", function(){
pm.expect(pm.response.headers.get('Content-Type')).equals('application/json');
@swateek
swateek / mysql_json.sql
Last active January 17, 2022 13:23
Working with JSON data structures in MySQL
-- https://www.digitalocean.com/community/tutorials/working-with-json-in-mysql
-- select rows where isPrivate field is ""
SELECT * FROM ecom_categories WHERE JSON_EXTRACT(`attributes` , '$.isPrivate') = "";
-- select rows where isPrivate field is not a part of JSON object
SELECT * FROM ecom_categories WHERE JSON_EXTRACT(`attributes` , '$.isPrivate') IS NULL;
-- add isPrivate field to attributes which are not present
UPDATE ecom_categories SET `attributes` = JSON_INSERT(`attributes`, '$.isPrivate', false);