From 6e8c324867578094ce777fbf8aa7abc3c107a446 Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 4 Jan 2021 16:40:21 -0800 Subject: [PATCH] Add years, change to good functions --- .eslintcache | 2 +- .gitignore | 1 + src/components/AboutMe.tsx | 132 ++++++++++++++++------- src/components/Footer.tsx | 2 +- src/components/Header.tsx | 4 +- src/components/Home.tsx | 6 +- src/components/Main.tsx | 4 +- src/components/ProjectGrid.tsx | 189 ++++++++++++++++----------------- src/components/Resume.tsx | 10 +- 9 files changed, 200 insertions(+), 150 deletions(-) diff --git a/.eslintcache b/.eslintcache index 221927d..80acea3 100644 --- a/.eslintcache +++ b/.eslintcache @@ -1 +1 @@ -[{"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\index.tsx":"1","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\reportWebVitals.ts":"2","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\App.tsx":"3","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Header.tsx":"4","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Home.tsx":"5","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Main.tsx":"6","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Contact.tsx":"7","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Resume.tsx":"8","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\ProjectGrid.tsx":"9","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\cusotmHooks.ts":"10","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Footer.tsx":"11","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\AboutMe.tsx":"12"},{"size":579,"mtime":1609726036012,"results":"13","hashOfConfig":"14"},{"size":440,"mtime":1609726036016,"results":"15","hashOfConfig":"14"},{"size":384,"mtime":1609726035985,"results":"16","hashOfConfig":"14"},{"size":1395,"mtime":1609726035988,"results":"17","hashOfConfig":"14"},{"size":235,"mtime":1609726035991,"results":"18","hashOfConfig":"14"},{"size":440,"mtime":1609726035998,"results":"19","hashOfConfig":"14"},{"size":142,"mtime":1609726035985,"results":"20","hashOfConfig":"14"},{"size":132,"mtime":1609726035991,"results":"21","hashOfConfig":"14"},{"size":9607,"mtime":1609727699395,"results":"22","hashOfConfig":"14"},{"size":1072,"mtime":1609462531624,"results":"23","hashOfConfig":"14"},{"size":1241,"mtime":1609726035990,"results":"24","hashOfConfig":"14"},{"size":5418,"mtime":1609726035984,"results":"25","hashOfConfig":"14"},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},"lcbj9u",{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"31","messages":"32","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"45","messages":"46","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"49","messages":"50","errorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":"51","usedDeprecatedRules":"28"},"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\index.tsx",[],["52","53"],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\reportWebVitals.ts",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\App.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Header.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Home.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Main.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Contact.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Resume.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\ProjectGrid.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\cusotmHooks.ts",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Footer.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\AboutMe.tsx",["54","55","56","57","58"],"import \"./AboutMe.scss\";\r\nimport { Link } from \"react-router-dom\";\r\nimport { Tooltip } from \"antd\";\r\nimport { useState, useEffect } from \"react\";\r\nimport axios from \"axios\";\r\n\r\nconst TelegramOutlinedSvg = () => {\r\n return (\r\n \r\n \r\n \r\n );\r\n};\r\n\r\nconst LastFmLi = () => {\r\n const [nowPlayingSong, setNowPlayingSong] = useState(\"nothing\");\r\n const [nowPlayingArtist, setNowPlayingArtist] = useState(\"no-one\");\r\n\r\n const updateNowPlaying = async () => {\r\n try {\r\n const songData = await axios.get(\r\n \"https://jsonplaceholder.typicode.com/posts\"\r\n );\r\n\r\n console.log(songData.data);\r\n } catch (err) {\r\n console.error(err);\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n updateNowPlaying();\r\n\r\n const interval = setInterval(updateNowPlaying, 10000);\r\n\r\n return () => {\r\n clearInterval(interval);\r\n };\r\n }, []);\r\n return
  • listening to ____ by ____
  • ;\r\n};\r\n\r\nconst Age = () => {\r\n const [age, setAge] = useState(\r\n Math.round((new Date().getTime() - 1021004428000) / 1000)\r\n );\r\n\r\n const UpdateAge = () => {\r\n setAge(Math.round((new Date().getTime() - 1021004428000) / 1000));\r\n };\r\n\r\n useEffect(() => {\r\n UpdateAge();\r\n\r\n const interval = setInterval(UpdateAge, 1000);\r\n\r\n return () => {\r\n clearInterval(interval);\r\n };\r\n }, []);\r\n\r\n return (\r\n
  • \r\n {age} seconds old{\" \"}\r\n
  • \r\n );\r\n};\r\n\r\nexport const AboutMe = () => {\r\n const EmailHandler = () => {\r\n const email = \"Y29udGFjdEBqYWtlY292ZXIubWU=\";\r\n window.prompt(\"Thanks for being a human! Here's my email:\", atob(email));\r\n };\r\n\r\n return (\r\n
    \r\n
    \r\n

    Hi! I'm Jake!

    \r\n\r\n
    \r\n
    \r\n

    A bit about me:

    \r\n\r\n
      \r\n
    • \r\n Name: Jake Cover\r\n
    • \r\n
    • Occupation: Student
    • \r\n
    • Location: Southern California
    • \r\n
    • \r\n Projects:{\" \"}\r\n \r\n document.getElementById(\"project-header\")?.scrollIntoView({\r\n behavior: \"smooth\",\r\n block: \"start\",\r\n })\r\n }\r\n >\r\n Down there\r\n \r\n
    • \r\n
    • \r\n Resume: Over here\r\n
    • \r\n
    • \r\n Find Me:\r\n
        \r\n
      • \r\n Email: \r\n
      • \r\n
      • \r\n Twitter:{\" \"}\r\n \r\n \r\n @cobular_\r\n \r\n \r\n
      • \r\n
      • \r\n GitHub:{\" \"}\r\n \r\n JakeCover\r\n \r\n
      • \r\n
      • \r\n Telegram:{\" \"}\r\n \r\n @cobular\r\n \r\n
      • \r\n
      • Elsewhere: Probably @cobular
      • \r\n
      \r\n
    • \r\n
    \r\n
    \r\n
    \r\n

    I'm:

    \r\n
      \r\n \r\n \r\n
    • \r\n doing (general stuff - in class, projects, sleeping, games)\r\n
    • \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n );\r\n};\r\n",{"ruleId":"59","replacedBy":"60"},{"ruleId":"61","replacedBy":"62"},{"ruleId":"63","severity":1,"message":"64","line":7,"column":7,"nodeType":"65","messageId":"66","endLine":7,"endColumn":26},{"ruleId":"63","severity":1,"message":"67","line":30,"column":10,"nodeType":"65","messageId":"66","endLine":30,"endColumn":24},{"ruleId":"63","severity":1,"message":"68","line":30,"column":26,"nodeType":"65","messageId":"66","endLine":30,"endColumn":43},{"ruleId":"63","severity":1,"message":"69","line":31,"column":10,"nodeType":"65","messageId":"66","endLine":31,"endColumn":26},{"ruleId":"63","severity":1,"message":"70","line":31,"column":28,"nodeType":"65","messageId":"66","endLine":31,"endColumn":47},"no-native-reassign",["71"],"no-negated-in-lhs",["72"],"@typescript-eslint/no-unused-vars","'TelegramOutlinedSvg' is assigned a value but never used.","Identifier","unusedVar","'nowPlayingSong' is assigned a value but never used.","'setNowPlayingSong' is assigned a value but never used.","'nowPlayingArtist' is assigned a value but never used.","'setNowPlayingArtist' is assigned a value but never used.","no-global-assign","no-unsafe-negation"] \ No newline at end of file +[{"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\index.tsx":"1","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\reportWebVitals.ts":"2","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\App.tsx":"3","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Header.tsx":"4","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Home.tsx":"5","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Main.tsx":"6","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Contact.tsx":"7","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Resume.tsx":"8","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\ProjectGrid.tsx":"9","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\cusotmHooks.ts":"10","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Footer.tsx":"11","C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\AboutMe.tsx":"12"},{"size":579,"mtime":1609726036012,"results":"13","hashOfConfig":"14"},{"size":440,"mtime":1609726036016,"results":"15","hashOfConfig":"14"},{"size":384,"mtime":1609726035985,"results":"16","hashOfConfig":"14"},{"size":1336,"mtime":1609807151229,"results":"17","hashOfConfig":"14"},{"size":221,"mtime":1609807151240,"results":"18","hashOfConfig":"14"},{"size":420,"mtime":1609807160871,"results":"19","hashOfConfig":"14"},{"size":142,"mtime":1609726035985,"results":"20","hashOfConfig":"14"},{"size":115,"mtime":1609807173240,"results":"21","hashOfConfig":"14"},{"size":9326,"mtime":1609807151251,"results":"22","hashOfConfig":"14"},{"size":1072,"mtime":1609462531624,"results":"23","hashOfConfig":"14"},{"size":1238,"mtime":1609806284783,"results":"24","hashOfConfig":"14"},{"size":5997,"mtime":1609806409462,"results":"25","hashOfConfig":"14"},{"filePath":"26","messages":"27","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},"lcbj9u",{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"31","messages":"32","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"28"},{"filePath":"45","messages":"46","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"47","messages":"48","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"49","messages":"50","errorCount":0,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\index.tsx",[],["51","52"],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\reportWebVitals.ts",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\App.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Header.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Home.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Main.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Contact.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Resume.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\ProjectGrid.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\cusotmHooks.ts",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\Footer.tsx",[],"C:\\Users\\jdc10\\Documents\\GitHub\\PersonalWebsite_Static\\src\\components\\AboutMe.tsx",["53","54","55","56","57"],{"ruleId":"58","replacedBy":"59"},{"ruleId":"60","replacedBy":"61"},{"ruleId":"62","severity":1,"message":"63","line":8,"column":10,"nodeType":"64","messageId":"65","endLine":8,"endColumn":24},{"ruleId":"62","severity":1,"message":"66","line":8,"column":26,"nodeType":"64","messageId":"65","endLine":8,"endColumn":43},{"ruleId":"62","severity":1,"message":"67","line":9,"column":10,"nodeType":"64","messageId":"65","endLine":9,"endColumn":26},{"ruleId":"62","severity":1,"message":"68","line":9,"column":28,"nodeType":"64","messageId":"65","endLine":9,"endColumn":47},{"ruleId":"69","severity":1,"message":"70","line":115,"column":6,"nodeType":"71","endLine":115,"endColumn":8,"suggestions":"72"},"no-native-reassign",["73"],"no-negated-in-lhs",["74"],"@typescript-eslint/no-unused-vars","'nowPlayingSong' is assigned a value but never used.","Identifier","unusedVar","'setNowPlayingSong' is assigned a value but never used.","'nowPlayingArtist' is assigned a value but never used.","'setNowPlayingArtist' is assigned a value but never used.","react-hooks/exhaustive-deps","React Hook useEffect has a missing dependency: 'UpdateAge'. Either include it or remove the dependency array.","ArrayExpression",["75"],"no-global-assign","no-unsafe-negation",{"desc":"76","fix":"77"},"Update the dependencies array to be: [UpdateAge]",{"range":"78","text":"79"},[2826,2828],"[UpdateAge]"] \ No newline at end of file diff --git a/.gitignore b/.gitignore index 544310f..060fa2e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Created by https://www.toptal.com/developers/gitignore/api/react,webstorm # Edit at https://www.toptal.com/developers/gitignore?templates=react,webstorm build +.eslintcache ### react ### .DS_* diff --git a/src/components/AboutMe.tsx b/src/components/AboutMe.tsx index 4370975..4eb944c 100644 --- a/src/components/AboutMe.tsx +++ b/src/components/AboutMe.tsx @@ -4,33 +4,11 @@ import { Tooltip } from "antd"; import { useState, useEffect } from "react"; import axios from "axios"; -const TelegramOutlinedSvg = () => { - return ( - - - - ); -}; - -const LastFmLi = () => { +function LastFmLi() { const [nowPlayingSong, setNowPlayingSong] = useState("nothing"); const [nowPlayingArtist, setNowPlayingArtist] = useState("no-one"); - const updateNowPlaying = async () => { + async function updateNowPlaying() { try { const songData = await axios.get( "https://jsonplaceholder.typicode.com/posts" @@ -40,7 +18,7 @@ const LastFmLi = () => { } catch (err) { console.error(err); } - }; + } useEffect(() => { updateNowPlaying(); @@ -54,19 +32,82 @@ const LastFmLi = () => { return
  • listening to ____ by ____
  • ; }; -const Age = () => { - const [age, setAge] = useState( - Math.round((new Date().getTime() - 1021004428000) / 1000) - ); - - const UpdateAge = () => { - setAge(Math.round((new Date().getTime() - 1021004428000) / 1000)); - }; +function Age() { + // Accounts for leap years and stuff + function milliseconds_year() { + const dateObj = new Date(); + const dateInit = Math.round( + new Date(dateObj.getFullYear(), 0, 1).getTime() + ); + const dateEnd = Math.round( + new Date(dateObj.getFullYear(), 11, 31, 23, 59, 59, 999).getTime() + ); + return dateEnd - dateInit; + } + + function searchSternBorcotTree( + target: number, + left_n: number, + left_d: number, + right_n: number, + right_d: number, + count: number = 0 + ): [number, number] { + count++; + const center_n: number = left_n + right_n; + const center_d: number = left_d + right_d; + // Check to see if we've gone too deep + if (count > 25) return [center_n, center_d]; + // Check to see if we're close enough to the target + if (Math.abs(target - (center_n / center_d)) > 0.001) { + // Look right down the tree + if (target > (center_n / center_d)) + return searchSternBorcotTree( + target, + center_n, + center_d, + right_n, + right_d, + count + ); + // Ok now look left + return searchSternBorcotTree( + target, + left_n, + left_d, + center_n, + center_d, + count + ); + } + return [center_n, center_d]; + } + + function CalcAge() { + let ageMs = new Date().getTime() - 1021004428000; + const yearMs = milliseconds_year(); + const ageYearsComponent = Math.floor(ageMs / yearMs); + const ageSecondsComponent = Math.floor((ageMs % yearMs) / 1000); + const [target_n, target_d] = searchSternBorcotTree( + ageSecondsComponent / (yearMs / 1000), + 0, + 1, + 1, + 1 + ); + return `${ageYearsComponent} and ${target_n}/${target_d}`; + } + + const [age, setAge] = useState(CalcAge()); + + function UpdateAge() { + setAge(CalcAge()); + } useEffect(() => { UpdateAge(); - const interval = setInterval(UpdateAge, 1000); + const interval = setInterval(UpdateAge, 5000); return () => { clearInterval(interval); @@ -75,16 +116,16 @@ const Age = () => { return (
  • - {age} seconds old{" "} + {age} years old
  • ); }; -export const AboutMe = () => { - const EmailHandler = () => { +export function AboutMe() { + function EmailHandler() { const email = "Y29udGFjdEBqYWtlY292ZXIubWU="; window.prompt("Thanks for being a human! Here's my email:", atob(email)); - }; + } return (
    @@ -164,9 +205,18 @@ export const AboutMe = () => {

    I'm:

      - + + +
    • + doing (general stuff - in class, projects, sleeping, games) +
    • +
    • - doing (general stuff - in class, projects, sleeping, games) + rather colorblind
    @@ -174,4 +224,4 @@ export const AboutMe = () => { ); -}; +} diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 4ee8cca..f950a35 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -2,7 +2,7 @@ import "./Footer.scss" import { Link } from "react-router-dom"; -export const Footer = () => { +export function Footer() { return (