Skip to content

Instantly share code, notes, and snippets.

if (typeof Promise === 'undefined') {
require.ensure([], (require) => {
require('imports?this=>window!es6-promise')
})
}
if (typeof fetch === 'undefined') {
require.ensure([], (require) => {
require('imports?self=>window!whatwg-fetch')
})
@guyht
guyht / gist:1684328
Created January 26, 2012 18:48
Twitter Bot in NodeJS
/*
* Load external modules and init variables
*/
var twitter = require('ntwitter'),
http = require('http'),
bitly = require('bitly'),
b = new bitly('USER', 'API_KEY'),
tweeted = {},
load_time = Math.round(new Date().getTime() / 1000),
score_threshold = 100;
@mjackson
mjackson / WindowScrollTo.js
Last active January 16, 2017 02:11
Make window.scrollTo declarative using a <WindowScrollTo> React component
import React from 'react'
import warning from 'warning'
const { number, object } = React.PropTypes
const WindowScrollTo = React.createClass({
contextTypes: {
windowScrollTo: object
},
// In v2/3 you did this:
import ReactDOM from 'react-dom'
import { Router, browserHistory, Route } from 'react-router'
ReactDOM.render(
<Router>
<Route path="/about" component={About}/>
<Route path="/:username" component={User}/>
</Router>
)
@developit
developit / preact-vdom-viewer.js
Last active July 11, 2017 15:42
preact vdom viewer
/** Use the built-in document viewer in devtools to inspect your VDOM.
* Usage in console:
* viewComponentTree(document.body)
*/
function viewComponentTree(node) {
let doc = new DOMParser().parseFromString('', 'application/xml');
function visitor(dom) {
let el, c;
if (dom instanceof Node) {
el = dom.cloneNode();
@Frikki
Frikki / dialogue.js
Last active October 3, 2017 08:34
Simple Cycle.js (Nested) Dialogue with MVI Example
/** @jsx hJSX */
import {hJSX} from '@cycle/dom';
const DIALOGUE_NAME = `dialogue`;
let idSuffix = 0;
function makeCycleId() {
return `${DIALOGUE_NAME}-${idSuffix++}`;
@bvaughn
bvaughn / create-subscriber-component-poc.js
Last active September 30, 2018 09:55
create-subscriber-component proof of concept
type SubscribableConfig = {
// Maps property names of subscribable data sources (e.g. 'someObservable'),
// To state names for subscribed values (e.g. 'someValue').
subscribablePropertiesMap: {[subscribableProperty: string]: string},
// Synchronously get data for a given subscribable property.
// It is okay to return null if the subscribable does not support sync value reading.
getDataFor: (subscribable: any, propertyName: string) => any,
// Subscribe to a given subscribable.

architectures and whatnot

  1. plain ol' React
let state = initial
render(view(state), element)
  • view is pure!
@lerouxb
lerouxb / gist:1071705
Created July 8, 2011 12:16
A little node.js server for testing html5 ajax file uploads.
/*
A little node.js server for testing html5 ajax file uploads.
It serves up the current directory and receives uploads at /upload.
This is for use with xhr.send(file) where the entire request body is the file.
It just pauses one second between chunks so that client-side progress events
get a chance to fire. On my laptop it looks like the maximum chunk size is
around 40K, so you would still need images in the range of hundreds of kilobytes
to really be able to test it.
@kitten
kitten / reactiveconf-sc-cfp.md
Last active November 17, 2020 15:06
ReactiveConf 2017 Lightning Talk CFP: With styled-components into the future

styled-components Logo

With styled-components into the future

Preprocessing is dead, long live preprocessing!


This is a CFP for ReactiveConf 2017's open call for Lightning talks. If you'd like to see this talk become a reality, please ⭐ star this gist. #ReactiveConf