Skip to content

Instantly share code, notes, and snippets.

View davidkpiano's full-sized avatar
🎹
Working on XState Dev Tools

David Khourshid davidkpiano

🎹
Working on XState Dev Tools
View GitHub Profile
@una
una / usage.md
Last active August 29, 2015 14:23
var x = require('x'); sublime snippet

varreq tab --> cursor in two spots: after var and after require('

varreq tab github --> var github = require('github');

import React from 'react';
import { Provider } from 'react-redux';
import { Router, Route } from 'react-router';
import { reduxRouteComponent } from 'redux-react-router';
import { checkAuthentication } from '../actions/AuthActions.js';
import Root from './Layout/Root';
import Dashboard from './Dashboard';
@feesh
feesh / .sass-lint.yaml
Last active November 25, 2015 21:15
sass-lint configuration
# sass-lint config generated by make-sass-lint-config v0.0.4
#
# The following scss-lint Linters are not yet supported by sass-lint:
# BemDepth, DisableLinterReason, ElsePlacement, PropertyCount
# PropertyUnits, SelectorDepth, SelectorFormat, SpaceAroundOperator
# TrailingWhitespace, UnnecessaryMantissa, UnnecessaryParentReference, Compass::*
#
# The following settings/values are unsupported by sass-lint:
# Linter Indentation, option "allow_non_nested_indentation"
# Linter Indentation, option "character"
// Here is a very simple Node.js script to perform GET HTTP requests to a
// collection of similar pages (see `URLS`) in order to extract some information
// from the (virtual) DOM. For instance, you could parse an array of pages and
// grab the title of each of them.
//
// The script then writes the resulting data (an array as well, of course) in a
// JSON file (see `DEST_FILE`). It will also cache the requested HTML documents
// in a cache file (see `CACHE_FILE`) in order to avoid having to perform all
// the HTTP requests when only the collected data changes (see `parseData`).
@zackify
zackify / .eslintrc
Last active December 21, 2015 17:57
Upgrade to Babel 6
{
"parser": "babel-eslint",
"env": {
"es6": true,
"mocha": true,
"node": true
},
"ecmaFeatures": {
"blockBindings": true,
"forOf": true,
@matthewoden
matthewoden / README.md
Last active January 21, 2016 22:14
Your CSS doesn't have to be a mess.

CSS in 2016

So this is roughly how I handle CSS these days. As much as I'd like to use CSSModules for everything, I work on a lot of different projects, for a lot of different clients. They can't all be a SPA.

Some of this seems blindingly obvious. But until I stop cleaning up messy, repetitive CSS, I figure it all merits being said.

Create a Baseline

I use one file to style HTML. This creates a baseline for the body, defines my box model, sets global typography rules, etc. If I need to style an HTML element, I style it globally. Otherwise, I give an element a class, and only style that class.

@conorhastings
conorhastings / state-component.js
Last active March 30, 2017 20:36
you can enact most of the behavior of redux with a simple component
/* this lacks subscribe behavior or ability to dispatch from outside of component tree but that is generally not neccesary */
class State extends React.Component {
constructor(props) {
super(props);
this.state = YOUR_INITIAL_STATE;
}
reducer = (action, state, props) => {...newState};
/* setState takes an object of new state as first arg or a function of props and state that returns new state
* which we will use here
* we pass dispatch around and use it similarly to redux dispatch
@mpj
mpj / $http.js
Last active July 10, 2017 16:08
function £http(method, uri, body) {
let opts = {
mode: 'cors',
method: method,
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-XSRF-TOKEN': getCookieValue('XSRF-TOKEN')
}
@staltz
staltz / slim-cycle-core.js
Created September 22, 2015 12:35
Cycle.js without sanity checks and comments in a single file. Don't use this, use normal Cycle.js. :-)
let Rx = require(`rx`)
function makeRequestProxies(drivers) {
let requestProxies = {}
for (let name in drivers) {
if (drivers.hasOwnProperty(name)) {
requestProxies[name] = new Rx.ReplaySubject(1)
}
}
return requestProxies
import React from 'react'
import { Machine } from 'xstate'
const createMachineComponent = chart => Comp => {
const machine = Machine(chart)
return class extends React.Component {
state = {
state: machine.getInitialState(),
data: {}