Skip to content

Instantly share code, notes, and snippets.

View selbekk's full-sized avatar
👨
Working dad

Kristofer Giltvedt Selbekk selbekk

👨
Working dad
View GitHub Profile
@selbekk
selbekk / constant_examples.js
Last active April 20, 2018 16:56
Some good ol' regular examples
const REQUEST_TIMEOUT = 1000 * 20;
const COOKIE_EXPIRY_TIME = 1000 * 60 * 60 * 24 * 7;
const DEBOUNCE_PERIOD = 500;
@selbekk
selbekk / timeproxy_examples.js
Created April 20, 2018 18:05
Some nice and fancy new timeproxy examples
import tp from 'timeproxy';
const REQUEST_TIMEOUT = tp.TWENTY_SECONDS;
const COOKIE_EXPIRY_TIME = tp.A_WEEK;
const DEBOUNCE_PERIOD = tp.HALF_A_SECOND;
@selbekk
selbekk / more_timeproxy_examples.js
Created April 20, 2018 18:12
More timeproxy examples
import tp from 'timeproxy';
const TIME_UNTIL_NEXT_PUSH = tp.ONE_WEEK_AND_A_DAY;
const SHOW_DONT_LEAVE_DELAY = tp.TWELVE_MINUTES_TWO_SECONDS;
const WOW = tp.NINE_WEEKS_TWELVE_DAYS_SEVEN_MINUTES_AND_HALF_A_SECOND;
@selbekk
selbekk / time_sensitive_timeproxy_examples.js
Created April 20, 2018 19:17
Time sensitive timeproxy examples
import tp from 'timeproxy';
const SESSION_EXPIRES = tp.IN_THIRTY_SECONDS;
const OLD_POST_TIMESTAMP = tp.TWO_WEEKS_AGO;
@selbekk
selbekk / calidation_simple_example.jsx
Created April 21, 2018 07:54
Calidation simple example
import { FormValidation } from 'calidation';
const config = {
username: {
isRequired: 'You need a username',
},
email: {
isRequired: 'We need your email',
isEmail: 'We need a valid email, too',
},
@selbekk
selbekk / timeproxy_tagged_template_literal_example.js
Created April 26, 2018 16:49
Timeproxy with tagged template literals
import tp from 'timeproxy';
const REQUEST_TIMEOUT = tp`twenty seconds`;
const COOKIE_EXPIRY_TIME = tp`1 week`;
const DEBOUNCE_PERIOD = tp`.5 seconds`;
@selbekk
selbekk / more_timeproxy_tagged_template_literals_example.js
Created April 26, 2018 16:52
More timeproxy examples with tagged template literals
import tp from 'timeproxy';
const TIME_UNTIL_NEXT_PUSH = tp`one week and a day`;
const SHOW_DONT_LEAVE_DELAY = tp`12 minutes 2 seconds`;
const WOW = tp`9 weeks twelve days and .5 seconds`;
@selbekk
selbekk / time_sensitive_timeproxy_tagged_template_literals_examples.js
Created April 26, 2018 16:54
Time sensitive timeproxy examples with tagged template literals
import tp from 'timeproxy';
const SESSION_EXPIRES = tp`in 30 seconds`;
const OLD_POST_TIMESTAMP = tp`two weeks ago`
import * as actions from '../actions';
const getUser = () => async dispatch => {
dispatch(actions.getUserRequested());
const response = await fetch('/api/user');
const user = await response.json();
dispatch(actions.getUserReceived(user);
};
@selbekk
selbekk / dispatcher-patterns-02-simple-usage.js
Created June 2, 2018 09:25
Simple usage of a dispatcher
import React, { Component } from 'react';
import { connect } from 'react-redux';
import * as dispatchers from '../dispatchers';
class ProfilePage extends Component {
componentDidMount() {
this.props.getUser();
}
render() {...} // Not really relevant here
}