Skip to content

Instantly share code, notes, and snippets.

@ironbyte
ironbyte / esm-package.md
Created July 26, 2023 11:14 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@ironbyte
ironbyte / restore.sh
Created January 5, 2021 09:03 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
@ironbyte
ironbyte / restore.sh
Created January 5, 2021 09:03 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
#!/bin/sh
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ 'master' = ${current_branch} ]
then
echo "ERROR: Not allowed to push to master."
exit 1;
else
exit 0;
@ironbyte
ironbyte / docker-it.sh
Created May 20, 2019 14:45 — forked from mattgrayisok/docker-it.sh
A simple script to install docker on a server
#!/bin/sh
curl https://get.docker.com | sh
sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -aG docker $USER
echo "****************"
echo "* Docker and docker-compose have been installed"
echo "* The current user has been added to the docker group"
echo "* Close and restart this session or run 'su - $USER' to refresh your active groups"
echo "****************"
@ironbyte
ironbyte / mongoDump.md
Created April 30, 2019 11:33 — forked from JaniAnttonen/mongoDump.md
Export Docker MongoDB collection as a JSON file

First, find the container that runs your MongoDB and ssh into it.

Then, find the collection you want to export:

mongo
show dbs
use <database>
show collections
exit
@ironbyte
ironbyte / nginx-tuning.md
Created April 15, 2019 20:14 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@ironbyte
ironbyte / README-Template.md
Created April 7, 2019 22:29 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ironbyte
ironbyte / docker.compose.yml
Created March 15, 2019 12:24 — forked from thomas15v/docker.compose.yml
traefik.io nginx example
version: '2'
services:
nginx:
image: nginx:alpine
restart: always
labels:
- "traefik.enable=true"
- 'traefik.frontend.rule=Host:www.website.com'
- "traefik.port=80"
volumes:

Node.js Express JSON API - CRUD Stickers We'll be using:

Postgres for our database

knex.js for our database migrations, seeds and queries.

express.js for our JSON routes

Mocha, Chai and SuperTest to test our routes