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
| package main | |
| // these are the packages we are importing | |
| // if you import it you gotta use it | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/smtp" | |
| "os" |
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
| useInterval(() => { | |
| // Your custom logic here | |
| if (isActive) { | |
| youtubeLiveViewCount() | |
| } else return null | |
| }, timer) |
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 youtubeLiveViewCount = () => { | |
| // https://developers.google.com/youtube/v3/docs/videos/list?apix=true#parameters | |
| return gapi.client.youtube.videos | |
| .list({ | |
| part: ['statistics'], | |
| id: youtubeBroadcastId, | |
| }) | |
| .then( | |
| function (res) { |
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 express = require('express'), | |
| router = express.Router(), | |
| { default: axios } = require('axios') | |
| require('dotenv').config() | |
| router.post('/api/youtube/view-count', async (req, res) => { | |
| // https://developers.google.com/youtube/v3/docs/videos/list?apix=true&apix_params=%7B%22part%22%3A%5B%22statistics%2C%20status%22%5D%2C%22id%22%3A%5B%22_IrFoihwTUc%22%5D%7D#parameters | |
| const youtubeBroadcastId = req.body.youtubeBroadcastId |
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 express = require('express'), | |
| router = express.Router(), | |
| { default: axios } = require('axios') | |
| require('dotenv').config() | |
| router.post('/api/twitch/view-count', async (req, res) => { | |
| // twitch forum: https://discuss.dev.twitch.tv/t/viewer-counter-help/24726/2 | |
| // https://discuss.dev.twitch.tv/t/getting-stream-viewer-count-webhook-notifications/20645/5 |
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
| useInterval(() => { | |
| // Your custom logic here | |
| if (isActive) { | |
| API.post('/twitch/view-count', { | |
| twitchUsername: twitchUsername, | |
| twitchAccessToken: twitchAccessToken, | |
| }) | |
| .then((res) => { | |
| console.log(res.data.number) | |
| if (res.data.number) settwitchViewCount(res.data.number) |
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, { useEffect, useRef } from 'react' | |
| // https://overreacted.io/making-setinterval-declarative-with-react-hooks/ | |
| function useInterval(callback, delay) { | |
| const savedCallback = useRef() | |
| // Remember the latest callback. | |
| useEffect(() => { | |
| savedCallback.current = callback |
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, { useState } from 'react' | |
| import TextInput from '../../components/TextInput/TextInput' | |
| import Button from '../../components/Buttons/Button' | |
| import { Link, useHistory } from 'react-router-dom' | |
| import API from '../../api/api' | |
| import './Register.css' | |
| import setCookie from '../../utils/setCookie' | |
| function Register() { | |
| const [email, setEmail] = useState('') |
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, { useState, useEffect } from 'react' | |
| import { Link, useHistory, useLocation } from 'react-router-dom' | |
| import API from '../../api/api' | |
| import TextInput from '../../components/TextInput/TextInput' | |
| import Button from '../../components/Buttons/Button' | |
| import setCookie from '../../utils/setCookie' | |
| import './Login.css' | |
| function Login() { | |
| const [email, setEmail] = useState('') |
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 timeFromUserRegistration = (dateUserRegistered) => { | |
| // example of dateUserRegistered = '2021-07-30T05:05:27.000Z' | |
| const userDataRegistered = Date.parse(dateUserRegistered) | |
| const currDate = Date.parse(new Date()) | |
| const dateDiff = currDate - userDataRegistered | |
| console.log(dateDiff) | |
| const days = dateDiff / (60 * 60 * 24 * 1000) | |
| return days |