Skip to content

Instantly share code, notes, and snippets.

View docsallover's full-sized avatar

DocsAllOver docsallover

View GitHub Profile
@docsallover
docsallover / removing_noise_regex.py
Last active September 4, 2025 16:38
Data Cleaning with Regex (Removing Noise)
def remove_noise(data_list):
"""Removes common noise and unwanted text."""
noise_pattern = r"(\. This is a note\.| ID #\d+|Sent from my mobile\.)"
cleaned_data = [re.sub(noise_pattern, "", text) for text in data_list]
return cleaned_data
print("\n--- Removed Noise ---")
cleaned_data = remove_noise(standardized_data)
for item in cleaned_data:
print(item)
@docsallover
docsallover / data_cleaning_workflow.py
Created September 4, 2025 16:29
Full script demonstrating the entire data cleaning workflow in python's regex
import re
raw_data = [
"Contact me at user.name@email.com or call me at (123) 456-7890. This is a note.",
"Invoice from customer@example.net, phone: 987.654.3210. ID #892",
"Sent from my mobile. My email is support@docsallover.io. Call me at 555-123-4567.",
"Random text with no useful info.",
"Our team can be reached at docsallover@corp.co, or by phone: +1-555-999-8888. "
]
@docsallover
docsallover / research_function_output.txt
Created September 4, 2025 15:04
re.search() function output in python's regex module
Match found!
Match found at indices (4, 7)
The matched string is: 'cat'
@docsallover
docsallover / research_function.py
Created September 4, 2025 14:41
re.search() function in python's regex module
import re
text = "The cat in the hat."
# Pattern to find 'a' followed by any single character, then 't'
pattern = 'a.t'
# Use re.search() to find the first match
match = re.search(pattern, text)
# Check if a match was found
@docsallover
docsallover / upper_bounded_wildcard.java
Created August 30, 2025 08:36
Upper Bounded Wildcard In Java
public void printNumbers(List<? extends Number> list) {
// We can safely read from the list
Number num = list.get(0);
System.out.println(num);
// list.add(10); // COMPILE ERROR: Cannot add to the list
}
@docsallover
docsallover / lower_bounded_wildcard.java
Created August 30, 2025 08:19
Lower Bounded Wildcard In Java
public void addIntegers(List<? super Integer> list) {
// We can safely write to the list
list.add(10);
list.add(20);
// Integer num = list.get(0); // COMPILE ERROR: Can't be sure of the type
}
@docsallover
docsallover / unbounded_wildcard.java
Created August 30, 2025 08:18
Unbounded Wildcard In Java
public void printList(List<?> list) {
for (Object element : list) {
System.out.println(element);
}
}
@docsallover
docsallover / bounded_type_parameters.java
Created August 30, 2025 08:13
Generic method that finds the maximum value in an array in Java
public class MaxFinder {
// The type T must implement the Comparable interface
public static <T extends Comparable<T>> T findMax(T[] array) {
if (array == null || array.length == 0) {
return null;
}
T max = array[0];
for (int i = 1; i < array.length; i++) {
if (array[i].compareTo(max) > 0) {
max = array[i];
@docsallover
docsallover / generic_method.java
Last active August 30, 2025 08:12
Example of a generic method that can print the elements of any ArrayList in Java
import java.util.List;
public class Util {
public static <T> void printList(List<T> list) {
for (T element : list) {
System.out.println(element);
}
}
}
@docsallover
docsallover / specific_type.java
Created August 30, 2025 07:58
Example of a simple Box class that can hold any single object in java part 2
// Create a Box to hold Strings
Box<String> stringBox = new Box<String>();
stringBox.set("Hello Generics!");
// Create a Box to hold Integers
Box<Integer> integerBox = new Box<>(); // The compiler infers the type, making it cleaner
integerBox.set(123);