This file contains hidden or 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
D = n => Math.ceil(n * Math.random()) | |
run = ({ name = 'run', d1, d2, n = 100000 } = {}) => { | |
result = { | |
win: 0, | |
loose: 0, | |
equals: 0, | |
} |
This file contains hidden or 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
// https://gist.github.com/jniac/39eabea6b06a9be5be348c11447c249c | |
/** | |
* 'prune' will simplify any tree (target) by removing any 'autoKey' | |
* found by its inner value. eg: | |
* | |
* `prune({ text:{ en:'foo', fr:'toto' }}, 'en') // -> { text:'foo' }` | |
* `prune({ text:{ en:'foo', fr:'toto' }}, 'fr') // -> { text:'toto' }` | |
* @param {object} target | |
* @param {...string} autoKeys | |
*/ |
This file contains hidden or 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
function ScreenScalar(props = { p1:1, p2:1 }) { | |
const compute = () => this.value = 1 - Object.values(props).reduce((r, v) => r * (1 - v), 1) | |
compute() | |
for (const key of Object.keys(props)) { | |
Object.defineProperty(this, key, { | |
get: () => props[key], | |
set: value => { |
This file contains hidden or 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
function deepClone(target) { | |
if (!target || typeof target !== 'object') | |
return target | |
const clone = Array.isArray(target) ? [] : {} | |
for (const [key, value] of Object.entries(target)) { | |
clone[key] = deepClone(value) |
This file contains hidden or 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
function* walk(object, currentPath = []) { | |
for (let [key, value] of Object.entries(object)) { | |
const path = [...currentPath, key] | |
yield [key, value, path] | |
if (value && typeof(value) === 'object') | |
yield* walk(value, path) |
This file contains hidden or 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
// https://gist.github.com/jniac/35ec5237a0b06359ae37ba5802e12bef | |
const isNullOrUndefined = item => item === null || item === undefined | |
const isObject = item => !!(item && typeof item === 'object') | |
const clone = object => { | |
if (!isObject(object)) | |
return object |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<meta http-equiv='X-UA-Compatible' content='IE=edge'> | |
<title>ar demo</title> | |
<script src='https://aframe.io/releases/0.9.2/aframe.min.js'></script> | |
<script src="https://raw.githack.com/jeromeetienne/AR.js/master/aframe/build/aframe-ar.min.js"></script> | |
<script src="https://raw.githack.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script> | |
<script> |
This file contains hidden or 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 { StyleSheet, Text, View, TextInput, KeyboardAvoidingView } from 'react-native'; | |
import Button from './src/view/Button' | |
import Movies from './src/view/Movies' | |
const API_KEY = '870c92db52a5e74ad6c1b6b06b19cfb9' | |
const API_MOVIE_ENDPOINT = 'https://api.themoviedb.org/3/search/movie' | |
const getSearchUrl = (query, page = 1) => { |
This file contains hidden or 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 { StyleSheet, Text, View, TextInput, KeyboardAvoidingView } from 'react-native'; | |
import Button from './src/view/Button' | |
import Movies from './src/view/Movies' | |
const API_KEY = '870c92db52a5e74ad6c1b6b06b19cfb9' | |
const API_MOVIE_ENDPOINT = 'https://api.themoviedb.org/3/search/movie' | |
const getSearchUrl = (query:string, page:number = 1) => { |
This file contains hidden or 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
let style = document.createElement('style'); | |
style.innerHTML = $` | |
body, body > * { | |
box-sizing: border-box; | |
position: relative; | |
margin: 0; | |
display:flex; | |
flex-direction |