Skip to content

Instantly share code, notes, and snippets.

View datnguyen199's full-sized avatar
🎯
Focusing

Dat Nguyen datnguyen199

🎯
Focusing
View GitHub Profile
@datnguyen199
datnguyen199 / puma.service
Created November 30, 2024 05:11 — forked from arteezy/puma.service
Manage Puma with systemd and rbenv
[Unit]
Description=Puma Rails Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/home/deploy/app/current
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/app/shared/config/puma.rb
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/app/shared/tmp/pids/puma.state stop
@datnguyen199
datnguyen199 / rails-jsonb-queries
Created May 13, 2023 05:18 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@datnguyen199
datnguyen199 / EslintNodeJS.md
Created December 8, 2021 10:04 — forked from LucasMallmann/EslintNodeJS.md
Eslint and Prettier configuration for NodeJS and Express projects

Eslint and prettier config for nodejs and express projects

Eslint and Libs

You need to install eslint and some other config libs.

yarn add eslint prettier eslint-config-prettier eslint-plugin-prettier -D

yarn eslint --init

.eslintrc.js

@datnguyen199
datnguyen199 / ts-boilerplate.md
Created December 8, 2021 09:40 — forked from silver-xu/ts-boilerplate.md
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

Setup a Node.js project with Typescript, ESLint, Prettier, Husky

1_D8Wwwce8wS3auLAiM3BQKA

Starting a personal node project could be easy; starting a team node project could be challenging.

I am a developer currently working in SEEK Australia.

In my experience, common mistakes developer make when starting a projects are:

  • No Linting
@datnguyen199
datnguyen199 / db.js
Created December 3, 2021 05:12
Node.js test jest, mongodb-memory-server
const mongoose = require('mongoose');
const { MongoMemoryServer } = require('mongodb-memory-server');
// Define a new instance of "MongoMemoryServer" to automatically start server
let mongoServer;
// For mongodb-memory-server's old version (< 7) use this instead:
// const mongoServer = new MongoMemoryServer();
const opts = {
@datnguyen199
datnguyen199 / a-mongodb-replica-set-docker-compose-readme.md
Created November 20, 2021 15:12 — forked from harveyconnor/a-mongodb-replica-set-docker-compose-readme.md
MongoDB Replica Set / docker-compose / mongoose transaction with persistent volume

This will guide you through setting up a replica set in a docker environment using.

  • Docker Compose
  • MongoDB Replica Sets
  • Mongoose
  • Mongoose Transactions

Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!