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
// In this component, React "strict mode" is disabled. The main focus of this quiz is <MainComponent />. | |
// <ReactLifecycleQuiz /> is a simple parent component that wraps <MainComponent />. | |
import { useEffect, useRef, useState } from 'react' | |
export const ReactLifecycleQuiz = () => { | |
const [parentValue, setParentValue] = useState(0) | |
const _handleClick = () => { | |
setParentValue(parentValue + 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
#!/usr/bin/env sh | |
DIR="/Users/samuelbossley/Repos/segway-next" | |
opts="\ | |
-R \ | |
--exclude-dir ${DIR}/build \ | |
--exclude-dir ${DIR}/coverage \ | |
--exclude-dir ${DIR}/node_modules \ | |
--exclude-dir ${DIR}/.yarn \ |
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 AWS = require('aws-sdk'); | |
const docClient = new AWS.DynamoDB.DocumentClient(); | |
/** | |
* Given a parameters object, scans a table and returns the items in the response. | |
* If no valid matching items are found, returns a response containing an empty array. | |
* @param {object} params - DynamoDB scan params | |
* @param {boolean} recursiveEvaluate - boolean whether operation should continue | |
* until all results are retrieved. Default value is true. | |
*/ |
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 AWS = require('aws-sdk'); | |
const docClient = new AWS.DynamoDB.DocumentClient(); | |
/** | |
* Given a parameters object, queries a table and returns the items in an array. | |
* If no valid matching items are found, returns an empty array. | |
* @param {object} params - DynamoDB query params | |
* @param {boolean} recursiveEvaluate - boolean whether operation should continue | |
* until all results are retrieved. Default value is true. | |
*/ |
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
#pragma once | |
/** | |
* A dynamically sizeable array implementation. | |
*/ | |
template <class T, class I = unsigned short> | |
class DynamicList { | |
private: | |
// the array storing all values |
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 <stdio.h> | |
#include <Windows.h> | |
#include <string> | |
// define a pair of integer and string | |
struct NameNumPair { | |
// constructor | |
NameNumPair(int _num, std::string _name) { | |
num = _num; | |
name = _name; |
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
/** | |
* Given an optional percentage chance between 0 and 1, generates a random | |
* boolean value with the chance percentage. The default percentage chance | |
* is 0.5, or 50%. | |
* @param {double} perc - percentage chance true | |
* @return {boolean} chance | |
*/ | |
exports.rnBool = function (perc = 0.5) { | |
// Because Math.random is [0, 1), percentage needs to be inversed | |
let invPerc = 1 - perc; |