Skip to content

Instantly share code, notes, and snippets.

@jniac
jniac / html.js
Last active March 11, 2018 13:15
scripts before oblivion
html = new Proxy({
div: document.createElement('div'),
dom(string) {
this.div.innerHTML = string
return this.div.firstChild
},
@jniac
jniac / albert-100.pug
Created March 20, 2018 21:06
html page to learn numbers [0-99] (child game)
html
head
link(href="https://fonts.googleapis.com/css?family=Roboto+Mono:100,100i,300,300i,400,400i,500,500i,700,700i" rel="stylesheet")
style
:sass
body
width: 100vw
height: 100vh
margin: 0
@jniac
jniac / integrate
Last active November 30, 2018 23:16
integrate = (f, { min = 0, max = 1, n = 1000 } = {}) => {
let s = 0
for (let i = 0; i < n; i++) {
let x = min + (max - min) * (i + 1/2) / n
s += f(x)
@jniac
jniac / SceneHelper.cs
Created October 15, 2019 14:11
SceneHelper
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SceneHelper : MonoBehaviour
{
private void OnDrawGizmos()
{
Gizmos.color = Color.yellow;
Gizmos.matrix = transform.localToWorldMatrix;
@jniac
jniac / index-setup.js
Last active January 7, 2020 12:53
Minimal index.html setup script
let style = document.createElement('style');
style.innerHTML = $`
body, body > * {
box-sizing: border-box;
position: relative;
margin: 0;
display:flex;
flex-direction
@jniac
jniac / App.tsx
Last active January 9, 2020 18:42
moviedb expo demo
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) => {
@jniac
jniac / App.jsx
Last active January 10, 2020 08:56
moviedb dimi demo app
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) => {
@jniac
jniac / index.html
Created January 12, 2020 19:30
étienne ensaama ar demo 1
<!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>
@jniac
jniac / extractValue.js
Last active September 24, 2020 13:48
super cool extractValue
// 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
@jniac
jniac / walk.js
Last active June 11, 2020 12:58
walk.js
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)