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, { useRef, useCallback, useEffect } from 'react' | |
import { GestureResponderEvent, PixelRatio } from 'react-native' | |
import { GLView } from 'expo-gl' | |
import Expo2DContext, { Expo2dContextOptions } from 'expo-2d-context' | |
const App = (): React.ReactElement => { | |
const ctxRef = useRef<Expo2DContext | null>(null) | |
const pixelRatio = PixelRatio.get() | |
let originPos = [0, 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
// import useRouterQueryState from '../hooks/useRouterQueryState' | |
// const [myState, setMyState] = useRouterQueryState(propertyName, defaultValue) | |
import { useState, useEffect } from 'react' | |
import { useRouter } from 'next/router' | |
function useRouterQueryState (key, defaultValue) { | |
const router = useRouter() | |
// Get initial state from router query or default 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
/* | |
Usage: | |
import { ItemContextProvider } from 'hooks/useItem' | |
<ItemContextProvider | |
item={item} | |
> | |
<ComponentThatUsesItem /> |
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 } from 'react' | |
import ReactMapGL, { Marker } from 'react-map-gl' | |
import { WebMercatorViewport } from '@deck.gl/core' | |
const getBoundsForPoints = (points, { width = 200, height = 500, padding = 0 } = {}) => { | |
// Calculate corner values of bounds | |
const pointsLong = points.map(point => point.coordinates._long) | |
const pointsLat = points.map(point => point.coordinates._lat) | |
const cornersLongLat = [ | |
[Math.min(...pointsLong), Math.min(...pointsLat)], |
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, { useContext } from 'react' | |
import { UserContext, UserContextProvider } from './UserContext' | |
export default (props) => { | |
const [user, setUser] = useContext(UserContext) | |
return ( | |
<UserContextProvider user={null}> | |
<div>User name: {user && user.name}</div> | |
</UserContextProvider> |
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
/** | |
* parallelPool module | |
* @description A resource pool e.g. for projects. Inspired by https://www.npmjs.com/package/generic-pool | |
* @module parallelPool | |
* @author Tom Söderlund | |
*/ | |
// Private functions | |
/* const projectPool = new ParallelPool({}) */ |
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
[ | |
{ | |
"name": "indianred", | |
"hexValue": "#cd5c5c", | |
"rgbValues": [205, 92, 92], | |
"hslValues": [0, 0.531, 0.582] | |
}, | |
{ | |
"name": "lightcoral", | |
"hexValue": "#f08080", |
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
#!/bin/sh | |
# Example: kill all non-development apps: | |
# . killapps.sh dev | |
# Example: kill all non-office apps in a soft way: | |
# . killapps.sh office soft | |
# Strip leading and trailing white space (new line inclusive). | |
trim () { | |
[[ "$1" =~ ^[[:space:]]*(.*[^[:space:]])[[:space:]]*$ ]] |
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
/* | |
Adapted from Lian Li’s (@chimney42) example: | |
https://slidr.io/Chimney42/machine-learning-with-synaptic | |
https://www.youtube.com/watch?v=M5glN6XjDv8 | |
You need to include synaptic.js - visit https://caza.la/synaptic/ | |
See my own tests at https://codepen.io/tomsoderlund/pen/MvLZLW | |
*/ |
NewerOlder