Skip to content

Instantly share code, notes, and snippets.

View diegofcornejo's full-sized avatar
🪄
randomtechguy

Diego Cornejo diegofcornejo

🪄
randomtechguy
View GitHub Profile
@diegofcornejo
diegofcornejo / flask_smpp_clien.py
Created March 12, 2021 05:29
Python Flask SMPP Client
import logging
import sys
import smpplib.gsm
import smpplib.client
import smpplib.consts
from flask import Flask, request, jsonify
# from flask_mysqldb import MySQL
app = Flask(__name__)
@diegofcornejo
diegofcornejo / node_smpp_client.js
Last active December 21, 2024 13:36
Node SMPP Client
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var smpp = require('smpp');
var session = smpp.connect('smpp://10.10.10.10:4331');
session.auto_enquire_link_period = 1000;
var didConnect = false;
app.use(
@diegofcornejo
diegofcornejo / index.js
Last active December 3, 2021 13:08
Node DynamoDB Get all records
const json2xls = require('json2xls');
const {
convertArrayToCSV
} = require('convert-array-to-csv');
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.update({
region: "us-east-1",
});
var events = new AWS.DynamoDB.DocumentClient();
@diegofcornejo
diegofcornejo / README.MD
Last active March 7, 2020 21:46
Express - SNS - Process SES granular events and save into Cloud Firestore

This assume you already have a SNS subscription (HTTP endpoint) and configured SES events, if not please go to this link

  1. Replace content from serviceAccountKey.json with your own info.

  2. Install dependencies

npm install --save express firebase-admin
@diegofcornejo
diegofcornejo / README.MD
Last active March 7, 2020 05:19
Lambda - SNS - Process SES granular events and save into Cloud Firestore
  1. Download this file FirebaseAdminLayer.zip
  2. Create a Lambda Layer with the downloaded AdminFirebase.zip
  3. Attach FirebaseAdminLayer to your Lambda Function
@diegofcornejo
diegofcornejo / index.js
Last active July 7, 2023 08:21
AWS SES send raw email with attachment
'use strict';
const AWS = require('aws-sdk');
const EMAIL = require('./mail.js');
exports.handler = (event, context, callback) => {
//HERE YOUR CODE
EMAIL.send();
callback(null, ':)');
};
@diegofcornejo
diegofcornejo / invalidate_cloudfront_distributions.sh
Last active May 7, 2019 04:18
Invalidate Multiple AWS Cloudfront Distributions
#!/bin/bash
distributions=( EVJDT**** E3UI4***** E*****0X1FHL E26R******* ******RIN9KGU)
for i in "${distributions[@]}"
do
aws cloudfront create-invalidation --distribution-id $i --paths "/*" --profile yourProfile
done
#Remember add permision for execute and use "./invalidate_distributions.sh" not "sh invalidate_distributions.sh" because sh doesn't support array
@diegofcornejo
diegofcornejo / docker_certbot_manual.sh
Last active February 14, 2022 21:40
Generate Letsencrypt cert using Docker certbot image in manual mode
# Pull docker certbot image
docker pull certbot/certbot
# Create a dir for mount in containers, and save letsencrypt folders
mkdir letsencrypt # or any name you want
# Run a container and follow the instructions
docker run -it --rm -v "$PWD"/letsencrypt:/etc/letsencrypt certbot/certbot certonly --manual -d yourdomain.com
@diegofcornejo
diegofcornejo / install_node_aarch64.sh
Last active October 6, 2021 23:59
Install Node JS & forever on AWS EC2 aarch64 - A1 & T4G Instances
#!/bin/bash
VERSION=6.17.1
curl -O https://nodejs.org/dist/v$VERSION/node-v$VERSION-linux-arm64.tar.xz
tar -xvf node-v$VERSION-linux-arm64.tar.xz
cd node-v$VERSION-linux-arm64
sudo cp -R * /usr/local/
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
npm install -g forever
@diegofcornejo
diegofcornejo / node_dynamodb_xlsx.js
Created February 20, 2019 03:46
Create XLSX based on DynamoDB scan
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
const json2xls = require('json2xls');
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.update({
region: "us-east-1",
});