All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

Login


All New Login

All gists

Recently created
Least recently created
Recently updated
Least recently updated
kristofer's Avatar

kristofer / Working with Strings

0 likes
0 forks
1 files
Last active 1763751699

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's Avatar

kristofer / Binning

0 likes
0 forks
1 files
Last active 1763751204
creating a data structure to "bin" items

Binning of frequencies

Examples of python and java of using dict/hashmap for binning of 1) dice rolls, 2) letter frequency and 3) checking for existing keys.

Key patterns:

  • Python: dict.get(key, default) and defaultdict(int) are idiomatic
  • Java: map.getOrDefault(key, default) and map.merge() are modern approaches
kristofer's Avatar

kristofer / String Splitting

0 likes
0 forks
1 files
Last active 1763750838
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's Avatar

kristofer / Random Integers (Java & Python)

0 likes
0 forks
1 files
Last active 1762530029
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's Avatar

kristofer / Pandas Hello World

0 likes
0 forks
2 files
Last active 1753283286
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's Avatar

kristofer / Spark/Docker Troubleshooting Guide

0 likes
0 forks
1 files
Last active 1751371779

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 -f
kristofer's Avatar

kristofer / Create Classroom assignment

0 likes
0 forks
1 files
Last active 1750972057
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's Avatar

kristofer / millions.java

0 likes
0 forks
3 files
Last active 1750425725
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's Avatar

kristofer / HTTP Server Java

0 likes
0 forks
2 files
Last active 1750422453
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's Avatar

kristofer / DTOs (java & python)

0 likes
0 forks
2 files
Last active 1749231863
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;
Newer Older

Powered by Opengist ⋅ Load: 168ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano Português Русский Türkçe Українська 中文 繁體中文