- Run
yarn create react-app my-app --typescript cd my-app
package me.dphil.statistics | |
import java.util.Random; | |
import java.util.concurrent.TimeUnit; | |
/** | |
* Many people have written this before and many will write it again. I | |
* wrote it because it was faster than looking for someone else's solution. | |
*/ | |
public class PackStatistics { |
// ----- Definition ----- | |
class SafeMap<V> { | |
private readonly o: { [key: string]: V } = {}; | |
public put(key: string, value: V): void { | |
this.o[key] = value; | |
} | |
public has<K extends string>(key: K): this is SafeMapWithKey<K, V> { |
enum DateStringBrand {} | |
export type DateString = string & DateStringBrand; | |
function of(date: string | number | Date): DateString { | |
// This branching needed to satisfy TypeScript. | |
const dateObject = | |
typeof date === "string" | |
? new Date(date) | |
: typeof date === "number" ? new Date(date) : new Date(date); |
import { TypedAction, TypedActionString } from "redoodle"; | |
import { | |
ForkEffect, | |
takeEvery, | |
takeLatest, | |
throttle, | |
} from "redux-saga/effects"; | |
type HelperFunc0<A> = (action: A) => any; | |
type HelperFunc1<A, T1> = (arg1: T1, action: A) => any; |
import Benchmark from "benchmark"; | |
const array: number[] = []; | |
for (let i = 0; i < 100000; i++) { | |
array.push(i); | |
} | |
function map<T, U>(arr: T[], f: (item: T) => U): U[] { | |
const result: U[] = []; | |
for (let i = 0, { length } = arr; i < length; i++) { |
import classNames from "classnames"; | |
import React, { memo, ReactElement } from "react"; | |
import "./__NAME__.scss"; | |
interface Props { | |
className?: string; | |
} | |
const __NAME__ = memo(function __NAME__({ className }: Props): ReactElement { | |
return ( |
A minimal set of commands for using Git to collaborate using pull requests.
Note that this is not the only way to do this, but it is one way that works. If someone says to do something else, they aren't necessarily wrong- it could just be a different means of accomplishing the same thing.
Check out the latest version of master
from GitHub:
So you need to read a Rust program and you've never seen rust before?
Rust has a well-earned reputation for being a difficult language because of its strict ownership rules, complex type system, and general assumption that anyone learning it has unlimited time and patience. But there's good news! Just because Rust is hard to write doesn't mean it has to be hard to read.
In fact, once you learn a few basics, you might find that Rust is a fairly easy