This file contains hidden or 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 delay = <T>(time: number, data: T): Promise<T> => | |
new Promise((resolve) => | |
setTimeout(() => { | |
resolve(data); | |
}, time) | |
); | |
class Users { | |
async getUsers() { | |
return await delay(1000, []); |
This file contains hidden or 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
class EventProcessor { | |
handleEvent(eventName: ..., data: ...): void { | |
} | |
addHandler(handler: ...) { | |
} | |
getProcessedEvents(): ...[] { | |
} | |
} |
This file contains hidden or 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
[ | |
{ "name": "Atreides", "planets": "Calladan" }, | |
{ "name": "Corrino", "planets": ["Kaitan", "Salusa Secundus"] }, | |
{ "name": "Harkonnen", "planets": ["Giedi Prime", "Arrakis"] } | |
] |
This file contains hidden or 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; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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" }) | |
); |