kristofer / Working with Strings
Ultima volta attivo
Working with Strings
In both python and Java, samples of working with common string operations: split, capitalization, concatenation, replacing characters, working with sentences.
Key differences:
- Python: Has built-in title(), capitalize() methods; f-strings for formatting
- Java: More verbose; often requires manual implementation or StringBuilder
- Python: Strings are immutable but syntax is cleaner
kristofer / String Splitting
Ultima volta attivo
split a string in both Python and Java
Splitting a String
into a list or array of strings.
Key differences:
- Python returns a list directly
- Java returns an array (String[]), which you can convert to List if needed
- Python uses split() with no argument to split by any whitespace
- Java requires explicit delimiter - use split("\s+") for any whitespace
kristofer / Random Integers (Java & Python)
Ultima volta attivo
easy way to generate a random int from to max
If you need to generate a random integer, a number from say, 1 to 6, you can write a couple routines:
Java
import java.util.Random;
int min = 1;
int max = 6;
kristofer / Pandas Hello World
Ultima volta attivo
a very simple pandas test
Explanation:
import pandas as pd:
This line imports the pandas library, aliasing it as pd for convenience, which is a common convention.
data = {'Message': ['Hello, World!']}:
kristofer / Spark/Docker Troubleshooting Guide
Ultima volta attivo
Spark-Docker-SQL - Troubleshooting Guide
🚨 Quick Emergency Fixes
🔥 "Everything is Broken" - Nuclear Option
# Stop everything and restart fresh
docker-compose down -v --remove-orphans
docker system prune -f
docker volume prune -fkristofer / Create Classroom assignment
Ultima volta attivo
for GitHub classroom
| 1 | #!/bin/bash |
| 2 | |
| 3 | # GitHub Classroom Assignment Creator |
| 4 | # This script creates a new assignment in a GitHub Classroom using the GitHub CLI |
| 5 | |
| 6 | set -e # Exit on any error |
| 7 | |
| 8 | # Color codes for output |
| 9 | RED='\033[0;31m' |
| 10 | GREEN='\033[0;32m' |
kristofer / millions.java
Ultima volta attivo
experimentation in code is Good Idea
| 1 | import java.time.Duration; |
| 2 | import java.time.Instant; |
| 3 | import java.util.ArrayList; |
| 4 | |
| 5 | public class Millions { |
| 6 | |
| 7 | |
| 8 | private Integer[] aArray; |
| 9 | private ArrayList<Integer> aList; |
kristofer / HTTP Server Java
Ultima volta attivo
a very simple HTTP server in Java
| 1 | package rocks.zipcode; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.io.OutputStream; |
| 5 | import java.net.InetSocketAddress; |
| 6 | |
| 7 | import com.sun.net.httpserver.HttpExchange; |
| 8 | import com.sun.net.httpserver.HttpHandler; |
| 9 | import com.sun.net.httpserver.HttpServer; |
kristofer / DTOs (java & python)
Ultima volta attivo
Data Transfer Objects (DTOs) Explained for Beginners (Java, then Python)
Data Transfer Objects (DTOs) via Java; Explained for Beginners
What Are DTOs?
A Data Transfer Object (DTO) is a simple container for data that travels between different parts of your application. Think of a DTO like an envelope specifically designed to carry exactly what's needed—no more, no less.
public class OrderDTO {
private Long id;
private String customerName;