- Manage shared state
- Allow for subscriptions from React
- Allow for mutation from React
- Allow for subscriptions from non-React
- Allow for mutation from non-React
- Allow for methods on the global state
- Allow for derived data on the global state
- Optimized re-renders
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 * as NanoTimer from "nanotimer"; | |
import { get } from "lodash"; | |
const foo = { | |
bar: { | |
baz: 1, | |
}, | |
}; | |
const iterateWithOptionalChaining = () => { |
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
<div class="mx-auto max-w-screen-xl"> | |
<div style="grid-template-columns: 1fr 2fr 3fr;" class="grid gap-4 m-4"> | |
<img | |
src="http://valleygrowlers.com/wp-content/uploads/2013/11/clean_line_circle_logo-300x300.jpg" | |
/> | |
<div | |
class="text-2xl" | |
> | |
Come join us every day starting at noon… Valley Growlers would love to have you as a guest. Come have a pint or take a growler or crowler to go.... | |
</div> |
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 inject = (str, obj) => str.replace(/\${(.*?)}/g, (_, g) => obj[g]); | |
console.log( | |
inject("Hello ${name}, Bye ${name2}", { name: "Jack", name2: "Dave" }) | |
); |
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
/* | |
Make a simple text game that has: | |
[X] Has a design using a flowchart | |
[X] Uses deeply nested conditionals | |
[X] Handles edge cases | |
[X] Uses variables with a variety of the basic data types (string, bool, int, long, float, double) | |
[X] Uses random | |
[X] Uses a mathematical operator | |
[X] No gotos or globals |
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
#include <iostream> | |
#include <list> | |
using namespace std; | |
int getValue(int index) { | |
int guessValue = 0; | |
/* | |
while (guessValue < 1 || guessValue > 100) { | |
cout << "Guess #" << index + 1 << ": "; |
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
#include <random> | |
#include <iostream> | |
#include <sstream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int rollDice(int top) { | |
return (rand() % top) + 1; |
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 { Component } from "react"; | |
import { | |
ChakraProvider, | |
Heading, | |
Box, | |
Text, | |
Grid, | |
Image, | |
} from "@chakra-ui/react"; |
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 { atom, WritableAtom } from "jotai"; | |
import firebase from "firebase"; | |
function atomWithCollection<TData>( | |
collection: firebase.firestore.CollectionReference | |
): WritableAtom< | |
TData[], | |
{ | |
id: string; | |
data: TData; |
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
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
// Generic print function that takes an output stream. | |
// Can be used to print to the screen by passing cout. | |
// Can be used to print to a file by passing a file stream. | |
void printSomething(ostream &out, string somethingToSay) { | |
out << "Something cool:" << somethingToSay << endl; |