Skip to content

Instantly share code, notes, and snippets.

View nerixim's full-sized avatar
🚰
Focusing

Nikita K nerixim

🚰
Focusing
  • Tokyo
  • 15:19 (UTC +09:00)
View GitHub Profile
@nerixim
nerixim / create-read-only-user.sql
Created October 11, 2024 05:09
add read only user to postgres
CREATE ROLE read_only WITH LOGIN PASSWORD 'PASSWORD';
GRANT CONNECT ON DATABASE "DB_NAME" TO read_only;
GRANT USAGE ON SCHEMA public TO read_only;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO read_only;
-- [Optional] Use with care
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO read_only;
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
@nerixim
nerixim / split_openapi_by_path.rb
Created May 21, 2023 06:41
Split OpenAPI definition by path
# output inspired by reading:
# https://tech.buysell-technologies.com/entry/2021/09/21/095238
require 'yaml'
api = YAML.load_file('openapi/schema.yml')
api_refs = api.dup
api['paths'].each do |path, value|
schema_name = "paths/#{path.gsub('/api/v1/', '')}"
@nerixim
nerixim / git-changed.sh
Last active December 23, 2020 15:15
Check if directory has changes
git diff --quiet HEAD $REF -- $DIR || echo changed
@nerixim
nerixim / code_review_basics.md
Created August 17, 2019 08:34 — forked from taichi/code_review_basics.md
チームでコードを書き始めた後、「どうやらレビューってやつをした方が良いらしい」くらいの若手に向けた資料です。

コードレビューの基本


一番大事な事

ソースコードはプロジェクトの共同所有物である

  • 誰かだけが触れるコードを無くす
@nerixim
nerixim / nginx.conf
Created September 17, 2018 14:56
simple nginx config for a wsgi app
events {
worker_connections 4000;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
@nerixim
nerixim / app.py
Last active September 17, 2018 14:50
Sample Flask app with optional debugging mode working with gunicorn
import os
import flask
from werkzeug.debug import DebuggedApplication
app = Flask(__name__)
app.config['debug'] = bool(os.environ.get('DEBUG'))
if app.config.get('debug'):
app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
@nerixim
nerixim / Dockerfile
Last active September 17, 2018 14:43
Dockerfile for gunicorn wsgi app
FROM python:3.7-alpine
RUN apk update &&\
apk add mariadb-dev build-base &&\
pip3 install --upgrade pip &&\
pip3 install mysqlclient
COPY ./requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
COPY . /app
@nerixim
nerixim / docker-compose.yml
Created September 17, 2018 14:29
docker-compose file for flask/nginx app
version: "3.3"
services:
web:
build:
context: ./webapp/
dockerfile: Dockerfile
depends_on:
- db
volumes:
- ./webapp/:/app