Skip to content

Instantly share code, notes, and snippets.

View vincentriemer's full-sized avatar

Vincent Riemer vincentriemer

View GitHub Profile
@vincentriemer
vincentriemer / AnimationHelpers.js
Last active August 29, 2015 14:05
Javascript Animation Snippets
// Cross-browser compatible scroll position
function getScrollPosition() {
return (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
}
// requestAnimationFrame polyfill
(function requestAnimationFramePolyfill() {
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];

sorting

module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
@font-face {
font-family: System;
src: local("-apple-system"), local("BlinkMacSystemFont"), local("Segoe UI"), local("Roboto"), local("Ubuntu"), local("Helvetica Neue"), local("sans-serif");
}
declare module "yoga-dom" {
declare opaque type AlignAuto;
declare opaque type AlignFlexStart;
declare opaque type AlignCenter;
declare opaque type AlignFlexEnd;
declare opaque type AlignBaseline;
declare opaque type AlignSpaceBetween;
declare opaque type AlignSpaceAround;
declare type Align =
| AlignAuto
@vincentriemer
vincentriemer / ResizeObservable.js
Created December 4, 2017 20:15
React Component prototype that provides element query functionality via ResizeObserver
// @flow
import * as React from "react";
import ResizeObserver from "resize-observer-polyfill";
import invariant from "invariant";
type Entry = {
+contentRect: {
+width: number,
+height: number
@vincentriemer
vincentriemer / Observable.re
Last active March 3, 2018 21:29
zen-observable reason bindings
type t('a, 'e);
module Subscription = {
type t;
[@bs.get] external closed : t => bool = "";
[@bs.send.pipe : t] external unsubscribe : unit => unit = "";
};
module Observer = {
type t('a, 'e);
@vincentriemer
vincentriemer / subreddit-face-average.js
Created March 13, 2018 17:14
Subreddit Face Averaging Script
import * as fs from "fs";
import * as path from "path";
import * as url from "url";
import { exec } from "child_process";
import cuid from "cuid";
import snoowrap from "snoowrap";
import throat from "throat";
import mmm from "mmmagic";
import axios from "axios";

Keybase proof

I hereby claim:

  • I am vincentriemer on github.
  • I am vincentriemer (https://keybase.io/vincentriemer) on keybase.
  • I have a public key ASBbyFx0Y416Yh_pdSHCOTmkEOVLG0rnocD-kCKgd7KKjQo

To claim this, I am signing this object:

@vincentriemer
vincentriemer / font-native.js
Created May 20, 2018 14:16
Example React Native DOM native module which provides the ability to load fonts from the worker thread
/**
* This is the "native" module that runs on the main thread
* To add this to the bridge the exported class gets added to the `nativeModules` array in the `bootstrap.js` file.
*
* @flow
*/
import {
RCT_EXPORT_METHOD,
RCT_EXPORT_MODULE,