Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / download_file_from_ftp_progress_bar.py
Created August 30, 2018 02:31
Download file from FTP Server, upload file to S3 with Progress Bar in Python
import progressbar
from hurry.filesize import size
filesize = ftp.size(file)
try:
down_progress = progressbar.AnimatedProgressBar(end=filesize, width=50)
with open(TEMP_DIR + file, 'wb') as f:
def download_progress(chunk):
f.write(chunk)
down_progress + len(chunk)
@emmanuelnk
emmanuelnk / pygrib_eccodes_python3.6_install.md
Last active February 3, 2022 19:56
How to install PyGrib with ECCodes (Python 3.6.5, Ubuntu 18, 16, RHEL)

How to install PyGrib with ECCodes (Python 3.6.5, Ubuntu 19, 18, 16, RHEL, Lambda, Linux AMI, Docker)

[ last_updated: 07-JAN-2020 ]

Recently I've had to work with Meterological data of the GRIB format. Needless to say, if you're reading this, you probably know how hard it is to get a library that can read them and even harder, setting up those libraries. Pygrib for python is by far the best library for reading grib files but the installation can leave you dizzy

In this tutorial I use Ubuntu 18 and python 3.6.5 virtualenv. Note: You don't have to use virtualenv Python. You can just as well use your system Python 3 however I personally find virtualenv a clean way to deal with these kind of complicated setups (prevents me mucking up my system's Python). This setup should also work with lower and higher Ubuntu versions (as someone below mentioned) and other Linux distros (like RHEL - AWS Linux AMI etc). The key to this installation is to build eccodes correctly (for your machine architecture) and succe

@emmanuelnk
emmanuelnk / aws-block-stack.ts
Created January 28, 2022 18:43 — forked from leegilmorecode/aws-block-stack.ts
Example of API Gateway caching on AWS using the CDK
// create the rest API for accessing our lambdas
const api: apigw.RestApi = new apigw.RestApi(this, "blogs-api", {
description: "blogs api gateway",
deploy: true,
deployOptions: {
// this enables caching on our api gateway, with a ttl of five minutes (unless overridden per method)
cachingEnabled: true,
cacheClusterEnabled: true,
cacheDataEncrypted: true,
stageName: "prod",
@emmanuelnk
emmanuelnk / terraform_install_64bit_linux.bash
Created April 10, 2019 09:20
Install Terraform on 64 bit Linux
# 0.XX.XX is the terraform version you need
wget https://releases.hashicorp.com/terraform/0.XX.XX/terraform_0.XX.XX_linux_amd64.zip -P ~/Downloads/terraform/
cd ~/Downloads/terraform && unzip terraform_0.11.8_linux_amd64.zip && cd terraform
sudo mv terraform /usr/local/bin/
nano ~/.bashrc
export PATH="$PATH:/usr/local/bin/terraform"
source ~/.bashrc
# then from anywhere
@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 / 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 / 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 / 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 / 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]