Skip to content

Instantly share code, notes, and snippets.

View sombochea's full-sized avatar

Sambo Chea sombochea

View GitHub Profile

βœ… AI Agent Prompt for Reviewing and Securing a Node.js/Express/MongoDB API:


You are a senior backend security engineer and API architect. Review the provided Node.js/Express.js/MongoDB (Mongoose) backend. Your task is to identify and fix issues related to:

  1. βœ… Code Quality and Best Practices

    • Follow clean code principles.
  • Ensure modular, scalable structure.

πŸš€ System Design for Safe Financial Data Imports (PostgreSQL + Redis/Bull)

This guide describes a robust, crash-safe, idempotent design for handling large concurrent financial imports (e.g. 1000 users Γ— 500 records).

🎯 Goals

  • Consistency & Integrity: No half-imports or duplicates.
  • Idempotency: Retries never create duplicates.
  • Crash-safety: Survive server crashes, client disconnects, cancellations.
  • Scalability: Support many users uploading at once.
  • Auditability: Always trace each import.
@sombochea
sombochea / haversine_find_2_locs.js
Last active June 12, 2024 02:44
Find the distance between 2 locations given.
export const findDistanceOf2Locations = ({ target, source }: {
target: { lat: number, lon: number, fencingRadius: number },
source: { lat: number, lon: number }
}): {
distance: number,
isInside: boolean,
distancePretty: string // Format the distance in meters or kilometers (e.g. 100m or 1.5km)
} => {
const { lat: lat1, lon: lon1 } = source;
@sombochea
sombochea / order_cafe.dart
Last active June 7, 2024 08:27
Sample code for Orders
class Topping {
String name;
double price;
Topping(this.name, this.price);
}
class CafeItem {
String name;
@sombochea
sombochea / executor_concurrently.dart
Created February 16, 2024 05:55
A simple code for run with retry and concurrently in dart.
import 'dart:async';
import 'dart:collection';
FutureOr<T?> executeWithRetry<T>(
FutureOr<T?> Function() function, {
int maxRetries = 3,
int delayFactor = 2, // in seconds
throwIfFailed = true,
}) async {
int retries = 0;
package com.cubetiqs.rps.example;
import com.cubetiqs.sdk.rps.RpsClient;
import com.cubetiqs.sdk.shared.util.JsonUtil;
import com.cubetiqs.sdk.socketio.Utils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.concurrent.TimeUnit;
/**
* @author sombochea
@sombochea
sombochea / Server.kt
Created May 12, 2022 08:33 — forked from Silverbaq/Server.kt
A simple socket-server written in Kotlin
package dk.im2b
import java.io.OutputStream
import java.net.ServerSocket
import java.net.Socket
import java.nio.charset.Charset
import java.util.*
import kotlin.concurrent.thread
@sombochea
sombochea / log4j_rce_detection.md
Last active December 11, 2021 01:54 — forked from Neo23x0/log4j_rce_detection.md
Log4j RCE CVE-2021-44228 Exploitation Detection

log4j RCE Exploitation Detection

You can use these commands and rules to search for exploitation attempts against log4j RCE vulnerability CVE-2021-44228

Grep / Zgrep

This command using for searches logs in nginx web server (access log)

cat /var/log/nginx/access.log | grep '${jndi:'
@sombochea
sombochea / ExampleController.java
Created December 18, 2020 11:16
SpringFox Swagger @AliasFor not working on @apioperation in Spring Boot
package com.example.mytest;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.PathSelectors;