Skip to content

Instantly share code, notes, and snippets.

View secobarbital's full-sized avatar

Seggy Umboh secobarbital

View GitHub Profile
const stream = require('stream')
const cache = new Map() // you might wanna use an lru here
function createCacheStream (url) {
const buf = []
return stream.Transform({
transform: function (data, enc, cb) {
buffer.push(data)
cb(null, data)
},
@dypsilon
dypsilon / reader-t.js
Last active October 28, 2020 22:25
A simple example of using Reader transformer to combine reader and future.
const {tagged} = require('daggy');
// const
const K = (a) => (b) => a;
// Reader Transformer
module.exports = (M) => {
const ReaderT = tagged('run');
ReaderT.lift = (m) => ReaderT(K(m));
@langpavel
langpavel / GraphQLTimestamp.js
Last active July 28, 2023 08:46
GraphQLTimestamp.js
import { Kind } from 'graphql/language';
import { GraphQLScalarType } from 'graphql';
function serializeDate(value) {
if (value instanceof Date) {
return value.getTime();
} else if (typeof value === 'number') {
return Math.trunc(value);
} else if (typeof value === 'string') {
return Date.parse(value);

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@BracketBulldog
BracketBulldog / detect-flexbox-and-flexwrap-support
Created January 10, 2015 21:58
How to detect browser support for flexbox and flexwrap
// how to detect flexbox support
// create a test div in the DOM
var div = document.createElement('div');
// make sure the default value is display: block
div.style.display = 'block';
// try some display values invoking flexbox
try {
@staltz
staltz / introrx.md
Last active May 24, 2024 07:56
The introduction to Reactive Programming you've been missing
@baldwicc
baldwicc / solarized_setup.js
Last active February 9, 2024 15:38
Solarized Light and Solarized Dark for Chrome Secure Shell (nassh), with fonts
/**
* STEP 1: Setup
* - Open Chrome Secure Shell settings
* - Open JS Console (CTRL+SHIFT+J)
* - Copy and paste the following:
*/
var s7d_colours = {
'base03': '#002b36',
'base02': '#073642',
'base01': '#586e75',
@gsoltis
gsoltis / rx.firebase.js
Last active May 6, 2024 03:17
Quick Firebase / RxJS binding prototype
(function () {
var makeCallback = function(eventType, observer) {
if (eventType === 'value') {
return function(snap) {
observer.onNext(snap);
};
} else {
return function(snap, prevName) {
// Wrap into an object, since we can only pass one argument through.
observer.onNext({snapshot: snap, prevName: prevName});
@tinabeans
tinabeans / template.html
Last active February 13, 2024 09:18
A super-barebones single-column responsive email template, assuming a max-width of 540px. Read about it on the Fog Creek blog.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {
@johan
johan / resolveURL.js
Created October 19, 2012 00:17
Resolves a relative url against a base_url using browser internals not exposed to you in API form.
function resolveURL(url, base_url) {
var doc = document
, old_base = doc.getElementsByTagName('base')[0]
, old_href = old_base && old_base.href
, doc_head = doc.head || doc.getElementsByTagName('head')[0]
, our_base = old_base || doc_head.appendChild(doc.createElement('base'))
, resolver = doc.createElement('a')
, resolved_url
;
our_base.href = base_url;