Skip to content

Instantly share code, notes, and snippets.

View nosvalds's full-sized avatar
🚀
Learning all the things

Nik Osvalds nosvalds

🚀
Learning all the things
View GitHub Profile
@nosvalds
nosvalds / AuthController.js
Last active October 18, 2020 13:50
forgot password controller function
const table = process.env.USERS_TABLE;
const fs = require('fs');
const fsPromises = fs.promises;
const Handlebars = require("handlebars");
// AWS
const AWS = require('aws-sdk')
const dynamodb = new AWS.DynamoDB.DocumentClient();
const ses = new AWS.SES({region: 'us-east-1'}); // Simple email service
@nosvalds
nosvalds / index.js
Created October 18, 2020 12:42
Express route definitions for password workflows
// Auth password routes
app.post(`/auth/forgot-password`, AuthController.forgotPassword);
app.post(`/auth/reset-password`, AuthController.resetPassword);
app.post(`/auth/update-password`, passport.authenticate('jwt', { session: false }), AuthController.updatePassword)
@nosvalds
nosvalds / API_Reponses.js
Last active September 10, 2020 08:59
DigitalHumani Tree Report Lambda Function
const Responses = {
_200(data = {}){
return {
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Origin': '*',
},
statusCode: 200,
body: JSON.stringify(data)
@nosvalds
nosvalds / index.html
Created August 24, 2020 13:14
HTML snippet from my portfolio of Pixel Perfect's Medium Widget
<!DOCTYPE html>
<html lang="en">
<head>
<!-- title and description -->
<meta name="description" content="Nikolas Osvalds personal web development portfolio website">
<title>Nik Osvalds - Home</title>
<meta property="og:image" content="https://www.nikolaso.com/images/photos/thumbnail.jpeg"/>
<!-- custom JS -->
<script defer src="./js/scripts.js"></script>
@nosvalds
nosvalds / scripts.js
Created August 24, 2020 12:57
Selecting and logging one element using a MutationObserver
((d, w) => {
// select the static HTML element that all this DOM manipulation will be contained to
let widget = d.getElementById("medium-widget");
const mainImgObserver = new MutationObserver(() => {
// if these elements have been rendered in the DOM
if (widget.getElementsByClassName("medium-widget-article__image").length > 0) {
// get the <a> link elements from the DOM, then map to get the child <img> elements
console.log(widget.getElementsByClassName("medium-widget-article__image"))
// stop observing
@nosvalds
nosvalds / scripts.js
Last active August 24, 2020 12:35
Medium Widget Alt Text Addition
((d, w) => {
// select the static HTML element that all this DOM manipulation will be contained to
let widget = d.getElementById("medium-widget");
const mainImgObserver = new MutationObserver(() => {
// if these elements have been rendered in the DOM
if (widget.getElementsByClassName("medium-widget-article__image").length > 0) {
// get the <a> link elements from the DOM, then map to get the child <img> elements
let imgElements = Array.from(widget.getElementsByClassName("medium-widget-article__image"))
.map((a) => a.firstElementChild);
// get the article description elements, then map to get the textConent of those elements