Skip to content

Instantly share code, notes, and snippets.

View ceane's full-sized avatar
🎯
Reality

Ceane ceane

🎯
Reality
View GitHub Profile
<html>
<head>
<title>Intersection Observer API</title>
</head>
<body>
<main>
<div class="observed">
</div>
</main>
</body>
namespace Ceane
module private rec Base
type foolproof<'a> = 'a;
type present<'a> = 'a;
type available<'a> = 'a;
let REDS = 220
let SHIFT = 8
let heatmap = (i, of_) => Math.floor(
REDS * Math.sin(i / of_)
) + SHIFT + i
let backgroundColor = (item, items) =>
`rgb(233, ${heatmap(item, items > 6 ? items : 6)}, 33`
@ceane
ceane / .zshrc
Last active July 16, 2018 22:39
# locales
export LANG="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
@ceane
ceane / asort.js
Last active March 25, 2016 22:52
Simple sort
/**
* Sort an array by another array
* i.e. (blue, red, yellow, orange) -> (red, orange, yellow blue)
*
* @param {Array} a - Array to be sorted
* @param {Array} b - Array of order
*/
function asort(a, b) {
let z = [...a];
@ceane
ceane / cssSupports.js
Last active April 5, 2016 19:19
ES6 implementation of a CSS supports polyfill
/**
* Read up on the API here https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports
*/
if (!window.CSS) {
window.CSS = {};
}
if(!RegExp.escape) {
RegExp.escape = s => String(s).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
/* @flow */
/**
* Parent element with perspective attribute will not look great
*/
import React, { Component } from "react";
const cx = (...c) => c.filter(n => !!n).join(" ");
const styles = {
root: "apple-tv-parllax-root",
@ceane
ceane / ExpressionParser.js
Created October 21, 2015 04:34
Unfinished calcSizeOrPosition function (finished elsewhere...)
// Remove default params and destructuring and add "use strict" to test in Chrome 46
const toFloat = (lhs) => parseFloat(lhs.replace(/[^-\d.]+/, ""));
export default class ExpressionParser {
constructor(str, fn = toFloat, _depth = 0) {
Object.assign(this, { _depth, fn, str });
}
*[Symbol.iterator]() {
@ceane
ceane / insertEvery.js
Last active September 11, 2015 17:48
Insert an item at a certain index in a recurring number of items inside of an array
/**
* Insert an item (d) at a certain index (b) in a
* recurring number (a) of items inside of an array (c)
*
* "For every 20 items in an array,
* insert this at the 12th index in that section"
*
* var myArray = Array.from({length: 80}, (v, k) => k);
* insertItemEvery(20, 12, myArray, "Hello index");
*