Skip to content

Instantly share code, notes, and snippets.

View cherewaty's full-sized avatar

Jeffrey Cherewaty cherewaty

View GitHub Profile
@cherewaty
cherewaty / gist:d61dc20b66202bc2702f1301b4657d90
Created December 13, 2019 14:52
Marshmallow Quickstart
Marshmallow is a Python library for dealing with complex data types.
It’s especially useful as an ORM layer between a database and the interface of a Python API or UI.
Example code from https://marshmallow.readthedocs.io/en/stable/quickstart.html
To start, in an existing Python project:
```
pip install -U marshmallow
```
Create a schema:
@cherewaty
cherewaty / CurrentUser.js
Last active May 1, 2018 19:52
Context scenario 1
// stripes-components/lib/CurrentUser/CurrentUser.js
export const CurrentUserContext = React.createContext({
timeZone: 'UTC'
// all the other things that hang on context.stripes also go here
});
export default function withCurrentUser(Component) {
return ({ currentUser, ...props }) => {
return (
@cherewaty
cherewaty / CurrentUser.js
Last active May 1, 2018 19:50
Context scenario 2
// stripes-components/lib/CurrentUser/CurrentUser.js
export const CurrentUserContext = React.createContext({
timeZone: 'UTC'
// all the other things that hang on context.stripes also go here
});
export default function withCurrentUser(Component) {
return ({ currentUser, ...props }) => {
return (
@cherewaty
cherewaty / CurrentUser.js
Created May 1, 2018 19:38
Context scenario 3
// stripes-components/lib/CurrentUser/CurrentUser.js
export const CurrentUserContext = React.createContext({
timeZone: 'UTC'
// all the other things that hang on context.stripes also go here
});
@cherewaty
cherewaty / Datepicker.js
Last active May 1, 2018 19:28
Context scenario 4
// stripes-components/lib/Datepicker/Datepicker.js
import withTimeZone from '../TimeZone';
class Datepicker extends Component {
static propTypes = {
timeZone: PropTypes.string.isRequired
};
}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames/bind';
import capitalize from 'lodash/capitalize';
import PaneHeader from '@folio/stripes-components/lib/PaneHeader';
import Icon from '@folio/stripes-components/lib/Icon';
import IconButton from '@folio/stripes-components/lib/IconButton';
import PaneMenu from '@folio/stripes-components/lib/PaneMenu';
import Modal from '@folio/stripes-components/lib/Modal';
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});