Skip to content

Instantly share code, notes, and snippets.

View itsHobbes's full-sized avatar

itsHobbes

View GitHub Profile
@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.

@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 / 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));
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="13">
<profile kind="CodeFormatterProfile" name="GoogleStyle" version="14">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="17">
<profile kind="CodeFormatterProfile" name="fluent" version="17">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
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;

@everyone :exclamation: Programmer's Safety Announce ❗ Hey folks, quick announcement on account safety. We're seeing an increased number of accounts get hacked through phishing scams that are posted in channels or sent via direct messages. The common scams at the moment are related to Steam and Discord. When you are visiting links, be very wary of shortened/hidden urls (use a site like https://wheregoes.com/ to check where shortened urls go).

When looking at messages/domains remember the following:

  1. Take your time. Don't rush into things. If you're excited or tired, pause for a minute and re-read the message.
  2. Always double check the domain name of a link.
  3. If it sounds too good to be true, it probably is.
  4. You can add some protection to your account with 2fa, but if you input your 2fa into a scam site your account will be taken from you.
  5. Be aware of fake i-frames/pop ups!