This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private restrictedWords(words) { | |
return (control: FormControl): {[key: string]: any} => { | |
if (!words ) { return null; } | |
const invalidWords = words | |
.map(word => control.value.includes(word) ? word : null) | |
.filter(word => word != null); | |
return invalidWords && invalidWords.length > 0 | |
? { restrictedWords: invalidWords.join(', ')} | |
: null; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Resources: | |
CognitoUserPool: | |
Type: "AWS::Cognito::UserPool" | |
Description: "A Cognito user pool for authenticating users" | |
Properties: | |
UserPoolName: "NgAppUserPool" | |
UsernameAttributes: [email, phone_number] # Allow both email or phone number to user can sign in / sign up | |
Schema: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function closestByClass(el, className) { | |
while(!el.classList.contains(className)) { | |
el = el.parentNode; | |
if (!el) { | |
return null; | |
} | |
} | |
return el; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const f1 = h => h.title.toLowerCase().includes(title.toLowerCase()); | |
const f2 = d => d.field_category.toLowerCase().includes(category.toLowerCase()); | |
const f3 = e => e.uid.toLowerCase().includes(author.toLowerCase()); | |
const filtered = nodes.filter(f1).filter(f2).filter(f3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEmpty = value => | |
value === undefined || | |
value === null || | |
(typeof value === "object" && Object.keys(value).length === 0) || | |
(typeof value === "string" && value.trim().length === 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createStore(reducer) { | |
// Store should have 4 parts. | |
// 1. The state. | |
// 2. Get the state. | |
// 3. Listen to state change. | |
// 4. Update the state. | |
let state; | |
let listeners = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlEscape(str) { | |
return str.replace(/>/g,'&') | |
.replace(/</g,'>') | |
.replace(/"/g,'<') | |
.replace(/'/g,'"') | |
.replace(/`/g,''') | |
.replace(/`/g,'`'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import './App.css'; | |
import { AuthProvider } from './Hoc/AuthProvider/AuthProvider'; | |
import Login from './Containers/Login/Login'; | |
import ProtectedRoute from './Components/ProtectedRoute/ProtectedRoute'; | |
class App extends Component { | |
render() { | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MomentJS library. | |
// Filter array and get only items that are from today (date). | |
var getTodayEvents = someArray.filter(todayDate => moment(todayDate.start.format("YYYY-MM-DD")).isSame(moment().format("YYYY-MM-DD"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Async await func | |
async function getTimelineData() { | |
var response = await fetch('/some-api-url') | |
return response.json() | |
} | |
async function populateTimelineInit() { | |
var data = await getTimelineData(); | |
new vis.DataSet(data); |
NewerOlder