This file contains 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
function logCar(array) { | |
console.log("I'm a " + array['color'] + " " + array['make']); | |
} | |
// Example call for functional version: | |
logCar({ color: 'blue', make: 'BMW' }); | |
This file contains 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
defmodule Filter do | |
def start_flow do | |
streams() | |
|> Flow.from_enumerables() | |
|> Flow.filter(&Regex.match?(~r/publishing/, &1)) | |
|> Flow.map(&get_key_and_payload(&1)) | |
|> Flow.partition(key: {:elem, 0}) | |
|> Flow.reduce(fn -> %{} end, fn x, acc -> | |
Map.put_new(acc, elem(x, 1), elem(x, 2)) | |
end) |
This file contains 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
def start_flow do | |
streams() | |
|> Flow.from_enumerables() | |
|> Flow.filter(&Regex.match?(~r/publishing/, &1)) | |
|> Flow.map(&get_key_and_payload(&1)) | |
|> Flow.partition(key: {:elem, 0}) | |
|> Flow.reduce(fn -> %{} end, fn x, acc -> | |
Map.put_new(acc, elem(x, 1), elem(x, 2)) | |
end) | |
end |
This file contains 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 React from "react" | |
import { Link } from "gatsby" | |
import Layout from "../components/layout" | |
const BlogPost = ({data: {post}}) => ( | |
<Layout> | |
<h1>{post.title}</h1> | |
<h4>By <Link to={`/author/${post.author.slug}`}>{post.author.name}</Link></h4> | |
<p>{post.publishDate}</p> |
This file contains 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
export const query = graphql` | |
query ($id: String!) { | |
post: postsJson(id: {eq: $id}) { | |
title | |
slug | |
content | |
publishDate(formatString: "MMMM DD, YYYY") | |
tags | |
author { | |
slug |
This file contains 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
export const query = graphql` | |
fragment postFields on PostsJson { | |
slug | |
title | |
content | |
publishDate(formatString: "MMMM DD, YYYY") | |
tags | |
} | |
fragment authorFields on AuthorsJson { |
This file contains 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 { graphql } from 'gatsby' | |
export const postFields = graphql` | |
fragment postFields on PostsJson { | |
slug | |
title | |
content | |
publishDate(formatString: "MMMM DD, YYYY") | |
tags | |
} |