Skip to content

Instantly share code, notes, and snippets.

@jedwards1211
jedwards1211 / useConnection.js
Last active June 3, 2020 12:00
useConnection (a React hook for infinite scrolling with Apollo, Relay-style Connections, and react-virtualized)
/**
* @flow
* @prettier
*/
import { type QueryRenderProps } from 'react-apollo'
import * as React from 'react'
import {
get,
takeRightWhile,
@kgregory
kgregory / MuiVirtualizedTable.jsx
Created November 21, 2018 16:36
Virtualized, Auto-Height Table powered by material-ui and react-virtualized
import React from "react";
import { PropTypes } from "prop-types";
import classNames from "classnames";
import withStyles from "@material-ui/core/styles/withStyles";
import TableCell from "@material-ui/core/TableCell";
import TableSortLabel from "@material-ui/core/TableSortLabel";
import {
AutoSizer,
Column,
SortDirection,
@miyaokamarina
miyaokamarina / conditions.js
Last active March 9, 2023 15:31
Type-level conditions in Flow https://is.gd/OPsJBd
// Licensed under CC BY 4.0.
type $If<X: boolean, Then, Else = empty> = $Call<
& ((true, Then, Else) => Then)
& ((false, Then, Else) => Else),
X,
Then,
Else,
>;
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
varying vec4 vertColor;
varying vec3 vertNormal;
varying vec3 vertLightDir;
varying vec4 vertTexCoord;
@nat-n
nat-n / Recipe-bundling-fonts-with-headless-chrome.md
Last active February 28, 2024 19:23
How to build a fontconfig bundle for adding arbitrary fonts to headless chrome independent of the OS. This is specifically useful for deploying headless chrome to AWS lambda where it is necessary to include fonts for rendering CJK (Chinese, Japanese, Korean) characters into the deployed bundle.

Building fontconfig

Start up a lambda-like docker container:

docker run -i -t -v /tmp:/var/task lambci/lambda:build /bin/bash

Install some dependencies inside the container:

yum install gperf freetype-devel libxml2-devel git libtool -y

easy_install pip

@ashrithks
ashrithks / nestedScrollview
Created October 31, 2017 13:55
nestedScrollview in react native
import React, { Component } from 'react';
import { View, ScrollView } from 'react-native';
export default class App extends Component {
constructor() {
super();
this.state = {
enabled:true
};
}
@ibraheem4
ibraheem4 / postgres-brew.md
Last active July 18, 2024 00:18 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@vsetka
vsetka / multipart-streaming-s3-upload.js
Created October 19, 2017 11:58
Demonstrates how a file can be read as a stream (from network), piped through gzip and into an s3 bucket without having to store it locally our load it whole in memory
const { Writable, Readable, PassThrough } = require("stream");
const { inherits } = require("util");
const AWS = require("aws-sdk");
const zlib = require("zlib");
const https = require("https");
const gzip = zlib.createGzip();
const s3 = new AWS.S3();
// Change the bucket name to point to an S3 bucket write-able within the IAM role assigned to your Lambda
/* @flow */
const SCAN_WIFIS_START = 'SCAN_WIFIS_START'
const SCAN_WIFIS_SUCCEED = 'SCAN_WIFIS_SUCCEED'
const SCAN_WIFIS_FAILED = 'SCAN_WIFIS_FAILED'
const SET_ACTIVE_WIFI_ITEM = 'SET_ACTIVE_WIFI_ITEM'
const CONNECT_WIFI_START = 'CONNECT_WIFI_START'
const CONNECT_WIFI_SUCCEED = 'CONNECT_WIFI_SUCCEED'
const CONNECT_WIFI_FAILED = 'CONNECT_WIFI_FAILED'
@yanickrochon
yanickrochon / flexboxgrid.css
Last active December 4, 2016 00:12
This, to me, solves the issue of horizontal scroll bars with Flexbox Grid. As long as Grid wraps the page content, everything seems to be fine so far.
:root {
--gutter-width: 1;
--gutter-compensation: calc((var(--gutter-width) * 0.5) * -1);
--half-gutter-width: calc((var(--gutter-width) * 0.5));
--container-sm: 46.5em;
--container-md: 63em;
--container-lg: 74em;
}
@custom-media --sm-viewport only screen and (min-width: 48em);