Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jonathan Creamer jcreamer898

🏠
Working from home
View GitHub Profile
View README.md

Type 'from' in the editor and...

View typescript.md

What even is TypeScript?

JavaScript + Types = Typescript

TypeScript as a compilter

npm i -g typescript

./node_modules/.bin/tsc

View vershion.sh
#!/bin/sh
set -e
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
@jcreamer898
jcreamer898 / README.md
Created Jul 13, 2012
Using amplifyjs as with RequireJS 2.0
View README.md

Using AmplifyJS with RequireJS 2.0

With the lastest version of Require, a new config object was introduced, the shim.

http://requirejs.org/docs/api.html#config-shim

That allows Amplify to now be used within AMD projects.

Have Fun!

View react-lifecycle.md
Name of thing Sorta like... Mounted? Can you even setState? What would you say... ya do here?
constructor initialize() nope nope init stuff NO side effects
componentWillMount beforeDomReady() nope yeah but don't Only needed in createClass now use constructor for most things
render render nope please no render stuff and don't set any state please
componentDidMount domReady() yup yup DOM is a go init jQuery plugins dispatch stuff
componentWillReceiveProps onChange() yup yup
View formatPriceJsDoc.ts
// @ts-check
/**
* Format a price
* @param num {number} The price
* @param symbol {string} The currency symbol
*/
const formatPrice = (num, symbol = "$") =>
`${symbol}${num.toFixed(2)}`;
formatPrice("1234");
View price.tsx
import * as React from "react";
import formatPrice from "../utils/formatPrice";
export interface IPriceProps {
num: number;
symbol: "$" | "€" | "£";
}
const Price: React.SFC<IPriceProps> = ({
num,
View formatPrice.ts
const formatPrice = (num: number, symbol = "$": string) =>
`${symbol}${num.toFixed(2)}`; formatPrice("1234");
// num.toFixed is not a function
@jcreamer898
jcreamer898 / formatPrice.js
Last active Feb 2, 2018
Stuff for my typescript blog
View formatPrice.js
const formatPrice = (num, symbol = "$") =>
`${symbol}${num.toFixed(2)}`; formatPrice("1234");