Skip to content

Instantly share code, notes, and snippets.

View anomaly44's full-sized avatar

Rob Indesteege anomaly44

  • Hasselt, Belgium
View GitHub Profile
require('dotenv').config();
const { startWithCleanDb } = require('../../../utils/test.helpers');
const { add } = require('../invitation.service');
const { ADMIN_LEVELS, TABLES } = require('../../../constants');
const { AuthorizationError } = require('../../../errors');
const knex = require('../../../../db/connection');
jest.mock('../../../mailer');
const { sendUserInvitationMail } = require('../../../mailer');
componentWillReceiveProps(nextProps) {
if (nextProps.isOpen && !this.props.isOpen) {
this.props.getSuperTestruns(this.props.superDispatchName);
}
}
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {
ListGroup,
ListGroupItem,
Input,
Label,
FormGroup
} from 'reactstrap'
import { Link } from 'react-router-dom'
require('babel-register')();
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const exposedProperties = ['window', 'navigator', 'document'];
const { document } = (new JSDOM('')).window;
global.document = document;
global.window = document.defaultView;
@anomaly44
anomaly44 / http.js
Last active June 27, 2017 21:13
Code Samples
const _ = require('lodash');
const debug = require('debug')('fixapi:utils:http');
const errors = require('../../utils/error');
/**
* # http
*
* Wrapper for all API functions. Wraps the API method so that it receives the data from the request.
* And formats a JSON response depending on the result or error.
*
import React from 'react'
import PropTypes from 'prop-types'
import { Card, CardTitle } from 'material-ui/Card'
export const FeatureCard = ({ color, title, subtitle, icon }) => {
const styles = {
card: { borderLeft: `solid 4px ${color}`, flex: '1', marginRight: '1em' },
icon: { float: 'right', width: 64, height: 64, padding: 16, color },
};
return (<Card style={styles.card} >
import React, { PropTypes } from 'react'
import { Route, Redirect } from 'react-router-dom'
import { connect } from 'react-redux'
import { createStructuredSelector } from 'reselect'
import { selectLoggedIn } from '../User/selectors'
export const PrivateRoute = ({ component, ...rest, loggedIn }) => (
<Route {...rest} render={props => (
loggedIn ? (
React.createElement(component, props)
function* bar() {
yield delay(10000);
console.log('ok');
}
function* foo() {
while(true) {
yield take(SOME_ACTION);
yield bar;
}
import 'whatwg-fetch';
import { validTokenPresent } from './checkAuth'
import { take, fork, cancel, call, put, cancelled, select } from 'redux-saga/effects'
function parseJSON(response) {
return response.json();
}
function checkStatus(response) {
export function putToS3(file, signedRequest) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('PUT', signedRequest);
xhr.setRequestHeader('x-amz-acl', 'public-read');
xhr.onload = () => {
if (xhr.status === 200) {
resolve('ok');
}
};