Skip to content

Instantly share code, notes, and snippets.

@vslinko
vslinko / 01_readme.md
Last active August 29, 2015 14:25
Experimental Relay Implementation

Experimental Relay Implementation

Features:

  • Relay.fetch(graphqlQuery) returns subscribtion that could change over time by mutation queries.
  • Relay.update(m: UpdateMutation) optimistically updates resource in all previous queries that contains updated resource.
  • Relay.update(m: DeleteMutation) optimistically deletes resource from all previous queries that contains deleted resource.
  • Relay.update(m: CreateMutation) pessimistically creates resource and executes again all previous queries.
  • All objects with id key in graphql response explained as resources. Arrays, objects without id and scalars explained as static properties.
@danielmahal
danielmahal / gist:4071840
Created November 14, 2012 12:31
Prevent page reload
$(window).on('beforeunload', function() {
return 'Sure you want to leave?';
});
@stammy
stammy / gist:4166118
Created November 29, 2012 01:26
IAM S3 read-only
// AWS IAM S3 Read-only, single bucket policy
{
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketAcl",
"s3:GetBucketLocation",
"s3:GetBucketNotification",
@Daniel15
Daniel15 / gist:7653825
Created November 26, 2013 05:20
Basic AJAX loading
/**
* Does an AJAX load of the specified URL
*
* @param {String} url URL to load
* @param {Object} data Hash of data to send in querystring
* @param {Function} callback Function to call once request returns
*/
function load(url, data, callback) {
if (data) {
var params = Object.keys(data)
@insin
insin / gulpfile.js
Last active September 15, 2016 08:35
gulpfile for use with React, with flat imports from uniquely-named modules under /src
/*
gulpfile from one of my React applications which has a gulp --production build
set up.
Assumptions:
1. All your own .js/.jsx modules are somewhere under ./src, have unique
filenames and use Node.js-style requires WITHOUT any path information, just
the name of another module somewhere under ./src
@jamiebuilds
jamiebuilds / deprecated.jsx
Created March 10, 2017 05:00
React PropTypes additions
import React, {PropTypes} from 'react';
class MyComponent extends React.Component {
static propTypes = {
foo: PropTypes.string,
bar: PropTypes.number.deprecated("Use props.foo instead of props.bar"),
});
}
<MyComponent foo="test"/>; // Works!
@prestonparris
prestonparris / reactjs-conf-2015-notes.md
Last active April 6, 2017 21:32
Notes from the 2015 React.js Conference

Reactjs conf 2015 Notes

  • react native announced

    • Allows you to use react style javascript to target native ios and android, native views, live reloading
    • intro pt1
    • intro pt2
    • facebook groups app uses react native with graphql and relay
  • realtime page tweaking

    • rethink best practices and workflows
  • inmutability is a good idea

@tj
tj / routes.js
Created October 15, 2011 00:23
Express routes
var app = require('../app');
console.log();
app.routes.all().forEach(function(route){
console.log(' \033[90m%s \033[36m%s\033[0m', route.method.toUpperCase(), route.path);
});
console.log();
process.exit();
@jaredpalmer
jaredpalmer / emotion-jsxstyle.js
Last active November 8, 2017 14:43
jsxstyle everywhere!
import React from 'react';
import { css as EmotionCSS } from 'react-emotion';
import { jsxstyleFactory } from './jsxstyleFactory';
const cx = (css, styles, className) =>
EmotionCSS([{ ...css, ...styles }, className]);
const jsxstyle = jsxstyleFactory(cx);
export const Box = jsxstyle.Box;
// Have some complicated non-React widgets that manipulate DOM?
// Do they manage a list of DOM elements? Here's how to wrap it
// into a React component so you can "constantly rerender" it.
// A dumb non-react widget that manually manage some DOM node that
// represent a list of items
function NonReactWidget(node) {
this.node = node;
}