Skip to content

Instantly share code, notes, and snippets.

@firstdoit
firstdoit / stateless-component-typescript.tsx
Created May 4, 2017
How to write a React stateless (functional) component in TypeScript
View stateless-component-typescript.tsx
import * as React from 'react'
const Button: React.StatelessComponent<{}> = ({children}) => (
<button
className="f4 br2 grow no-underline ph5 pv3 dib white bg-dark-pink bn shadow-3 w-100 w-auto-ns b">
{children}
</button>
)
export default Button
@firstdoit
firstdoit / stateless-component-typescript-error.tsx
Last active May 4, 2017
How to write a React stateless (functional) component in TypeScript
View stateless-component-typescript-error.tsx
import * as React from 'react'
const Button = ({children}) => (
<button
className="f4 br2 grow no-underline ph5 pv3 dib white bg-dark-pink bn shadow-3 w-100 w-auto-ns b">
{children}
</button>
)
export default Button
View vtex-render-intro.md

VTEX Render - Straight to React

Production-ready Universal React Apps in 5 minutes

Publishing a fast, production-ready server side rendered React app takes a lot of effort. Platforms, build servers, CI, CD, CSS frameworks... So many choices, so little time.

VTEX Render is a web framework that let's you go "Straight to React"®. You just need an editor and a small CLI to sync your files. Updates are blazing-fast and it even does hot module replacement. By using GraphQL for data fetching, functional CSS for styling and a robust component library, developers create beautiful apps in hours, not weeks. Not only that: non-technical users can customize VTEX Render apps in a beautiful WYSIWYG interface.

VTEX Render is a refreshingly simple approach to building scalable web apps, fast.

View keybase.md

Keybase proof

I hereby claim:

  • I am firstdoit on github.
  • I am firstdoit (https://keybase.io/firstdoit) on keybase.
  • I have a public key whose fingerprint is E635 402F DFAB 17A0 D560 C3AC A0DA EDB7 003A C77F

To claim this, I am signing this object:

View underscore-2.8.js
_.chain(students)
.filter(isApproved)
.pluck('grades')
.flatten()
.min() // Can you guess what this does?
.value()
// 6
View underscore-2.7.js
_.every(studentsByClass["A"], isApproved) // false
_.every(studentsByClass["B"], isApproved) // true
View underscore-2.6.js
var studentGrades = _.pluck(studentsByClass["A"], 'grades')
// [[7.0, 6.9, 8.0], [5.0, 8.7, 3.7]] - not very useful
var grades = _.flatten(studentGrades)
// [7.0, 6.9, 8.0, 5.0, 8.7, 3.7]
average(grades)
// 6.55
View underscore-2.5.js
var studentsByClass = _.groupBy(students, 'class')
// Same result! Neat.
View underscore-2.4.js
var studentsByClass = _.groupBy(students, function (student) { return student.class })
/* {
"A": [
{ name: "John", grades: [7.0, 6.9, 8.0], class: "A" },
{ name: "Paul", grades: [5.0, 8.7, 3.7], class: "A" }
],
"B": [
{ name: "Luke", grades: [9.0, 8.2, 6.2], class: "B" },
{ name: "Mark", grades: [6.0, 9.0, 8.4], class: "B" }
]
View underscore-2.3.js
_.pluck(approvedStudents, 'name')
// ["John", "Luke", "Mark"]