Skip to content

Instantly share code, notes, and snippets.

@androidfred
androidfred / haskell_stack_and_intellij_idea_ide_setup_tutorial_how_to_get_started.md
Last active February 4, 2024 20:58
Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started

Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started

Upon completion you will have a sane, productive Haskell environment adhering to best practices.

Basics

  • Haskell is a programming language.
  • Stack is tool for Haskell projects. (similar tools for other languages include Maven, Gradle, npm, RubyGems etc)
  • Intellij IDEA IDE is a popular IDE.

Install required libraries

sudo apt-get install libtinfo-dev libghc-zlib-dev libghc-zlib-bindings-dev

@androidfred
androidfred / progressively_more_detail.md
Last active January 8, 2024 20:23
This "progressively more detail" image loading algorithm can help you do and learn anything

This "progressively more detail" image loading algorithm can help you do and learn anything

Summary, TLDR

When doing or learning pretty much anything, the strategy where you tackle the whole thing all at once, but starting with a rough outline and then incrementally revisiting everything to go into increasingly more detail, is often more effective than doing things perfectly little by little and missing the big picture. (pun intended)

Longer version

Back in the days of dial up internet, which was very limited in speed and capacity compared to modern internet connections, images on a web page could take very long to load. There were different strategies for dealing with that problem, and if you look hard enough (pun intended again), they can reveal some things about how to do and learn stuff.

@androidfred
androidfred / test_tests.md
Created June 22, 2021 05:10
Test your tests

Test your tests

Summary: test interfaces, not implementations

Tests that pass when something is actually broken, and fail when things actually do work, are worse than useless- they are positively harmful.

The requirement

Let's say we've been tasked with returning 400 when GET /users/<userId> is called with a negative userId.

The test

The requirement can be turned into a test that hits the endpoint with a negative userId and checks that a 400 is returned:

@androidfred
androidfred / kotlin_arrow.md
Last active December 7, 2023 17:42
Kotlin Arrow

Kotlin Arrow

A lot of Kotlin features can be traced back to functional programming languages, eg

  • Heavy use of immutability-by-default and map, filter etc functions
  • Type inference
  • Data classes (which enable pattern matching)
  • Null safety and dealing with the absence of values

However, Kotlin is missing many incredibly useful data types that are ubiquitous in functional programming languages, eg Either, Try etc.

@androidfred
androidfred / help.md
Last active May 24, 2023 20:10
How to ask for help or report a problem

How to ask for help or report a problem

I've been in tech 10 years now, and it never ceases to amaze me how bad even professional techies are at asking for help or reporting a problem.

How many times have you reached out to someone, or been reached out by someone else, something like this? (to be clear, I'm guilty as charged of this)

"I can't do x"

"y is broken"

@androidfred
androidfred / noargs_setters_builders.md
Last active March 9, 2023 15:51
Stop using noargsconstructors and setters (and builders)

Stop using noargsconstructors and setters (and builders)

TLDR summary

Noargsconstructors and setters are outdated, 90's style old school Java. They needlessly allow entire categories of defects that are easily avoided by using only allargsconstructors and no setters. Please stop writing code like that.

Longer version

How many times have you come across (or written) code like this

public class User {
@androidfred
androidfred / package_by_feature.md
Created September 15, 2021 00:40
Package by feature - not by layer

Package by feature - not by layer

TLDR, summary

Traditionally, most Java apps are organized by layer, which needlessly encourages large, unwieldy "God classes" and spaghetti dependencies, where every class and package depends on every other across the system.

Instead, consider packaging by feature.

Longer version

Package by layer and what it leads to

How many times have you come across classes like this

@androidfred
androidfred / advanced_anki_deck_editing.md
Last active February 15, 2023 18:47
Advanced Anki deck editing made simple (ish)

Advanced Anki deck editing made simple (ish)

Anki is a great open source flashcard app that can be used to learn anything.

This Gist is a full end to end example of how to:

  • export Anki decks from Anki
  • import Anki decks into MySQL
  • edit Anki decks using MySQL
  • export Anki decks from MySQL
@androidfred
androidfred / semantic_indenting.md
Last active August 14, 2022 05:11
Use semantic indenting

Use semantic indenting

TLDR - Summary

Semantic indenting can greatly increase readability and maintainability of code. It can even increase the quality of code! (eg by making excessive dependencies more obvious etc)

Longer version

How many times have you come across code indented like this (ignore the code, it's just gibberish, focus on the indenting itself)

    @Autowired
    public FooService(FirstDependency first, SecondDependency second, ThirdDependency third,
@androidfred
androidfred / lambdas_functions_functors_monads.md
Last active March 10, 2022 06:08
Lambdas, Functions, Functors and Monads

Lambdas, Functions, Functors and Monads

Intro

If you've been exposed to lambdas (whether in Java or Kotlin), you already know at least the basics of what lambdas are, the syntax for using them, that they're more succinct than instantiating anonymous classes etc etc.

Rather than talking about that, I figured we would talk about functions and lambdas on a higher level.

I think most of us are familiar with map and, having used it quite a bit, have an intuitive understanding of what any given call to map will do.

Does anyone know a bit more about map, what it is and where it came from?