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 / jdbc_connection
Created October 15, 2021 16:32
Java test oracle db connection
https://dba010.com/2019/09/30/simpe-java-code-to-test-connection-to-oracle-database/
Assuming that client computer does not have Oracle client installed.
1. Download necessary version of ojdbc jar file from Oracle. The latest version for now is ojdbc8.jar
2. Install java development tools:
# yum install java-devel * -y
3. Create a sample java code, which:
@diegofcornejo
diegofcornejo / dynamodb_query.js
Created October 12, 2021 17:18
Lambda - Query DynamoDB items between ISO dates
const AWS = require('aws-sdk');
const REGION = 'us-east-1';
const DYNAMODB = new AWS.DynamoDB.DocumentClient();
const TABLE = "ttn-events";
exports.handler = async(event) => {
var date = new Date();
//dates should be obtained from request
var end = date.toISOString();
var start = new Date(date.setDate(date.getDate()-7)).toISOString();
@diegofcornejo
diegofcornejo / init.sh
Last active May 10, 2023 17:22
AWS EC2 User data (init script) for Linux AMI 2 ARM A1 or T4G instances
#!/bin/bash
REPO="your-repo"
OWNER="diegofcornejo"
TOKEN="github_developer_token"
APPDIR="/home/ec2-user"
NODE_VERSION="12.16.3"
cd $APPDIR
touch init.log
echo 'Updating OS' >> init.log
yum update -y
@diegofcornejo
diegofcornejo / System Design.md
Created October 6, 2021 19:29 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@diegofcornejo
diegofcornejo / discord.js
Created October 6, 2021 03:55
Discord get all members in a guild (server)
const { Client, Intents } = require('discord.js');
// const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });
const client = new Client({ intents: [Intents.FLAGS.GUILD_MEMBERS] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
const guild = client.guilds.cache.get('GUILD_ID');
// Fetch and get the list named 'members'
guild.members.fetch().then(members => {
@diegofcornejo
diegofcornejo / send_mail.py
Last active December 22, 2021 00:03
Python send email with smtplib
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
mail_content = '''Hello,
This is a simple mail.
There is only text, no attachments are there The mail is sent using Python SMTP library.
Thank You
'''
#The mail addresses and password
@diegofcornejo
diegofcornejo / Discord Github Webhook Tutorial.md
Last active September 8, 2021 20:33 — forked from jagrosh/Github Webhook Tutorial.md
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@diegofcornejo
diegofcornejo / decodeAxioma.js
Created September 7, 2021 00:27 — forked from Alkarex/decodeAxioma.js
Node-RED function to decode Axioma water meter payloads.
/* jshint esversion:6, bitwise:false, node:true, strict:true */
/* globals msg */
"use strict";
/**
* Node-RED function to decode Axioma water meter payloads.
* Example assuming that msg.req.body contains an HTTP POST callback from The Things Networks.
*/
function statusAxiomaShort(s) {
const messages = [];
@diegofcornejo
diegofcornejo / index.js
Created March 12, 2021 05:36
Generate charts inside xlsx doc with node
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var fs = require("fs");
//===================================
var XLSXChart = require("xlsx-chart");
var xlsxChart = new XLSXChart();
var opts = {
@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__)