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 / send_email_to_multiple_recipients.py
Created December 22, 2021 00:09
Python send email to multiple recipients with smtplib
"""*********************************************************
-------------- Use example ---------------
from helpers.notifier import Notification
Notification.mail('Python notification message',['[email protected]', '[email protected]'])
# Notification.mail('Python notification message','[email protected],[email protected]')
**********************************************************"""
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@diegofcornejo
diegofcornejo / index.js
Created December 24, 2021 02:31
Send bulk html emails based on xlsx file
const axios = require('axios');
const readXlsxFile = require('read-excel-file/node');
const MAIL = require('./mail');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@diegofcornejo
diegofcornejo / jsonTocsv.py
Last active January 12, 2022 03:18
Python: generate csv file from json, fetch json example.
"""*********************************************************
Service: Generate csv from json request
------- Use example ---------------
from helpers.request import Request
params = {
'page':1,
'size':100,
'month':12,
'year':2021
}
@diegofcornejo
diegofcornejo / index.js
Created February 4, 2022 04:51
ThirdWeb - Mint NFT using NodeJS
const { ThirdwebSDK } = require('@3rdweb/sdk');
const { ethers } = require("ethers");
const fs = require('fs');
const request = require('./request');
const getUnsplashImg = async () => {
let img = await request.unsplash();
img = JSON.parse(img);
return img.urls.small;
@diegofcornejo
diegofcornejo / metamask_verifier.js
Created February 4, 2022 05:15
Metamask ETH - NodeJS Signature verifier
const ethSigUtil = require("@metamask/eth-sig-util");
const address = '0x0';
const message = 'Hi I am 0x0';
const signature = '0x0';
let checkSignature = (data, signature) => {
const params = {
data,
signature
@diegofcornejo
diegofcornejo / 1_WriteInTheBlockchain.sol
Last active February 6, 2022 05:36
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
contract RandomTestContract{
string text;
function write(string calldata _text) public{
text = _text;
}
@diegofcornejo
diegofcornejo / application.properties
Last active August 7, 2022 01:10
PKG ExpressJS example
PORT=4000
API_PROTOCOL=https
API_HOST=localhost
API_PORT=4001
API_VERSION=v1
@diegofcornejo
diegofcornejo / README.md
Last active November 13, 2022 06:40
Rust vs JavaScript - Sort array number

Rust vs JavaScript - Sort array number

Rust

This is a cargo project, you need to compile before use

cargo build --release

Or just use

cargo run --release -- 1000000

JavaScript

This project use Node 16 or later

@diegofcornejo
diegofcornejo / index.js
Created October 15, 2022 03:01
AWS Lambda - Automate Elastic IP assignation to new created EC2 instance
const AWS = require('aws-sdk');
const EC2 = new AWS.EC2();
exports.handler = (event, context, callback) => {
const done = function(response) {
callback(null, response);
};
const message = JSON.parse(event.Records[0].Sns.Message);
console.log(message);
const describeAddressesParams = {
@diegofcornejo
diegofcornejo / index.js
Created October 15, 2022 03:07
AWS Lambda - APIGateway create API Key and Usage plan key
'use strict';
var AWS = require('aws-sdk');
var apigateway = new AWS.APIGateway();
var docClient = new AWS.DynamoDB.DocumentClient();
function generateApiKey() {
return 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[x]/g, function(c) {
var r = Math.random() * 36 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(36);