This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from "react"; | |
import { pipe } from "callbag-basics"; | |
import subscribe from "callbag-subscribe"; | |
export default fns => { | |
const [value, setValue] = useState(null); | |
useEffect( | |
() => | |
pipe( | |
...fns, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
import { interval, map, pipe, merge } from "callbag-basics"; | |
import subscribe from "callbag-subscribe"; | |
import of from "callbag-of"; | |
const usePipeStream = fns => { | |
const [value, setValue] = useState(null); | |
// maybe should use useCallback on the pipe and then run it | |
useEffect( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const state = { | |
// user: { | |
// isLoggedIn: false, | |
// email: "", | |
// password: "", | |
// details: { | |
// firstName: "", | |
// lastName: "" | |
// } | |
// }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PureComponent } from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
const withState = render => | |
class extends PureComponent { | |
state = { value: "xxx" }; | |
onChange = event => this.setState({ value: event.target.value }); | |
render = () => render(this); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import withStateHandlers from 'withStateHandlers'; | |
const initialState = { | |
value: '', | |
} | |
const handlersFactory = ({ props, state, setState }) => { | |
return { | |
setValue(value) { | |
setState({ value }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { Dimensions as RNDimensions } from 'react-native'; | |
const dimensionsShape = PropTypes.shape({ | |
width: PropTypes.number, | |
height: PropTypes.number, | |
}); | |
// eslint-disable-next-line react/prop-types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default const validateBsn = (bsn = '') => { | |
// Needs to be 9 characters | |
if (bsn.length !== 9) { | |
return false; | |
} | |
const VALUES = [9, 8, 7, 6, 5, 4, 3, 2, -1]; | |
const total = bsn | |
.split('') // make it an enumerable | |
.reduce((p, c, i) => Number(p) + c * VALUES[i], 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express');; | |
const app = express(); | |
app.get('/first.js', (req, res) => { | |
setTimeout(() => { | |
res.send('alert("First script")'); | |
}, 350); | |
}) | |
app.get('/second.js', (req, res) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do (jQuery) -> | |
$ = jQuery | |
insertAtCaret = (value) -> | |
if document.selection # IE | |
@focus() | |
sel = document.selection.createRange() | |
sel.text = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do (jQuery) -> | |
$ = jQuery | |
wrap = (fn) -> | |
(e) -> | |
fn e | |
do e.stopPropagation | |
do e.preventDefault | |
false |