Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / kotlin_dsl.md
Last active February 27, 2021 01:26
Kotlin DSLs

Kotlin in Action: DSLs

General purpose programming language

  • imperative (sequence of stateful, ordered steps that describe how to do something)
  • wide scope
  • Java, Bash etc
  • potential for "runtime errors"

DSL (Domain Specific Language)

  • declarative (describes what something is, not how to do it)
@androidfred
androidfred / lambdas_functions_functors_monads.md
Last active May 17, 2024 15:42
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?

@androidfred
androidfred / advanced_anki_deck_editing.md
Last active April 27, 2024 04:25
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 / javafx.md
Last active October 27, 2021 03:21
java.lang.ClassNotFoundException: javafx.util.Pair

java.lang.ClassNotFoundException: javafx.util.Pair happens because javafx.util.Pair and other classes from javafx.util are not included in OpenJDK. Options for resolving:

Switch class

Map.Entry<K, V> from java.util is similar to javafx.util.Pair.

Install java-openjfx

Install java-openjfx through your package manager. (or whatever means you used to install Java on your machine) Note that java-openjfx is compatible with OpenJDK8, not previous versions.

After installing java-openjfx, you may have to add it manually to your IDE SDK classpath. Eg in IntelliJ, you may have to go to Project Structure | SDKs | <select your SDK> | Classpath | + (the Classpath +, not the SDKs +) | and add /usr/lib/jvm/java-8-openjdk/jre/lib/ext/jfxrt.jar (which should be there now that java-openjfx has been installed) | OK

@androidfred
androidfred / anti_tests.md
Last active March 3, 2021 02:08
Anti-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 / haskell_stack_and_intellij_idea_ide_setup_tutorial_how_to_get_started.md
Last active May 6, 2024 19:13
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