Skip to content

Instantly share code, notes, and snippets.

@mjex11
mjex11 / github-action.yml
Last active September 4, 2023 08:40
Configure which jobs to run based on file paths that change.
jobs:
path-check:
runs-on: ubuntu-latest
outputs:
message: ${{ steps.check.outputs.message }}
steps:
- name: Checkout
uses: actions/checkout@v3
- id: check
@mjex11
mjex11 / Dockerfile
Created May 17, 2023 21:17
Dockrfile for Ruby on Rails
# build stage
FROM ruby:3.2.2 AS builder
WORKDIR /app
ENV RAILS_ENV=production
ENV NODE_ENV=production
RUN apt-get update -qq && apt-get install --no-install-recommends -y \
build-essential \
@mjex11
mjex11 / Dockerfile
Created May 3, 2023 06:02
NestJS with Docker and docker-compose
###################
# DEVELOPMENT
###################
FROM node:20.0.0-slim AS development
WORKDIR /usr/src/app
RUN apt-get update && apt-get -qq install -y --no-install-recommends \
tzdata \
tini \
@mjex11
mjex11 / zipFile.mjs
Created April 21, 2023 10:17
Zip CSV file in nodejs 18.x
import { createWriteStream, createReadStream } from 'fs';
import archiver from 'archiver';
import { basename } from 'path';
export const zipFile = async (sourceFilePath, outputZipPath) => {
return new Promise((resolve, reject) => {
const output = createWriteStream(outputZipPath);
const archive = archiver('zip', {
zlib: { level: 9 },
});
@mjex11
mjex11 / index.mjs
Created April 13, 2023 00:35
handle Lambda timeout error
export const sleep = (ms) => {
return new Promise((_, reject) => {
setTimeout(() => {
// 指定した時間が経過したら、エラーを生成してプロミスをrejectする
reject(new Error('Lambda function timeout'));
}, ms);
});
};
export async function service(event) {
@mjex11
mjex11 / query.sh
Last active April 13, 2023 00:35
Split PostgreSQL data by period and output to CSV file with Bash
#!/bin/bash
# データベース接続情報
db_host="db_host"
db_port=5432
db_name="db_name"
db_user="db_user"
db_password="db_password"
# SSH接続情報
@mjex11
mjex11 / extract_selected_col_as_str.sh
Created September 6, 2022 01:48
awkでCSVのn行目を抜き出し、シングルクオーテーションで囲んだ上で、クリップボードにコピーする
awk -F',' '{ print "'\''"$n"'\''," }' file.csv | pbcopy