Skip to content

Instantly share code, notes, and snippets.

View tsh-code's full-sized avatar

TSH code sharing tsh-code

View GitHub Profile
@tsh-code
tsh-code / .spec.js
Last active September 4, 2025 09:15
import LoginEndpoint from '../../endpoints/loginEndpoint';
import RegistrationEndpoint from '../../endpoints/registrationEndpoint';
import HomePage from '../../pages/homePage';
import TransactionHistoryPage from '../../pages/transactionHistoryPage';
describe('History transaction via UI', () => {
const registrationEndpoint = new RegistrationEndpoint();
const loginEndpoint = new LoginEndpoint();
const homePage = new HomePage();
const transactionHistoryPage = new TransactionHistoryPage();
Your task is to find unique individuals in the given text. As a result, return an array of objects in the given format:
[
{
firstName: string,
lastName: string,
presumedGender: "male" | "female" | "unknown"
}
]
const WebSocket = require("ws");
const redis = require("redis");
const subscriber = redis.createClient({
url: "redis://localhost:6379"
});
const publisher = subscriber.duplicate();
const WS_CHANNEL = "ws:messages";
const mockedUsers = [
{
"transfer": {
"properties": {
"transfer_type_of_transportation": {
"type": "string",
"description": "if it is car or aircraft or ship"
},
"transfer_person_name": { "type": "string" },
"transfer_departure_from_location": { "type": "string" },
"transfer_arrival_to_location": { "type": "string" },
@tsh-code
tsh-code / du.sh
Created May 18, 2019 13:55
Find largest modules
du -sh ./node_modules/* | sort -nr | grep '\dM.*'
@tsh-code
tsh-code / Api.ts
Created May 6, 2024 09:44
Preloaded translation lambdas API stack
import { Api, Function, StackContext, use } from "sst/constructs";
import { Translations } from "./Translations";
export function API({ stack }: StackContext) {
const { translationFn, translationFns } = use(Translations);
const staticTranslationLambdas: Record<string, { function: Function }> = Object.fromEntries(
translationFns.map(({ key, fn }) => [`POST /api/translate/${key}`, { function: fn }])
);
@tsh-code
tsh-code / Translations.ts
Created May 6, 2024 09:43
multiple preloaded lambdas stack
import { StackContext, Function, Stack } from "sst/constructs";
const LANGUAGE_PAIRS = [
["es", "en"],
["pl", "en"],
] as const;
interface UnidirectionalTranslation {
from: string;
to: string;
}
@tsh-code
tsh-code / handler.py
Created May 6, 2024 09:42
Preloaded translation lambdas handler
from easynmt import EasyNMT
import json
import os
def main(event, context):
source_lang = os.environ.get("FROM_LANGUAGE_CODE")
target_lang = os.environ.get("TO_LANGUAGE_CODE")
try:
body_dict = json.loads(event.get("body", "{}"))
@tsh-code
tsh-code / Dockerfile
Created May 6, 2024 09:41
Preloaded translation lambdas
FROM alpine:latest AS model
ARG LANGUAGE_CODE_PAIR
ENV LANGUAGE_CODE_PAIR=$LANGUAGE_CODE_PAIR
RUN test -n "$LANGUAGE_CODE_PAIR" || (echo "ERROR: LANGUAGE_CODE_PAIR is empty!" && exit 1)
RUN apk update && apk add --no-cache curl git git-lfs
RUN git lfs install
RUN git clone https://huggingface.co/Helsinki-NLP/opus-mt-${LANGUAGE_CODE_PAIR} /tmp/models
import { SSTConfig } from "sst";
import { Translations } from "./stacks/Translations";
import { API } from "./stacks/Api";
export default {
config(_input) {
return {
name: "easynmt-opus-translation",
region: "eu-west-1",
};