Skip to content

Instantly share code, notes, and snippets.

View samsch's full-sized avatar

Lumina Scheiderich samsch

View GitHub Profile
@samsch
samsch / react.js
Created December 7, 2017 19:24 — forked from anonymous/react.js
handleProductChange(event) {
const target = event.target;
const name = target.name;
this.setState({
"product": {
[name]: target.value
}
});
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry : __dirname + '/app/index.js',
module : {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
{queries.map(query => ({
area: <Area key={query.id} name={query.name} {...query.definition} />,
bar: <Bar key={query.id} name={query.name} {...query.definition} />,
line: <Line key={query.id} name={query.name} {...query.definition} />
}[query.definition.cartesianType]))}
// Shorter version
{queries.map(query => {
const Component = {area: Area, bar: Bar, line: Line}[query.definition.cartesiantype];
@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 / 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 / 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 / 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
);
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);
}
@samsch
samsch / connect.js
Last active December 30, 2015 16:52 — forked from dagda1/connect.js
import React, {Component} from 'react';
import {connect} from 'react-redux';
import FunctionPlot from './function-plot';
require("../../css/functions.css");
function mapStateToProps(state) {
return {
expression: state.expression