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
//Copied from SO checking if an element is in view | |
const checkIfInView = (elementPosition, extraOffset) => | |
elementPosition.top >= 0 && | |
elementPosition.left >= 0 && | |
elementPosition.bottom + extraOffset <= | |
(window.innerHeight || document.documentElement.clientHeight) && | |
elementPosition.right + extraOffset <= | |
(window.innerWidth || document.documentElement.clientWidth); | |
//React hook that sets state when in view |
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
version: '3.3' | |
services: | |
db: | |
image: mysql:latest | |
volumes: | |
- dbdata:/var/lib/mysql | |
restart: always | |
ports: | |
- "3306:3306" |
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 styles from './styles.css'; | |
export default ({ title, }) => ( | |
<section className={styles.wrapper}> | |
{title} | |
</section> | |
); | |
/* |
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 getAppointments = Appointment => () => { | |
return Appointment.joins(:customer).where('customers.pays_a_lot = true').includes(:customer).order_by('customers.age DESC') | |
} | |
const dbmock = fakes => new Proxy({}, { | |
get: (target, name) => { | |
if(!fakes[name]) return this | |
return fakes[name] |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"outDir": "./dist/", | |
"sourceMap": true, | |
"noImplicitAny": true, | |
"module": "es2015", | |
"moduleResolution": "node", | |
"target": "es5", | |
"jsx": "react", | |
"allowJs": true, |
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 beforeInsert = ({ values, state }) => { | |
if(state.deleted) values.deleted_at = Date.now() | |
return values | |
} | |
const conversions = { | |
column_one: ({value, setState}) => { | |
if(value.match(/zz/)) setState({ deleted: true}) |
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
return ( | |
<Toggle> | |
<p toggle>some text you click to toggle</p> | |
<div on>if on, this renders!</div> | |
<div off>if off, this renders!</div> | |
</Toggle> | |
) |
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
//Useful helpers for async await in tests | |
global.sleep = time => | |
new Promise(resolve => setTimeout(() => resolve(), time)); | |
global.waitFor = (value, equal) => | |
new Promise(resolve => | |
setInterval( | |
() => { | |
if (value === equal) resolve(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 { Link } from 'react-router-dom' | |
import { loadRoute } from './route-helper' | |
export default class AsyncLink extends React.Component { | |
async loadBeforeNavigate (blockPush) { | |
let { to, dataPath } = this.props | |
let { router } = this.context | |
await loadRoute(dataPath || to.substring(1)) |
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
public function __construct(Book $bookModel, BookTransformer $transformer) | |
{ | |
parent::__construct(); | |
$this->transmit = [ | |
'transformer' => $transformer, | |
'model' => $bookModel, | |
]; | |
} |