Skip to content

Instantly share code, notes, and snippets.

View soumoks's full-sized avatar
🏠
Working from home

Sourabh Mokhasi soumoks

🏠
Working from home
View GitHub Profile
@soumoks
soumoks / Dockerfile
Last active March 17, 2025 21:01
uv dockerfile with local dependency
# https://github.com/astral-sh/uv-docker-example/blob/main/multistage.Dockerfile
# use base python image with uv pre-installed
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
ARG WORK_DIR=/app
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
WORKDIR ${WORK_DIR}
COPY pyproject.toml ${WORK_DIR}/pyproject.toml
from datetime import datetime, timedelta
def daterange(date1, date2):
date_range = list()
for n in range(int ((date2 - date1).days)):
tmp = date1 + timedelta(n)
date_range.append(tmp.strftime('%Y-%m-%d'))
return date_range
current_date = datetime.today()
last_week_start = current_date - timedelta(days=7)
@soumoks
soumoks / gist:c9b7493183c904f0c4e5c13e822bcd47
Last active November 28, 2022 22:33
kakfa_number_of_partitions_per_broker.sh
# returns number of partitions per broker
kafka-log-dirs.sh --describe --bootstrap-server localhost:9092 --topic-list ${topic_name} --describe | grep '^{' | jq '[.brokers[] | {broker:.broker, partition_count:[.logDirs[].partitions[]] | length}]' | jq 'sort_by(.partition_count)'
@soumoks
soumoks / kafka_topic_size_per_broker.sh
Created November 23, 2022 01:11
Returns topic size per broker by summing up individual partition sizes
kafka-log-dirs.sh --describe --bootstrap-server localhost:9092 --topic-list ${topic_name} --describe | grep '^{' | jq '[.brokers[] | {broker:.broker, size:[.logDirs[].partitions[].size] | add}]' | less
import scala.collection.mutable
case class DataServiceLookup(
app_name: String,
lookup_keys: mutable.Map[String, Any],
data: mutable.Map[String, Any]
)
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction
import org.apache.flink.streaming.runtime.tasks.{ProcessingTimeService,ProcessingTimeCallback}
import org.apache.flink.streaming.api.operators.StreamingRuntimeContext
import org.apache.flink.api.common.state.{ValueState, ValueStateDescriptor}
class RichSinkFactUpcoming extends RichSinkFunction[FulfillmentUsagesOutput] with ProcessingTimeCallback {
@transient var processingTimeService: ProcessingTimeService = _
/**
* Reads the items.txt file and returns an inventory object
*
* @return
* @throws IOException
*/
public Inventory ReadToolFile() throws IOException {
Inventory theInventory = new Inventory();
try {
package View;
import javax.swing.*;
import java.awt.*;
/**
* The type Search panel.
*/
public class SearchPanel extends JPanel {
private JRadioButton clientIdButton;
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: github handler
Outputs:
GithubHandlerApiURL:
Description: "API Prod stage endpoint"
Value: !Sub "https://${ApiGatewayApi}.execute-api.${AWS::Region}.amazonaws.com/prod/"
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
AWSTemplateFormatVersion: "2010-09-09"
Description: Template creates Codebuild resources for a simple SAM Application
Resources:
SamCodeBuild:
Type: AWS::CodeBuild::Project
Properties:
Name: sam-deployment-v2
Description: Build process for a simple Python HelloWorld Application deployed using AWS SAM
ServiceRole: !GetAtt CodeBuildIAMRole.Arn
Artifacts: