- Incremental progress over big bangs - Small changes that compile and pass tests
- Learning from existing code - Study and plan before implementing
- Pragmatic over dogmatic - Adapt to project reality
- Clear intent over clever code - Be boring and obvious
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import json | |
| import backoff | |
| import logging | |
| from posthog import Posthog | |
| # SingletonMeta implementation | |
| class SingletonMeta(type): | |
| _instances = {} | |
| def __call__(cls, *args, **kwargs): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[white]%}[" | |
| ZSH_THEME_GIT_PROMPT_SUFFIX="" | |
| ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[white]%}]%{$reset_color%} " | |
| ZSH_THEME_GIT_PROMPT_CLEAN="]%{$reset_color%} " | |
| ZSH_THEME_SVN_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX | |
| ZSH_THEME_SVN_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX | |
| ZSH_THEME_SVN_PROMPT_DIRTY=$ZSH_THEME_GIT_PROMPT_DIRTY | |
| ZSH_THEME_SVN_PROMPT_CLEAN=$ZSH_THEME_GIT_PROMPT_CLEAN | |
| ZSH_THEME_HG_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX | |
| ZSH_THEME_HG_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [... document.querySelectorAll('#fittingroom > div:nth-child(2) > div.fitting-room-wrapper.feed > div')].filter(item => item.innerText.includes("Sold")).map(filtered => filtered.childNodes[1].childNodes[2].click()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var lastScrollHeight=0;function autoScroll(){var l=document.documentElement.scrollHeight;l!=lastScrollHeight&&(lastScrollHeight=l,document.documentElement.scrollTop=l)}window.setInterval(autoScroll,100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.getElementById('gateway-content').remove(); document.getElementById('app').children[0].children[0].classList = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io._ | |
| import java.nio.charset.CharacterCodingException | |
| import cats.{ ApplicativeError, Defer, MonadError } | |
| import cats.effect._ | |
| import cats.implicits._ | |
| import com.typesafe.scalalogging.LazyLogging | |
| import scala.concurrent.duration._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env amm | |
| // This script converts Maven dependencies from a pom.xml to sbt dependencies. | |
| // It is based on the answers of George Pligor and Mike Slinn on http://stackoverflow.com/questions/15430346/ | |
| // - install https://github.com/lihaoyi/Ammonite | |
| // - make this script executable: chmod +x PomDependenciesToSbt | |
| // - run it with from your shell (e.g bash): | |
| // $ ./PomDependenciesToSbt /path/to/pom.xml | |
| import scala.xml._ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import $ivy.`org.typelevel::cats-core:2.1.1`, cats._, cats.implicits._ | |
| import $ivy.`org.scalatest::scalatest:3.0.8`,org.scalatest._ | |
| import $ivy.`org.scalacheck::scalacheck:1.14.0` | |
| import $ivy.`io.monix::monix:3.1.0` | |
| import $ivy.`dev.zio::zio:1.0.0-RC18` | |
| import $ivy.`org.typelevel::cats-effect:2.1.2` | |
| import $ivy.`com.github.chocpanda::scalacheck-magnolia:0.3.1` | |
| import $ivy.`io.chrisdavenport::cats-scalacheck:0.2.0` | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.duration._ |
I've been exploring functional programming with Scala ever since I started on the Digital Experience Platform team at Qualtrics (my first ever exposure to Scala), and ever since I grokked functional programming I really got excited about the concept and have since been trying to learn and apply its principals to the code I write.
This post spawned out of notes that I've taken about the language in my first 6 months working in it, and I decided to clean it up last night in the hope that my attempts to learn functional programming in Scala help with anyone else who is curious. It was also helpful for my own learning to write everything down.
Anyway, here's what I have so far!