[Examples] Function signature

type Callback = (?Error, string) => any

function fetch (callback: Callback) {

[Examples] Examples

var myNumbers: Array<number> = [42]
function foo(): any { return 42 }
var b: boolean = false
var b: ?boolean = false  /* maybe */
var b: string | boolean = false

var a: Class<MyClass> = MyClass
var b: MyClass = new a()

[Advanced features] React

type Props = {
  bar: number,

type State = {
  open: boolean,

class Foo extends React.Component<Props, State> {
  // Component code

[Advanced features] Comment syntax

  export type Foo = { ... }

function add(n /*: number */) { ... }

[Advanced features] Imports

import type { Person } from '../person'
import typeof Config from '../config'
export type Person = { id: string }

[Advanced features] Functions

const callback: () => void = function () {}
function filter<T> (
  list: Array<T>,
  callback: (item: T) => boolean
): Array<T> {

See: Functions

[Advanced features] Interfaces

interface Jsonable {
  toJSON(): string

class Foo {
  toJSON() { return '{}' }

(new Foo: Jsonable)

See: Interfaces

[Advanced features] Generic classes

class GenericClass<T> {
  x: T
  constructor (x: T) { ... }

var n: GenericClass<number> = new GenericClass(0)

See: Generic classes

[Advanced features] Type aliases

type Tree = {
  foo: string,
  bar: number,
  qux: (foo: string, bar: number) => boolean

type Generic<T> = {
  foo: T

See: Type aliases

[Advanced features] Enums

type Suit = "Diamonds" | "Clubs" | "Hearts" | "Spades"

const countries = {
  US: "United States",
  IT: "Italy",
  FR: "France"

type Country = $Keys<typeof countries>

See: Enums

[Advanced features] Primitives

Type Description
void undefined
null null (but not undefined)
--- ---
{a: Number} Object with a shape
[any, number] Tuples (fixed-length arrays)
--- ---
--- ---
?number Maybe (number, void, null)
a | b Union types

[Objects] Dynamic keys

type Items = {
  [key: string]: Item

{: data-line="2"}

See: Dynamic object keys

[Objects] Exact object types

type Artist = {|
  name: string,
  label: string

{: data-line="1,4"}

const a: Artist = {
  name: 'Miguel Migs',
  label: 'Naked Music',
  genre: 'House' // ✗ Error

{: data-line="4"}

Exact object types prevent extra properties from being added to an object.

See: Exact object types

[Objects] Width subtyping

type Artist = {
  name: string,
  label: string
const a: Artist = {
  name: 'Miguel Migs',
  label: 'Naked Music',
  genre: 'House' // ✓ OK

{: data-line="6"}

A type with more properties is "wider" and is a subtype of a "narrower" type.

See: Width subtyping


{: .-three-column}

[Optionals] Optional properties

type Album = {
  name?: string

{: data-line="2"}

const a: Album = { } // ✓ OK
a.name = 'Blue'      // ✓ OK
a.name = null        // ✗ Error
a.name = undefined   // ✓ OK

This makes an Album valid even if name is not part of the keys. This is different from "maybe" types.

See: Optional properties

[Optionals] Maybe types

type Album = {
  name: ?string

{: data-line="2"}

const a: Album = { }                 // ✗ Error
const a: Album = { name: 'Blue' }    // ✓ OK
const a: Album = { name: null }      // ✓ OK
const a: Album = { name: undefined } // ✓ OK

This makes name either a string or null.

See: Maybe types

[Getting started] Union types

type Action = number | string
type Direction = 'left' | 'right'

See: Unions

[Getting started] Importing and exporting

import type { Person } from './types'
export type Person = {

See: Module types

[Getting started] Variables

const count: number = 200

You typically don't need to do this, function args are often enough.

See: Variable types

[Getting started] Type aliases

type Person = {
  name: string,
  age: number,
  isAdmin: boolean,
  likes: Array<string>

{: data-line="1,2,3,4,5,6"}

function greet(user: Person) {
  console.log('hello', user.name)

{: data-line="1"}

greet({ name: 'Miles Davis', ··· })

This is the typical way to define the shape of complex objects.

[Getting started] Type inference

function square (n: number) {
  const result = n * n

{: data-line="2"}

result is inferred to be a number because number * number will result in a number. There's no need to give it annotations.

[Getting started] Simple example

{: .-prime}

/* @flow */
function square (n: number) {
  return n * n

const four = square(2)

{: data-line="1,2"}

Most of what you need to do is to simply add annotations to function arguments!

See: flow.org docs

Getting started

{: .-three-column}



dplyr cheat sheet is a quick reference for dplyr that is a grammar of data manipulation, providing a consistent set of verbs that help you solve the most common data manipulation challenges.


A regular expression is a sequence of characters that specifies a search pattern.


PySpark is an interface for Apache Spark in Python. It not only allows you to write Spark applications using Python APIs


Go is a statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson.


Watchman exists to watch files and record when they change. It can also trigger actions (such as rebuilding assets) when matching files change.


Rollup Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application.


Bluebird is a fully-featured Promise library for JavaScript. The strongest feature of Bluebird is that it allows you to "promisify" other Node modules in order to use them asynchronously. Promisify is a concept applied to callback functions.


Flow is a static type checker for your JavaScript code. It does a lot of work to make you more productive. Making you code faster, smarter, more confidently, and to a bigger scale.

Node.Js Api

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

C Preprocessor

Quick reference for the C macro preprocessor, which can be used independent of C/C++.


Sass is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets. SassScript is the scripting language itself. Sass consists of two syntaxes.


Active Admin is a Ruby on Rails plugin for generating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort.


The Fetch standard defines requests, responses, and the process that binds them: fetching.


$ http POST http://example.com name="John" Host:example.com — JSON, cookies, files, auth, and other httpie examples.


RSpec is a computer domain-specific language testing tool written in the programming language Ruby to test Ruby code. It is a behavior-driven development framework which is extensively used in production applications.


Sauce Labs allows users to run tests in the cloud on more than 700 different browser platforms, operating systems, and device combinations.


Jasmine is a behavior-driven development framework for testing JavaScript code.


Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.


Ubuntu is a Linux distribution based on Debian and composed mostly of free and open-source software. Ubuntu is officially released in three editions: Desktop, Server, and Core for Internet of things devices and robots.

Rails Models

Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under the MIT License. Rail is a model–view–controller framework, providing default structures for a database, a web service, and web pages.

Git Log

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.


Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller framework, providing default structures for a database, a web service, and web pages.

Ansible Examples

Ansible is an open-source software provisioning, configuration management, and application-deployment tool enabling infrastructure as code.

Bolt Quickstart

A quick guide to getting started writing Bolt tasks


RSpec Rails defines ten different types of specs for testing different parts of a typical Rails application.


rsync is a utility for efficiently transferring and synchronizing files between a computer and an external hard drive and across networked computers by comparing the modification times and sizes of files.

Ledger Cli

Ledger is a command-line based double-entry bookkeeping application. Accounting data is stored in a plain text file, using a simple format, which the users prepare themselves using other tools.


Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system macOS as well as Linux.


Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.