Skip to content

Instantly share code, notes, and snippets.

View davegurnell's full-sized avatar
🐱

Dave Pereira-Gurnell davegurnell

🐱
View GitHub Profile
package code
import cats.implicits._
// Main.scala
object Main extends App {
val database = PersonDatabase.createTestDatabase
// 1. Write code to:
@davegurnell
davegurnell / copy-responses-to-choices.js
Last active November 7, 2021 13:19
Script to copy the responses from a text field in one Google Form as choices in a multiple choice field in another Google Form
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
START OF CONFIGURATION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~
Configuration: Form URLs
~~~~~~~~~~~~~~~~~~~~~~~~
You can get these from the address bar
@davegurnell
davegurnell / karabiner.json
Created June 8, 2018 10:18
Karabiner Elements config file for British Microsoft Sculpt keyboard
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@davegurnell
davegurnell / config.yml
Last active April 5, 2020 01:18
Minimal CircleCI 2.0 Scala build configuration with caching of Ivy/Maven dependencies
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
steps:
- checkout
- restore_cache:
key: scala-library-dependencies-{{ checksum "build.sbt" }}
- run: sbt test:compile
@davegurnell
davegurnell / PostfixCalcEither.scala
Last active December 1, 2017 12:58
Postfix calculator with ADT-based error handling
package calc
sealed trait Term
case object Add extends Term
case object Sub extends Term
case object Mul extends Term
case object Div extends Term
case class Num(value: Int) extends Term
sealed trait Error

What we installed at the start

First we installed Node.js, which is a command line application that lets you run JAvascript code outside of the browser. We installed Node 7.10.2 (which isn't the latest version).

When you install node.js you get two commands:

  • node -- runs Javascript in your terminal;
  • npm -- "node package manager" This allows you to install libraries for Javascript development.

Keybase proof

I hereby claim:

  • I am davegurnell on github.
  • I am davegurnell (https://keybase.io/davegurnell) on keybase.
  • I have a public key ASApCZUz4VGEmz2Ctus4gct2FCaAnGUJoaas1mvLor9TZgo

To claim this, I am signing this object:

@davegurnell
davegurnell / HtmlWriter.scala
Created April 3, 2017 21:17
HtmlWriter type class example
trait HtmlWriter[A] {
def apply(value: A): String
}
object HtmlWriter {
def apply[A](implicit writer: HtmlWriter[A]): HtmlWriter[A] =
writer
def write[A](value: A)(implicit writer: HtmlWriter[A]): String =
writer.apply(value)

Workshop: Getting Started with Shapeless

This workshop will introduce shapeless, a library for generic programming in Scala. We will discover how to use shapeless to automatically create instances of type classes ("JSON encoder", "Equals", "Show", and so on) for any algebraic data type (case class or sealed trait) using a very small kernel of library code.