Skip to content

Instantly share code, notes, and snippets.

View rickhernandezio's full-sized avatar
🎯
Focusing

Rick Hernandez rickhernandezio

🎯
Focusing
View GitHub Profile
@rickhernandezio
rickhernandezio / event.js
Last active February 9, 2018 02:11
Custom JavaScript
var ValidateElements;
$(document).ready(function () {
var occurrence = $('.BBListingHeading h1').text().replace(/\s/g, '').split('|');
occurrence = (occurrence.length - 1);
if (occurrence == 3) { // Passes 3 bar test
/* Remove divMemberOnlyInfo h3 element if empty */
var memberOnlyInfo = $('.divMemberOnlyInfo h3').text().replace(/\s/g, '');
if (memberOnlyInfo.length == 0) {
$('.divMemberOnlyInfo h3').hide();
@rickhernandezio
rickhernandezio / Cognito.js
Created January 28, 2018 17:23
Log user in using Cognito
const authenticationData = {
Username: user.email,
Password: user.password,
};
const authenticationDetails = new AuthenticationDetails(authenticationData);
const userData = {
Username: user.email,
Pool: this.userPool
};
const cognitoUser = new CognitoUser(userData);
@rickhernandezio
rickhernandezio / cognito.js
Created January 28, 2018 17:20
How to authenticate users with Tokens using Cognito
const AccessToken = new CognitoAccessToken({ AccessToken: tokens.accessToken });
const IdToken = new CognitoIdToken({ IdToken: tokens.idToken });
const RefreshToken = new CognitoRefreshToken({ RefreshToken: tokens.refreshToken });
const sessionData = {
IdToken: IdToken,
AccessToken: AccessToken,
RefreshToken: RefreshToken
};
const userSession = new CognitoUserSession(sessionData);
@rickhernandezio
rickhernandezio / Encrypt and Decrypt Objects.js
Created January 22, 2018 01:02
Encrypt and Decrypt Objects.js
const Encrypted = '36d435ec6268244a209c1d3b5b8d12c7838f604fc907519e8e75583f1c12902f62e5da4905bea381326b893fc750c9ca913bd6d8cd9cdb13ba541329399100989ac22dfa10ab2cf9784ee8183c55fa96'
const Decrypted = mailPro.decrypt(user);
// Results -> { username: 'brandy19', age: 23, sex: 'female', balance: 3339.03 }
@rickhernandezio
rickhernandezio / Encrypt and Decrypt Objects.js
Created January 22, 2018 01:02
Encrypt and Decrypt Objects.js
const user = {
username: 'brandy19',
age: 23,
sex: 'female',
balance: 3339.03
}
const Encrypted = mailPro.encrypt(user);
@rickhernandezio
rickhernandezio / Validate an email address for validity.js
Created January 22, 2018 01:01
Validate an email address for validity
const email = 'example@example.com';
mailPro.validateEmail(email).then(valid => {});
@rickhernandezio
rickhernandezio / Update a selected subscriber from a selected mailing list.js
Last active January 22, 2018 01:00
Update a selected subscriber from a selected mailing list
const user = {
address: 'example@example.com',
name: 'Brandy',
vars: {} /* Variables you want to save */
};
const list = 'mailing-list@domain.com';
mailPro.updateSubscriber(list, user).then(result => {});
@rickhernandezio
rickhernandezio / Create a subscriber for a selected mailing list.js
Created January 22, 2018 00:59
Create a subscriber for a selected mailing list
const user = {
address: 'example@example.com',
name: 'Brandy',
vars: {} /* Variables you want to save */
};
const list = 'mailing-list@domain.com';
mailPro.createSubscriber(list, user).then(result => {});
mailPro.getSubscribers('mailing-list@domain.com').then(result => {});