Skip to content

Instantly share code, notes, and snippets.

@bultas
bultas / 01_readme.md
Last active August 29, 2015 14:25 — forked from vslinko/01_readme.md
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.
@bultas
bultas / pre-commit
Last active March 4, 2016 08:22 — forked from jhartikainen/commit-msg
Pre-commit to check tracked/commited js/jsx files with ESlint (node_modules)
#!/bin/bash
files=$(git diff --diff-filter=ACMRT --cached --name-only | grep '\.jsx\|\.js\?$')
# Prevent ESLint help message if no files matched
if [[ $files = "" ]] ; then
exit 0
fi
failed=0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dynamic Gist Embedding</title>
</head>
<body>
<p>
@bultas
bultas / Enhance.js
Last active August 29, 2015 14:24 — forked from sebmarkbage/Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@bultas
bultas / gist:ce09c999f75f6268cf15
Created July 3, 2015 10:29
React formfield validation composition example
<FormField
type=''
blockInvalid={true}
validators=[...]
convertor=fn()
>
<Switch>
case 'type'
input = <input>
@bultas
bultas / gist:20437398a6342ffb766c
Created April 29, 2015 09:34
Email validation regex
// http://stackoverflow.com/a/46181
// live demo http://output.jsbin.com/ozeyag/19
function validateEmail(email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}
@bultas
bultas / stylesheet.less
Last active August 29, 2015 14:19
Atom editor - custom stylesheet
/* font-weight problem - https://discuss.atom.io/t/atom-font-weight-anti-alias/4212/6 */
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
@bultas
bultas / gist:3fcd11d8e5e31e93562d
Created March 18, 2015 21:24
GIT - how to replace master branch with another branch
http://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch
You should be able to use the "ours" merge strategy to overwrite master with AnotherBranch like this:
git checkout AnotherBranch
git merge -s ours master
git checkout master
git merge AnotherBranch
The result should be your master is now essentially AnotherBranch.
@bultas
bultas / getSortedObjKeys.js
Created March 5, 2015 09:11
Get Sorted Object Keys
/**
* Get array of sorted Object's keys
* @param {object} Object which keys do you want to sort
* @param {boolen} byValue - false/null if you want to sort Object keys by Object's keys
* @param {boolen} byValue - true if you want to sort Object keys by Object's properties value
* @param {string} byValue - string if you want to sort Object keys by value inside each Object's property
* @return {array} Array of sorted keys (strings)
*/
var getSortedObjKeys = function(obj, byValue) {
@bultas
bultas / gist:c161f90dd71c944f2357
Created March 3, 2015 20:03
Clone - anything with javascript (dojo toolkit)
// http://davidwalsh.name/javascript-clone
function clone(src) {
function mixin(dest, source, copyFunc) {
var name, s, i, empty = {};
for(name in source){
// the (!(name in empty) || empty[name] !== s) condition avoids copying properties in "source"
// inherited from Object.prototype. For example, if dest has a custom toString() method,
// don't overwrite it with the toString() method that source inherited from Object.prototype
s = source[name];