Skip to content

Instantly share code, notes, and snippets.

View jadehopepunk's full-sized avatar

Jade jadehopepunk

  • Melbourne, Australia
View GitHub Profile
// Option 1
const result = stepOne(input).stepTwo().stepThree()
// Option 2
let result = input
result = stepOne(result)
result = stepTwo(result)
result = stepThree(result)
const result = stepOne(input).stepTwo().stepThree()
const steps = [
stepOne,
stepTwo,
stepThree
]
const result = runSteps(steps)
@jadehopepunk
jadehopepunk / main.dart
Created April 21, 2019 03:04
Function as child containing state
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
var auth = new Auth();
return MaterialApp(
title: 'Pod',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.amber),
home: WithAuth(auth: auth, builder: (user) => DummyRootPage()));
export function fetchWithHeaders(url: string, jwt: ?string = null, params: ParamType = {}) {
const customHeaders = params.headers || {}
const otherParams = omit(params, 'headers')
const headers = {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-Token': window.rippleCSRF,
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
...customHeaders
}
[
{
"uuid": "9d750b19-1319-425c-add6-f091181cf65a",
"type": "asteroid",
"position": [12.3, 34.2],
"radius": 20.3,
}
]
function animate(posX, posY, directionX, directionY, delta) {
return {
x: posX + (directionX * delta),
y: posY + (directionY * delta)
}
}
function animate(pos, direction, delta) {
return pos.plus(direction.scaleBy(delta))
}
function isValidOrder(order, customer) {
return
order.units > 1 &&
order.state == 'complete' &&
includingSalesTax(order.price) < customer.availableBalance
}