Skip to content

Instantly share code, notes, and snippets.

View AgtLucas's full-sized avatar
🌎
💀⏳🌷

Lucas AgtLucas

🌎
💀⏳🌷
View GitHub Profile
@AgtLucas
AgtLucas / PinchZoomPan.js
Created October 3, 2017 20:58 — forked from iammerrick/PinchZoomPan.js
React Pinch + Zoom + Pan
import React from 'react';
const MIN_SCALE = 1;
const MAX_SCALE = 4;
const SETTLE_RANGE = 0.001;
const ADDITIONAL_LIMIT = 0.2;
const DOUBLE_TAP_THRESHOLD = 300;
const ANIMATION_SPEED = 0.04;
const RESET_ANIMATION_SPEED = 0.08;
const INITIAL_X = 0;
@AgtLucas
AgtLucas / children-as-function.js
Created October 3, 2017 10:16 — forked from iammerrick/children-as-function.js
Which API do you prefer? Passing a function into the Ratio component or making a higher order component called Ratio you can use to configure a component.
<Ratio width={Ratio.OPTIONS.FLUID} x={3} y={4}>
{(width, height) => (
<Chart id={this.props.id} width={width} height={height} />
)}
</Ratio>
@AgtLucas
AgtLucas / safari-nomodule.js
Created September 24, 2017 20:03 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
* <script nomodule>alert('no modules');</script>.
*
* This workaround is possible because Safari supports the non-standard 'beforeload' event.
* This allows us to trap the module and nomodule load.
@AgtLucas
AgtLucas / Create Reducer.md
Created September 17, 2017 13:20 — forked from fdaciuk/Create Reducer.md
Less boilerplate when create a new reducer on Redux

Create Reducer

Less boilerplate when create a new reducer on Redux

Method:

'use strict'

const createReducer = (initialState, actionHandlers) =&gt; {
@AgtLucas
AgtLucas / reactiflux-actions-action-creators-mapDispatch.md
Created September 10, 2017 17:43 — forked from markerikson/reactiflux-actions-action-creators-mapDispatch.md
Reactiflux chat: Dispatching actions, using reducers, action creators, and mapDispatchToProps

[10:39 AM] infected mushroom: Is this analogy correct?

Can we say that the store in the Redux app is like a database?
mapStateToProps is used to retrive (read) the information from the database where as
mapDispatchToPropsis used to write the information in the same database? [10:59 AM] infected mushroom: Okay, I am confused now

On official docs it says

Actions are payloads of information that send data from your application to your store

@AgtLucas
AgtLucas / PhantomTypeReasonML.md
Created September 9, 2017 19:30 — forked from busypeoples/PhantomTypeReasonML.md
Phantom types in ReasonML

Phantom types in ReasonML

Introduction

"A phantom type is a parametrised type whose parameters do not all appear on the right-hand side of its definition..." Haskell Wiki, PhantomType

The following write-up is intended as an introduction into using phantom types in ReasonML.

Taking a look at the above definition from the Haskell wiki, it states that phantom types are parametrised types where not all parameters appear on the right-hand side. Let's try to see if we can implement a similar example as in said wiki.

@AgtLucas
AgtLucas / native-virtual-dom.js
Created August 28, 2017 19:05 — forked from HenrikJoreteg/native-virtual-dom.js
Native virtual dom?
// what if this was something browsers just gave us?
const { vdom } = document;
// this is same idea as React.createElement
// or any of the other similar appraoches
const newVirtualDom = vdom('div', {className: 'some-class'}, [
vdom('p', null, 'hi')
])
// if preferred, someone could easily use JSX and precompile it
@AgtLucas
AgtLucas / README.md
Created August 20, 2017 18:31 — forked from busypeoples/README.md
Making Impossible States Impossible in ReasonML

Making Impossible States Impossible in ReasonML

Introduction

If you have already seen Richard Feldman's talk entitled "Making Impossible States Impossible" or have read "Designing with types: Making illegal states unrepresentable" then you can skip the explanations and just head straight to the Reason examples.

This post is intended to display how to model your Reason Application to prevent creating impossible states. The benefits of being able to design a feature in this way are avoiding having to deal with complex test scenarios when dealing with a set of business rules and a clear documentation of what is possible just by looking at the type definition. Long story short, let's see how this all works by implementing an example.

Requirements

@AgtLucas
AgtLucas / async_swift_proposal.md
Created August 18, 2017 10:24 — forked from lattner/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@AgtLucas
AgtLucas / function_invocation.js
Created June 18, 2017 20:03 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);