Skip to content

Instantly share code, notes, and snippets.

View itsHobbes's full-sized avatar

itsHobbes

View GitHub Profile
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.LongAdder;
import java.util.stream.Collectors;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
@itsHobbes
itsHobbes / day1.rs
Last active December 1, 2019 17:43
AOC Day 1
use crate::util::util;
use std::vec::Vec;
pub fn execute() {
let filename = String::from("day1.txt");
let masses: Vec<u32> = util::read_file(filename);
println!("Part one answer: {}", part_one(&masses));
println!("Part two answer: {}", part_two(&masses));
}
@itsHobbes
itsHobbes / PasswordFinder.java
Last active July 24, 2019 14:27
A simple java program to search password dumps for SHA-1 Hashed passwords from https://haveibeenpwned.com/passwords
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@itsHobbes
itsHobbes / Twelve ways to make code suck less.md
Last active April 1, 2022 01:16
A summary of the popular talk, "Twelve ways to make code suck less" by Venkat Subramaniam

Twelve ways to make code suck less by Venkat Subramaniam

12: Schedule time to lower technical debt

Make a prioritised list of your current technical debt. Allocate time to tackle it and keep that list in mind when you are working on something new. Think about whether what you are writing will end up on that list.

11: Favour high cohesion

Cohesion is where code does one thing really, really well. Code that is more cohesive changes less, and reduces effort to make any needed changes to it. One measure of cohesion is Cyclomatic complexity and services like www.sonarcloud.io can analyse this for you.