Note: I recommend reading this gist in order because
Examples 1-6
build on each other.
- Example 1: Getting Console Input With
Console.ReadLine
How to get console input.- Example 2: Parsing The Console Input From
String
ToInt32
How to convert the console input into a numeric value.- Example 3: Validating Console Input With
Int32.TryParse
How to validate numeric input to prevent bugs in your code.- [Example 4: Looping Until User Provides Valid Input](https://gist.github.com/ZacharyPatten/798ed612
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 { useState } from 'react'; | |
export function useCounter(initial = 0) { | |
const [count, setCount] = useState(initial); | |
return [count, () => setCount(count + 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
{ | |
"parser": "@typescript-eslint/parser", | |
"parserOptions": { | |
"project": "./tsconfig.json", | |
"tsconfigRootDir": "." | |
}, | |
"env": { | |
"browser": true, | |
"jest/globals": 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 childProcess = require('child_process'); | |
const puppeteer = require('puppeteer'); | |
const request = require('request-promise-native'); | |
var delay = require('timeout-as-promise'); | |
function spawn(port) { | |
return childProcess.spawn( | |
// '/Applications/Visual\ Studio\ Code\ -\ Insiders.app/Contents/MacOS/Electron', | |
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron', | |
[ |
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 React from 'react'; | |
import { useInjection } from './ioc.react'; | |
import { IProvider } from './providers'; | |
export const Hello: React.FC = () => { | |
const provider: IProvider<string>; // here we need to inject our provider | |
return ( | |
<h1>Hello {provider.provide()}!</h1> | |
); |
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
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
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 { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable } from 'typeorm'; | |
import Company from './Company'; | |
@Entity('clients') | |
export default class Client { | |
@PrimaryGeneratedColumn() | |
id: number; | |
@Column() |
Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.
Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.
The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.
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 type { MarkdownHeading } from 'astro'; | |
type Props = { | |
headings: MarkdownHeading[]; | |
}; | |
type HeadingWithSubheadings = MarkdownHeading & { | |
subheadings: MarkdownHeading[]; | |
}; |
OlderNewer