Skip to content

Instantly share code, notes, and snippets.

Avatar

Emmanuel N Kyeyune emmanuelnk

View GitHub Profile
@emmanuelnk
emmanuelnk / cronlist.sh
Created Mar 31, 2021 — 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
View cronlist.sh
#!/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 / cronlist.sh
Created Mar 31, 2021 — 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.
View cronlist.sh
#!/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 / ssh2-client.ts
Created Mar 23, 2021
Forward SSH port in Node.js
View ssh2-client.ts
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 / api.service
Last active Feb 17, 2021
The NewBoston Bank and Validator Setup Scripts
View api.service
[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 / db.py
Last active Mar 26, 2021
Python SQLAlchemy Basic Model, Session, DB Connection Classes
View db.py
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 / init_script
Last active Dec 9, 2020
Install Redis Server on Amazon Linux AMI EC2
View init_script
#!/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
View expose_docker_container_hostname.sh
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container-name
@emmanuelnk
emmanuelnk / getAmiID.ts
Created Nov 20, 2020
Get latest Amazon EC2 AMI image ID just like in the AWS EC2 quick launch console using Node.js
View getAmiID.ts
import * as AWS from "aws-sdk"
export const getAMIImageID = async(imageName: string): Promise<string | undefined> => {
AWS.config.update({ region: "us-west-2" })
const ec2 = new AWS.EC2()
// see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EC2.html#describeImages-property
const params = {
Filters: [
{
@emmanuelnk
emmanuelnk / koa-context.ts
Last active Nov 12, 2020
Simple Koa Context for testing in Typescript (Mocha-chai, Jest) etc
View koa-context.ts
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
// Ripped from https://github.com/koajs/koa/blob/master/test/helpers/context.js
// Solution courtesy of user @fl0w. See: https://github.com/koajs/koa/issues/999#issuecomment-309270599
// I've disabled type checking in this file but you are free to add types if you wish
// if you want more comprehensive Koa Context object to test stuff like Cookies etc
// then use https://www.npmjs.com/package/@shopify/jest-koa-mocks (requires Jest)