Skip to content

Instantly share code, notes, and snippets.

View Spimy's full-sized avatar

Spimy Spimy

View GitHub Profile
@Spimy
Spimy / Data.java
Last active May 30, 2024 14:59
PRG1203 Object Oriented Programming Fundamentals - Lab 8
public class Date {
private int day;
private int month;
private int year;
private final String[] monthNames = {
"January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"
};
private final int[] monthDays = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@Spimy
Spimy / Search.vb
Created October 30, 2022 20:12
LinearSearch and BinarySearch
Module Program
Sub Main()
Dim MyArray() As Integer = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Console.WriteLine(LinearSearch(MyArray, 5))
Console.WriteLine(BinarySearch(MyArray, 9))
Console.WriteLine(RecursiveBinarySearch(MyArray, 3))
End Sub
Function LinearSearch(Array() As Integer, Search As Integer) As Boolean
@Spimy
Spimy / Sort.vb
Last active October 30, 2022 19:22
BubbleSort and InsertionSort
Module Program
Sub Main()
Dim ArrayA() As Integer = {3, 5, 6, 2, 1, 4, 8, 0, 9, 7}
Dim ArrayB() As Integer = {3, 5, 6, 2, 1, 4, 8, 0, 9, 7}
Console.WriteLine("Before Sorting")
Console.WriteLine("============================")
Console.WriteLine("Array A: " & String.Join(",", ArrayA))
Console.WriteLine("Array B: " & String.Join(",", ArrayB))
Console.WriteLine("============================")
@Spimy
Spimy / UserAuthentication.vb
Created November 3, 2020 19:44
Simple User Authentication in VB
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Imports System.Text.RegularExpressions
Module Program
Const Users As String = "C:\Users\acer\source\repos\FileProcessing\users.txt"
Dim UsernameRegex As New Regex("[a-zA-Z0-9_]{1,16}")
Dim EmailRegex As New Regex("^[^@]+@[^@]+\.[^@]+$")
@Spimy
Spimy / SortingAlgorithms.vb
Last active November 3, 2020 18:15
Sorting Algorithms Written in VB
Module Program
' I keep using Arr.Clone() to create a new copy of the array instead of having
' a reference to the original array. VB is too dumb to get a copy of the values of
' the original array instead of getting a reference of it.
' Simply put, it's to avoid mutating the original array.
''' <summary>
''' Insertion works by having a pointer and a key value.
@Spimy
Spimy / BuiltInFunctions.vb
Created November 3, 2020 13:36
Built In Functions for String Manipulation in VB.NET
Module Program
Sub Main()
Const Name As String = "Spimy"
Const PiStr As String = "3.14" ' To be converted to Double
' Val will always convert to type of Double even if the argument provided is an integer
Dim Pi = Val(PiStr)
Console.WriteLine("{0} : Type {1}", PiStr, PiStr.GetType.Name)