Skip to content

Instantly share code, notes, and snippets.

View samsch's full-sized avatar

Lumina Scheiderich samsch

View GitHub Profile
@samsch
samsch / main.jsx
Last active April 12, 2016 17:04
Starting other app code which uses the store in a Redux app.
let React = require('react');
let ReactDOM = require('react-dom');
let { createStore } = require('redux');
let { Provider } = require('react-redux');
let reducer = require('./RootReducer');
let App = require('./containers/App');
let SocketThing = require('socket-thing');
let store = createStore(reducer);
const React = require('react');
class NewComponent extends React.Component {
constructor(props) {
super(props);
this.onMouseOver = this.onMouseOver.bind(this);
}
onMouseOver() {
this.props.onMouseOver(this.props.id);
}
const React = require('react');
const Menus = props => <div>
{this.props.menus.map(menu=>
<div className={this.props.openMenus.includes(menu.name) ? 'open' : ''}>
{menu.name}{menu.children.length > 0 ? <Menus menus={menu.children} openMenus={this.props.openMenus} /> : null}
</div>
)}
</div>
@samsch
samsch / ButtonWrapper.jsx
Created July 19, 2016 17:55
A button wrapper which allows you to give it an id to pass back with onClick.
const React = require('react');
class ButtonWrapper extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.props.onClick(this.props.id);
}
@samsch
samsch / app.js
Last active September 21, 2016 14:57
import React from 'react';
import ReactDOM from 'react-dom';
import Router from 'routes';
ReactDOM.render(
<Router />,
document.body
);
@samsch
samsch / remove-docker-containers.md
Last active November 28, 2016 18:53 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
@samsch
samsch / client.js
Last active December 21, 2016 18:10 — forked from brycekmartin/client.js
<Router history={hashHistory}>
<Route path="/" component={Layout}>
<IndexRoute component={Dashboard}></IndexRoute>
<Route path="Login" component={Login}></Route>
<Route path="accounting">
<Route path="authorize-orders" component={AuthorizeOrders}></Route>
<Route path="credit-transaction" component={CreditCcTransaction}></Route>
<Route path="authorize-card" component={Sale}/>
<Route path="authorize-card/select-invoices" component={SaleSelectInvoices}></Route>
<Route path="void-transaction" component={VoidCcTransaction}></Route>
@samsch
samsch / ESNextFeatures.md
Last active January 24, 2017 17:21
Should I use ES Next features?

Specifically, read this if you are considering turning on and using pre-stage 4 features with Babel.

What are these stages?

If an item is at stage 4, it's finalized and ready to be included in the next iteration of the Javascript standard. These should always be as safe to use as current standard features. Features at stage 4 were pulled for ES2015 and ES2016 around January/Febuary of that year. It's reasonable to expect the same for ES2017, ES2018, etc.

If it's at stage 3, it shouldn't change much or at all, but it's not final. Stage 2 and lower are up for changes as needed. You can read the full process here.

If something that is implemented in Babel (pre-stage 4) is changed, or removed, what happens?

@samsch
samsch / foo.jsx
Last active May 22, 2017 21:49 — forked from StoneCypher/foo.jsx
StoneCypher's external state example, re-written for React latest (15.x)
let counter = 0;
const repaint = () => React.render(<Spinner data={counter}/>, document.body);
const inc = () => { counter += 1, repaint() };
const dec = () => { counter -= 1, repaint() };
const Spinner = ({ counter }) => (
<div>
{counter}
<button value="^" onclick={inc}/>
@samsch
samsch / .md
Last active June 16, 2017 18:04
Should I use a stage-x preset in babel?

What's wrong with stage-0?

state-0 is highly volatile proposals, very likely to change. In other words, it's possible for every update to the preset (theoretically every tc39 meeting) to break any code which uses it. This is very true with stage-0, kinda true with stage-1, and 2-3 start to be a bit more solid (4 means it's finalized and ready for the spec).

But <boilerplate> uses it, and they're well tested!

It's not a matter of how well tested their code is, because it affects your own. It doesn't do any harm if you don't use those features, but you could accidentally use one, only to have your code break down the road after an update.

Which preset(s) should I use then? stage-1?