Skip to content

Instantly share code, notes, and snippets.

@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: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 / 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 / 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() {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dynamic Gist Embedding</title>
</head>
<body>
<p>
@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
@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 / gist:7a5e0a3974423cef0018
Last active July 14, 2017 09:05
React Stateless component example with props validation
import React from 'react';
import Link from 'components/link';
import { createStyles } from 'styles/styleSheet';
export function Button({ onClick }) {
return (
@bultas
bultas / composeComponents.js
Last active May 18, 2016 08:40
Composable High-order components
export function composeComponents(component, wrappers = []) {
return wrappers.reduce((c, wrapper) => wrapper(c), component);
}
@bultas
bultas / gist:6f4fccc1bb7d21cab9be4eec7c8cb843
Created August 25, 2016 16:47 — forked from n00neimp0rtant/gist:9515611
simple squash without rebase
## within current branch, squashes all commits that are ahead of master down into one
## useful if you merged with upstream in the middle of your commits (rebase could get very ugly if this is the case)
## commit any working changes on branch "mybranchname", then...
git checkout master
git checkout -b mybranchname_temp
git merge --squash mybranchname
git commit -am "Message describing all squashed commits"
git branch -m mybranchname mybranchname_unsquashed
git branch -m mybranchname