Skip to content

Instantly share code, notes, and snippets.

@d6y
d6y / gist:a7c88bdec85a73f18b3b176953afaa32
Created July 30, 2018 09:06
checkout and compile mapping playground
tmp$ git clone git@github.com:d6y/aws-gateway-mapping-playground.git
Cloning into 'aws-gateway-mapping-playground'...
remote: Counting objects: 22, done.
remote: Total 22 (delta 0), reused 0 (delta 0), pack-reused 22
Receiving objects: 100% (22/22), 8.71 KiB | 4.36 MiB/s, done.
Resolving deltas: 100% (1/1), done.
tmp$ cd aws-gateway-mapping-playground/
aws-gateway-mapping-playground (master)$ sbt
[info] Updated file /Users/richard/Developer/tmp/aws-gateway-mapping-playground/project/build.properties: set sbt.version to 1.1.6
[info] Loading settings from idea.sbt,sbt-updates.sbt,sonatype.sbt ...
@d6y
d6y / wrong.txt
Created June 25, 2018 10:23
filterQuery.map(_.name).update("new")
-------- QUERY 2 (WRONG):
DEBUG slick.compiler.QueryCompiler - Source:
| Bind
| from s2: Filter s3
| from s3: TableExpansion
| table s4: Table a
| columns: TypeMapping
| 0: ProductNode
| 1: Path s4.id : Int'
@d6y
d6y / correct.txt
Created June 25, 2018 10:06
filterQuery.length.result
-------- QUERY 1 (CORRECT):
DEBUG slick.compiler.QueryCompiler - Source:
| Apply Function count(*)
| 0: Filter s2
| from s2: TableExpansion
| table s3: Table a
| columns: TypeMapping
| 0: ProductNode
| 1: Path s3.id : Int'
'use strict';
const admin = require('firebase-admin');
admin.initializeApp();
const functions = require('firebase-functions'); // Cloud Functions for Firebase library
const DialogflowApp = require('actions-on-google').DialogflowApp; // Google Assistant helper library
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
if (request.body.queryResult) {
@d6y
d6y / noodle.scala
Last active March 16, 2018 17:43
Assuming you're stuck using Future somewhere, well...
package example
import scala.language.higherKinds
import cats.MonadError
import cats.syntax.functor._
// Both Try and Future are backed by Exceptions
// We can trade Future for Try in tests to avoid concurrency and execution context etc
@d6y
d6y / equals.scala
Last active November 24, 2017 19:06
Equality
/*
By default, there are equality tests in Scala that return false which you'd really like
to be a compile-time error.
For example:
scala> "Hello" == 42
res0: Boolean = false
scala> Some(1) == 1
@d6y
d6y / moremonads.hs
Created July 20, 2017 06:36
Code from Functional Brighton 18 July 2017
import Data.Monoid
import Data.Ratio
import Control.Monad.Writer
import Control.Monad.Reader
import Control.Monad.State
-- Maybe is for values with an added context of failure
fruit :: Maybe String
fruit = Just "Apple"
@d6y
d6y / monoid.hs
Created May 16, 2017 21:33
FB Monoid
--
-- Functional Brighton, LYAHFGG Monoids
-- https://www.meetup.com/Functional-Brighton/events/239127334/
--
{-
About Monoids:
Needs a binary function:
~$ cd tmp/
tmp$ git clone https://github.com/underscoreio/shapeless-guide-code
Cloning into 'shapeless-guide-code'...
remote: Counting objects: 280, done.
remote: Total 280 (delta 0), reused 0 (delta 0), pack-reused 280
Receiving objects: 100% (280/280), 1.02 MiB | 918.00 KiB/s, done.
Resolving deltas: 100% (60/60), done.
tmp$ cd shapeless-guide-code/
shapeless-guide-code (exercises)$ ls
LICENSE build.sbt csv json migrations project representations sbt.bat schedule.md
protocol (master *)$ git diff
diff --git a/http/src/test/scala/spinoco/protocol/http/codec/HeaderCodecSpec.scala b/http/src/test/scala/spinoco/protocol/http/codec/HeaderCodecSpec.scala
index e181170..41015af 100644
--- a/http/src/test/scala/spinoco/protocol/http/codec/HeaderCodecSpec.scala
+++ b/http/src/test/scala/spinoco/protocol/http/codec/HeaderCodecSpec.scala
@@ -292,6 +292,9 @@ property("Accept-Ranges Header") = secure {
, ("Cookie: SESSID=298zf09hf012fh2; httponly"
, Cookie(HttpCookie("SESSID", "298zf09hf012fh2", None, None, None, None, false, httpOnly = true, Map.empty))
, "Cookie: SESSID=298zf09hf012fh2; httponly")
+ , ("Cookie: __utmz=118721.140907.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); Currency=%22usd%22"