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
<!doctype html> | |
<html> | |
<head> | |
<title>Reaction Tester</title> | |
<meta charset="utf-8" /> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<link rel="stylesheet" href="main.css"> |
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
<!--HEADER--> | |
<header> | |
<div class="container"> | |
<div class="row"> | |
<div class="twelve columns"> | |
<nav> | |
<ul> | |
<li><a href="#">About</a></li> | |
<li><a href="#">Work</a></li> |
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
{- OVERVIEW ------------------------------------------------------ | |
A "Tree" represents a binary tree. A "Node" in a binary tree | |
always has two children. A tree can also be "Empty". Below I have | |
defined "Tree" and a number of useful functions. | |
This example also includes some challenge problems! | |
-----------------------------------------------------------------} |
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
type Required<T> = { | |
[K in keyof T]: Schema<T> | |
} | |
interface ObjectSchema<T> { | |
type: 'object' | |
required: Array<keyof T> | |
properties: Required<T> | |
} |
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 fetchComments = async ({ | |
postId, | |
host | |
}: RequestInfo): Promise<Result<Array<Comments.Schema>, string>> => { | |
try { | |
const comments = await db(Comments.Table.name) | |
.select(everything(Comments.Table)) | |
.join( | |
Posts.Table.name, | |
`${Comments.Table.name}.${Comments.Table.cols.post_id}`, |
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
const BUFFER_CAPACITY: usize = 4; | |
pub struct Buffer { | |
size: usize, | |
read_idx: usize, | |
write_idx: usize, | |
buffer: [u8; BUFFER_CAPACITY] // unsigned 8bit integer | |
} | |
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
{- | |
Note that we use the `riskyRequest` function because this | |
webapp uses Cookies for authentication. | |
These cookies come from a different domain than the one | |
that host this app | |
-} | |
module Api exposing | |
( adminSignup | |
, adminSignin | |
, getAdminSession |
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
const pickFunc = <T extends {}, K extends keyof T>( | |
obj: T, | |
predicate: (k: string) => boolean | |
): Pick<T, K> => | |
Object | |
.keys(obj) | |
.filter(predicate) | |
.reduce((filteredObj: Pick<T, K>, key) => ({ | |
...filteredObj, | |
[key]: obj[key as keyof T] |
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
-- A tree contains 2 kinds of nodes | |
-- at depths 1 through 2 you will have a node with a 'replies' field | |
-- at depth 3 the node is missing a 'replies' field | |
type alias TreeNode a = | |
{ a | |
| body : String | |
} |
OlderNewer