Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / expose_docker_container_hostname.sh
Last active December 4, 2020 07:32
Expose docker hostname
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container-name
@emmanuelnk
emmanuelnk / init_script
Last active March 27, 2023 09:26
Install Redis Server on Amazon Linux AMI EC2
#!/bin/sh
# From - http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
@emmanuelnk
emmanuelnk / db.py
Last active May 9, 2024 07:46
Python SQLAlchemy Basic Model, Session, DB Connection Classes
from sqlalchemy import event
import os
import logging
import sqlalchemy
import boto3
import base64
import json
from botocore.exceptions import ClientError
logger = logging.getLogger()
@emmanuelnk
emmanuelnk / api.service
Last active February 17, 2021 17:29
The NewBoston Bank and Validator Setup Scripts
[Unit]
Description = Service to run Django API
After = network.target
[Service]
EnvironmentFile = /etc/bank/environment
User = deploy
ExecStart = /usr/local/bin/start_api.sh
[Install]
@emmanuelnk
emmanuelnk / ssh2-client.ts
Created March 23, 2021 14:32
Forward SSH port in Node.js
import sshClient from 'ssh2-promise'
const config = {
database: {
host: process.env.DB_HOST,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
port: process.env.DB_PORT,
databaseName: process.env.DB_NAME,
},
@emmanuelnk
emmanuelnk / cronlist.sh
Created March 31, 2021 11:52 — forked from Zitrax/cronlist.sh
Script to list all cron events on a system - found on stackoverflow.com: http://bit.ly/nkFwD9 Modified from original to pick up users also in /home.
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
@emmanuelnk
emmanuelnk / cronlist.sh
Created March 31, 2021 11:53 — forked from islander/cronlist.sh
Script to list all cron events on a system - found on stackoverflow.com: http://bit.ly/nkFwD9 Modified from original to list /etc/anacron jobs
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
ANACRONTAB='/etc/anacrontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
@emmanuelnk
emmanuelnk / code-reviews.md
Created October 8, 2021 06:19 — forked from sktse/code-reviews.md
How to Keep Pull Requests Manageable

How to Keep Pull Requests Manageable

  • There are a lot different things you can try to keep pull requests manageable.
  • These pointers are not meant to be rules, but merely guidelines when possible. Due to the nature of what you are working on, some of these techniques may not be possible (or incredibly difficult).

More like guidelines

  • Either way, here are some tips to help make people not want to claw their eyes out reviewing a pull request.

The Basics

  • These are the fundamental basics to a pull request and ALL pull requests should have these, regardless of how small or meaningless it is.
@emmanuelnk
emmanuelnk / dwr.sh
Created November 18, 2021 16:58
Delete Workflow Runs
#!/usr/bin/env bash
# Delete workflow runs - dwr
# Given an "owner/repo" name, such as "qmacro/thinking-aloud",
# retrieve the workflow runs for that repo and present them in a
# list. Selected runs will be deleted. Uses the GitHub API.
# Requires gh (GitHub CLI), jq (JSON processor) and fzf