From 1e999368ac665998c9bebd8195e267d5a9ad6b5e Mon Sep 17 00:00:00 2001 From: Alex Hyett Date: Fri, 4 Oct 2024 14:13:56 +0100 Subject: [PATCH] Update code --- 2022-11-25-Stack-Vs-Heap/Example1/Program.cs | 29 ------- .../Example1/StackVsHeap1.csproj | 11 --- 2022-11-25-Stack-Vs-Heap/Example2/Program.cs | 34 -------- .../Example2/StackVsHeap2.csproj | 11 --- 2022-11-25-Stack-Vs-Heap/Example3/Program.cs | 34 -------- .../Example3/StackVsHeap3.csproj | 11 --- 2022-11-25-Stack-Vs-Heap/Example4/Program.cs | 44 ---------- .../Example4/StackVsHeap4.csproj | 11 --- README.md | 5 +- youtube-code.sln | 81 +++++++++++++++++++ 10 files changed, 85 insertions(+), 186 deletions(-) delete mode 100644 2022-11-25-Stack-Vs-Heap/Example1/Program.cs delete mode 100644 2022-11-25-Stack-Vs-Heap/Example1/StackVsHeap1.csproj delete mode 100644 2022-11-25-Stack-Vs-Heap/Example2/Program.cs delete mode 100644 2022-11-25-Stack-Vs-Heap/Example2/StackVsHeap2.csproj delete mode 100644 2022-11-25-Stack-Vs-Heap/Example3/Program.cs delete mode 100644 2022-11-25-Stack-Vs-Heap/Example3/StackVsHeap3.csproj delete mode 100644 2022-11-25-Stack-Vs-Heap/Example4/Program.cs delete mode 100644 2022-11-25-Stack-Vs-Heap/Example4/StackVsHeap4.csproj create mode 100644 youtube-code.sln diff --git a/2022-11-25-Stack-Vs-Heap/Example1/Program.cs b/2022-11-25-Stack-Vs-Heap/Example1/Program.cs deleted file mode 100644 index 148b6c6..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example1/Program.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; - -namespace StackVsHeap1 -{ - internal class Program - { - static void Main(string[] args) - { - var dateOfBirth = new DateTime(1987, 05, 01); - var age = CalculateAge(dateOfBirth); - - Console.WriteLine(age); - } - - private static int CalculateAge(DateTime dateOfBirth) - { - var today = DateTime.Today; - var age = today.Year - dateOfBirth.Year; - - if (dateOfBirth.Date > today.AddYears(-age)) - age--; - - return age; - } - } -} - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example1/StackVsHeap1.csproj b/2022-11-25-Stack-Vs-Heap/Example1/StackVsHeap1.csproj deleted file mode 100644 index 0ca377e..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example1/StackVsHeap1.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net7.0 - StackVsHeap1 - disable - enable - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example2/Program.cs b/2022-11-25-Stack-Vs-Heap/Example2/Program.cs deleted file mode 100644 index 3ffe372..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example2/Program.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace StackVsHeap2 -{ - internal class Program - { - const int MAX_AGE = 99; - - static void Main(string[] args) - { - var dateOfBirth = new DateTime(1900, 05, 01); - var age = CalculateAge(dateOfBirth); - - if (age >= MAX_AGE) - Console.WriteLine($"Are you sure you are {age}?"); - else - Console.WriteLine(age); - } - - private static int CalculateAge(DateTime dateOfBirth) - { - var today = DateTime.Today; - var age = today.Year - dateOfBirth.Year; - - if (dateOfBirth.Date > today.AddYears(-age)) - age--; - - return age; - } - } -} - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example2/StackVsHeap2.csproj b/2022-11-25-Stack-Vs-Heap/Example2/StackVsHeap2.csproj deleted file mode 100644 index bc7f20a..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example2/StackVsHeap2.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net7.0 - StackVsHeap2 - disable - enable - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example3/Program.cs b/2022-11-25-Stack-Vs-Heap/Example3/Program.cs deleted file mode 100644 index 896663e..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example3/Program.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace StackVsHeap3 -{ - internal class Program - { - static void Main(string[] args) - { - var maxAge = 99; - var dateOfBirth = new DateTime(1900, 05, 01); - var calculateAge = () => - { - var today = DateTime.Today; - var age = today.Year - dateOfBirth.Year; - - if (dateOfBirth.Date > today.AddYears(-age)) - age--; - - return age; - }; - - var age = calculateAge(); - - if (age >= maxAge) - Console.WriteLine($"Are you sure you are {age}?"); - else - Console.WriteLine(age); - } - - } -} - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example3/StackVsHeap3.csproj b/2022-11-25-Stack-Vs-Heap/Example3/StackVsHeap3.csproj deleted file mode 100644 index de7eb21..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example3/StackVsHeap3.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net7.0 - StackVsHeap3 - disable - enable - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example4/Program.cs b/2022-11-25-Stack-Vs-Heap/Example4/Program.cs deleted file mode 100644 index a1c5f51..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example4/Program.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace StackVsHeap4 -{ - internal class Program - { - static async Task Main(string[] args) - { - var dateOfBirth = new DateTime(1900, 05, 01); - var ageTask = CalculateAge(dateOfBirth); - var otherTask = DoSomethingElse(); - - await Task.WhenAll(ageTask, otherTask); - - var age = ageTask.Result; - - Console.WriteLine(age); - } - - private static async Task CalculateAge(DateTime dateOfBirth) - { - var today = DateTime.Today; - var age = today.Year - dateOfBirth.Year; - - await Task.Delay(1000); // Pretending to do work - - if (dateOfBirth.Date > today.AddYears(-age)) - age--; - - return age; - } - - - private static async Task DoSomethingElse() - { - Console.WriteLine("Doing some other work"); - await Task.Delay(2000); // Pretending to do work - } - } -} - - - diff --git a/2022-11-25-Stack-Vs-Heap/Example4/StackVsHeap4.csproj b/2022-11-25-Stack-Vs-Heap/Example4/StackVsHeap4.csproj deleted file mode 100644 index 548203d..0000000 --- a/2022-11-25-Stack-Vs-Heap/Example4/StackVsHeap4.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net7.0 - StackVsHeap4 - disable - enable - - - diff --git a/README.md b/README.md index 2bdea0b..c93814a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ # Code featured in my YouTube videos This repository contains all the code from the following YouTube videos. The code from the other videos have their own separate repository. +> [!NOTE] +> [This repository](https://code.alexhyett.com/alexhyett/youtube-code) is also mirrored on [Codeberg.org](https://codeberg.org/alexhyett/youtube-code) if you want to raise an issue. + ## Index of all the code by YouTube video and date I will add new code as soon as I am done editing the videos. So, you might find the latest on this video hasn't been released yet. | Date Published | Video | Link | | -------------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | 2022-12-09 | [Big O Notation](https://youtu.be/aIG48ldbpRI) | [code](2022-12-09-Big-O-Notation) | -| 2022-11-25 | [Stack vs Heap](https://youtu.be/5OJRqkYbK-4) | [code](2022-11-25-Stack-Vs-Heap) | +| 2022-11-25 | [Stack vs Heap](https://youtu.be/5OJRqkYbK-4) | [code](/alexhyett/stack-vs-heap) | | 2022-11-11 | [Automate Your Life With Python (File Management Step By Step Example)](https://youtu.be/1dgnl7oCVTY) | [code](2022-11-11-Automate-Your-Life-With-Python/move-photos.py) | | 2022-10-21 | [Bitwise Operators and WHY we use them](https://youtu.be/igIjGxF2J-w) | [code](2022-10-21-Bitwise-Operators-and-WHY-we-use-them) | | 2022-10-10 | [6 Coding Concepts You MUST Know For Beginners](https://youtu.be/pKFcVs2HibA) | [code](2022-10-10-6-Coding-Concepts-You-MUST-Know-For-Beginners) | diff --git a/youtube-code.sln b/youtube-code.sln new file mode 100644 index 0000000..884e989 --- /dev/null +++ b/youtube-code.sln @@ -0,0 +1,81 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2022-11-25-Stack-Vs-Heap", "2022-11-25-Stack-Vs-Heap", "{D9274304-4A5B-457C-9F94-0D43FCB34306}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackVsHeap2", "2022-11-25-Stack-Vs-Heap\Example2\StackVsHeap2.csproj", "{84D0E2A6-F29D-4E7A-A9A7-7B3B189858B4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackVsHeap4", "2022-11-25-Stack-Vs-Heap\Example4\StackVsHeap4.csproj", "{88871D7B-C1E5-40A9-99D5-C4728F4F9F34}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackVsHeap3", "2022-11-25-Stack-Vs-Heap\Example3\StackVsHeap3.csproj", "{738D63F4-EC3C-4228-8CDD-49F225D63F50}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StackVsHeap1", "2022-11-25-Stack-Vs-Heap\Example1\StackVsHeap1.csproj", "{687246E4-702E-40D2-A00F-A6D8933EFE76}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2022-12-09-Big-O-Notation", "2022-12-09-Big-O-Notation", "{44A151F1-0BBE-485D-8E61-77FCC1CB6308}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quadratic", "2022-12-09-Big-O-Notation\Quadratic\Quadratic.csproj", "{3864AA23-5A37-4E4F-9324-E68BC78B7AD4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Exponential", "2022-12-09-Big-O-Notation\Exponential\Exponential.csproj", "{3E1B73A9-BC6C-42D9-BB90-C4568753F406}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Linear", "2022-12-09-Big-O-Notation\Linear\Linear.csproj", "{EDAF8432-6D21-4FCA-84F6-1A71AA9E0237}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Constant", "2022-12-09-Big-O-Notation\Constant\Constant.csproj", "{EB616A5C-E246-4278-B75E-956D9A239D24}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {84D0E2A6-F29D-4E7A-A9A7-7B3B189858B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84D0E2A6-F29D-4E7A-A9A7-7B3B189858B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84D0E2A6-F29D-4E7A-A9A7-7B3B189858B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84D0E2A6-F29D-4E7A-A9A7-7B3B189858B4}.Release|Any CPU.Build.0 = Release|Any CPU + {88871D7B-C1E5-40A9-99D5-C4728F4F9F34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {88871D7B-C1E5-40A9-99D5-C4728F4F9F34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {88871D7B-C1E5-40A9-99D5-C4728F4F9F34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {88871D7B-C1E5-40A9-99D5-C4728F4F9F34}.Release|Any CPU.Build.0 = Release|Any CPU + {738D63F4-EC3C-4228-8CDD-49F225D63F50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {738D63F4-EC3C-4228-8CDD-49F225D63F50}.Debug|Any CPU.Build.0 = Debug|Any CPU + {738D63F4-EC3C-4228-8CDD-49F225D63F50}.Release|Any CPU.ActiveCfg = Release|Any CPU + {738D63F4-EC3C-4228-8CDD-49F225D63F50}.Release|Any CPU.Build.0 = Release|Any CPU + {687246E4-702E-40D2-A00F-A6D8933EFE76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {687246E4-702E-40D2-A00F-A6D8933EFE76}.Debug|Any CPU.Build.0 = Debug|Any CPU + {687246E4-702E-40D2-A00F-A6D8933EFE76}.Release|Any CPU.ActiveCfg = Release|Any CPU + {687246E4-702E-40D2-A00F-A6D8933EFE76}.Release|Any CPU.Build.0 = Release|Any CPU + {3864AA23-5A37-4E4F-9324-E68BC78B7AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3864AA23-5A37-4E4F-9324-E68BC78B7AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3864AA23-5A37-4E4F-9324-E68BC78B7AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3864AA23-5A37-4E4F-9324-E68BC78B7AD4}.Release|Any CPU.Build.0 = Release|Any CPU + {3E1B73A9-BC6C-42D9-BB90-C4568753F406}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E1B73A9-BC6C-42D9-BB90-C4568753F406}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E1B73A9-BC6C-42D9-BB90-C4568753F406}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E1B73A9-BC6C-42D9-BB90-C4568753F406}.Release|Any CPU.Build.0 = Release|Any CPU + {EDAF8432-6D21-4FCA-84F6-1A71AA9E0237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EDAF8432-6D21-4FCA-84F6-1A71AA9E0237}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EDAF8432-6D21-4FCA-84F6-1A71AA9E0237}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EDAF8432-6D21-4FCA-84F6-1A71AA9E0237}.Release|Any CPU.Build.0 = Release|Any CPU + {EB616A5C-E246-4278-B75E-956D9A239D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB616A5C-E246-4278-B75E-956D9A239D24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB616A5C-E246-4278-B75E-956D9A239D24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB616A5C-E246-4278-B75E-956D9A239D24}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {84D0E2A6-F29D-4E7A-A9A7-7B3B189858B4} = {D9274304-4A5B-457C-9F94-0D43FCB34306} + {88871D7B-C1E5-40A9-99D5-C4728F4F9F34} = {D9274304-4A5B-457C-9F94-0D43FCB34306} + {738D63F4-EC3C-4228-8CDD-49F225D63F50} = {D9274304-4A5B-457C-9F94-0D43FCB34306} + {687246E4-702E-40D2-A00F-A6D8933EFE76} = {D9274304-4A5B-457C-9F94-0D43FCB34306} + {3864AA23-5A37-4E4F-9324-E68BC78B7AD4} = {44A151F1-0BBE-485D-8E61-77FCC1CB6308} + {3E1B73A9-BC6C-42D9-BB90-C4568753F406} = {44A151F1-0BBE-485D-8E61-77FCC1CB6308} + {EDAF8432-6D21-4FCA-84F6-1A71AA9E0237} = {44A151F1-0BBE-485D-8E61-77FCC1CB6308} + {EB616A5C-E246-4278-B75E-956D9A239D24} = {44A151F1-0BBE-485D-8E61-77FCC1CB6308} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4009C08A-12EC-4A91-9145-57C7F0B5124C} + EndGlobalSection +EndGlobal