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 PrimitiveValue = string | null | number | boolean; | |
interface JSONValue { | |
[k: string]: PrimitiveValue | JSONValue | Array<PrimitiveValue> | Array<JSONValue>; | |
} | |
type JSONData = PrimitiveValue | JSONValue | Array<PrimitiveValue> | Array<JSONValue>; |
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
interface Schema { | |
posts: Array<{ | |
id: number; | |
title: string; | |
views: number; | |
}>; | |
user: { | |
name: string; | |
}; | |
} |
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'; | |
class ErrorBoundary extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
error: null, | |
errorInfo: null, | |
}; |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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 hasAARequest = (context) => { | |
return context.AARequest; | |
} | |
const dropAARequest = assign({ | |
AARequest: () => null, | |
}); | |
const REQUEST_SUBMISSION = { | |
id: 'RequestSubmission', |
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
/* | |
If you have seperate github accounts for personal use and work, but use the same laptop. | |
Taken from this StackOverflow answer: https://stackoverflow.com/a/43884702 | |
*/ | |
/* | |
Have two folders, ~/company is going to house all your company repos and | |
~/personal is going to house all your personal projects | |
*/ |
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 Stack() { | |
this.min = Infinity; | |
this.values = []; | |
} | |
Stack.prototype.push = function(value) { | |
this.values[this.values.length] = value; // Using this logic since .push() was banned from use. | |
if (value < this.min) { | |
this.min = value; |
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 Menu() { | |
this.items = []; | |
} | |
Menu.prototype.addItem = function(item) { | |
this.items.push(item); | |
return this; // This allows for chaining | |
} | |
Menu.prototype.showMenu = function() { |
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
/* | |
Question: Assume .bind does not exist. | |
Implement the .bind functionality using .apply() | |
*/ | |
Function.prototype.bind = function(thisArg) { | |
// Get a reference to the function that you want to bind | |
let functionToBind = this; | |
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
... | |
<body> | |
<script type="text/javascript"> | |
document.addEventListener('visibilitychange', () => { | |
if (document.visibilityState === 'hidden') { | |
document.title = '😴'; | |
} | |
if (document.visibilityState === 'visible') { | |
document.title = '😁'; |
NewerOlder