Skip to content

Instantly share code, notes, and snippets.

View wodCZ's full-sized avatar

Martin Janeček wodCZ

View GitHub Profile
@wodCZ
wodCZ / queues.module.ts
Created January 21, 2024 16:49
Nest separate Queue and Processor structure
import { Module } from '@nestjs/common';
import { BullModule, BullRootModuleOptions } from '@nestjs/bull';
import { QueuesService } from './queues.service';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AppConfig } from '../config/schema';
@Module({
imports: [
BullModule.forRootAsync({
imports: [ConfigModule],
@wodCZ
wodCZ / development-stage.Dockerfile
Created November 12, 2022 12:55
Node.js Dockerfiles
##################################
# Development stage
# This is not used at the moment, since the node_modules synchronization with host is complicated.
# Left here for future reference if we decide to run the app in docker during development.
##################################
FROM base as development
# Prepare the app directory and node user
@wodCZ
wodCZ / Dockerfile
Created August 2, 2022 13:25
Nest.js + Prisma Dockerfile - possibly smallest image size
FROM node:18-alpine as build
WORKDIR /app
RUN yarn global add @vercel/ncc
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN ./node_modules/.bin/prisma generate && yarn run build && ncc build dist/src/main.js -o build
@wodCZ
wodCZ / Dockerfile
Created October 15, 2021 11:34
Sample node.js Dockerfile
##################################
# Dev dependencies stage, only prepares node_modules, that are later reused
##################################
FROM node:14-slim as devdependencies
USER node
WORKDIR /app
COPY --chown=node:node package.json yarn.lock ./
# Use docker mount cache, with locked sharing to avoid concurrency issues.
@wodCZ
wodCZ / main.py
Last active July 29, 2021 12:32
Simple starter for a String Calculator kata (first 3 steps done)
# This is a simple starter for a String Calculator kata (https://osherove.com/tdd-kata-1/)
# The following link could be useful for working with the input string:
# https://developers.google.com/edu/python/strings
def add(numbers):
# Here, write the actual implementation.
# Don't forget to commit your changes, at least every time you solve a step.
# Also, don't be afraid to modify any of the existing code. Refactoring is your friend - as the complexity of
# the program grows, the readability of the code is crucial for future maintainability.
@wodCZ
wodCZ / Metricbeat aws module permissions
Created May 28, 2020 08:44 — forked from asjadathick/Metricbeat aws module permissions
AWS IAM policy for metricbeat aws module metricsets
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:DescribeRegions",
"cloudwatch:GetMetricData",
@wodCZ
wodCZ / express.js
Created March 17, 2020 18:47
Web Framework performance comparison
const express = require('express')
const app = express()
const port = 4000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
// node express.js
@wodCZ
wodCZ / async-foreach.ts
Last active November 21, 2019 13:36 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
export async function asyncForEach<T>(array: T[], callback: (item: T, index: number, allItems: T[]) => void) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
@wodCZ
wodCZ / Dockerfile
Created February 13, 2019 14:28
Configuration for SPA frontend in Docker
FROM node:9.8.0-alpine as build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
FROM nginx:1.13.9-alpine
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/app/build /usr/share/nginx/html
import logging
from celery.app.defaults import DEFAULT_TASK_LOG_FMT, DEFAULT_PROCESS_LOG_FMT
class CeleryTaskFilter(logging.Filter):
def filter(self, record):
return record.processName.find('Worker') != -1