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

kristofer

Joined 1714567308

Recently created
Least recently created
Recently updated
Least recently updated
All gists 105
kristofer's Avatar

kristofer / Intro TDD

0 likes
0 forks
1 files
Last active 1740760421

Introduction to Test Driven Development in Java

Test Driven Development (TDD) is a software development approach where tests are written before the actual code implementation. This methodology focuses on creating a solid foundation of tests that drive the design and development of your application code. For Java developers, TDD has become a fundamental practice that improves code quality, reduces bugs, and facilitates maintenance.

The TDD Cycle

The core of TDD revolves around a simple three-step cycle, often called "Red-Green-Refactor":

  1. Red: Write a failing test that defines the functionality you want to implement.
  2. Green: Write the minimal amount of code needed to make the test pass.
kristofer's Avatar

kristofer / Intro Using ArrayLists

0 likes
0 forks
3 files
Last active 1741204255
1 import java.util.ArrayList;
2 import java.util.Collections;
3 import java.util.Comparator;
4 import java.util.Scanner;
5
6
7 // See below for information on this class.
8 public class ArrayListExamples {
9
10 public static void main(String[] args) {
kristofer's Avatar

kristofer / ArrayList class

0 likes
0 forks
1 files
Last active 1741098222

Java ArrayLists: A Dynamic Alternative to Arrays

While Java arrays are powerful, they have a significant complication: their size is fixed once created. Enter ArrayLists - a more flexible, dynamic alternative that automatically grows and shrinks as needed. ArrayLists are part of Java's Collections Framework and offer enhanced functionality for managing groups of objects.

What Is an ArrayList?

An ArrayList is a resizable array implementation of the List interface. Unlike regular arrays, ArrayLists can dynamically change in size during program execution. They store objects rather than primitive types, though Java's autoboxing feature allows them to work seamlessly with primitives too.

ArrayList vs. Array

kristofer's Avatar

kristofer / IntroJavaArrays

0 likes
0 forks
1 files
Last active 1741098232

Java Arrays: An Introduction for Beginners

Arrays are one of the most fundamental data structures in Java programming. They allow you to store multiple values of the same type under a single variable name, making your code more organized and efficient. This introduction will help you understand what arrays are, how they work, and how to use them effectively in your Java programs.

What Is an Array?

An array is a container that holds a fixed number of values of a single type. Think of an array as a row of boxes, where each box can store one item. All items in an array must be of the same data type - whether that's integers, floating-point numbers, characters, or even objects.

Why Use Arrays?

kristofer's Avatar

kristofer / Simple Text Edit Python

0 likes
0 forks
1 files
Last active 1739984695
Python simple text edit using Tkinter
1 import tkinter as tk
2 from tkinter.filedialog import askopenfilename, asksaveasfilename
3
4 def open_file():
5 """Open a file for editing."""
6 filepath = askopenfilename(
7 filetypes=[("Text Files", "*.txt"), ("All Files", "*.*")]
8 )
9 if not filepath:
10 return
kristofer's Avatar

kristofer / Digital Clock Py GUI

0 likes
0 forks
1 files
Last active 1739983954
1 from tkinter import Label, Tk
2 import time
3
4 # need to `brew install python-tk`
5 # to setup a mac for tkinter
6 #
7
8 app_window = Tk()
9 app_window.title("Digital Clock")
10 app_window.geometry("420x150")
kristofer's Avatar

kristofer / qrcodepy.md

0 likes
0 forks
1 files
Last active 1739983053

pip install pyqrcode

How to create a QR Code with Python:

import pyqrcode 
from pyqrcode import QRCode 
  
# String (URL) to make into QR code 
s = "https://zipcodewilmington.com"
kristofer's Avatar

kristofer / Python Alarm

0 likes
0 forks
1 files
Last active 1739982656
1 from datetime import datetime
2 from playsound import playsound
3 alarm_time = input("Enter the time of alarm to be set:HH:MM:SS\n")
4 alarm_hour=alarm_time[0:2]
5 alarm_minute=alarm_time[3:5]
6 alarm_seconds=alarm_time[6:8]
7 alarm_period = alarm_time[9:11].upper()
8 print("Setting up alarm..")
9 while True:
10 now = datetime.now()
kristofer's Avatar

kristofer / Acronym Python

0 likes
0 forks
1 files
Last active 1739982535
user_input = str(input("Enter a Phrase: "))
text = user_input.split()
a = " "
for i in text:
    a = a+str(i[0]).upper()
print(a)
kristofer's Avatar

kristofer / Acronym Python

0 likes
0 forks
1 files
Last active 1739982565
user_input = str(input("Enter a Phrase: "))
text = user_input.split()
a = " "
for i in text:
    a = a+str(i[0]).upper()
print(a)
Newer Older

Powered by Opengist ⋅ Load: 154ms⋅

English
Čeština Deutsch English Español Français Magyar Português Русский 中文 繁體中文