Skip to content

Instantly share code, notes, and snippets.

View mauricedb's full-sized avatar

Maurice de Beijer mauricedb

View GitHub Profile
This file has been truncated, but you can view the full file.
fetch("https://wb-api.ethz.ch/MFT/api/upload/v1/UploadChunk", {
"headers": {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9,nl;q=0.8,de;q=0.7",
"authorization": "....",
"cache-control": "no-cache",
"content-type": "application/json",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
@mauricedb
mauricedb / .storybook\main.js
Created August 19, 2020 18:20
SDN Storybook
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-a11y",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
],
};
@mauricedb
mauricedb / index.njk
Last active May 23, 2020 18:32
Pagination with Eleventy and Nunjucks
<span>Page {{ pagination.pageNumber + 1 }} of {{ pagination.pages.length }}:</span>
{% if page.url !== pagination.href.first %}<a href="{{ pagination.href.first }}"><i class="ion-ios-skipbackward"></i></a>{% endif %}
{% if pagination.href.previous %}<a href="{{ pagination.href.previous }}"><i class="ion-arrow-left-b"></i></a>{% endif %}
{%- for pageEntry in pagination.pages %}
{%- if (loop.index0 - pagination.pageNumber) | abs <= 3 %}
<a href="{{ pagination.hrefs[ loop.index0 ] -}}"
{%- if page.url === pagination.hrefs[ loop.index0 ] %} class="active"{% endif %}>
{{- loop.index -}}
</a>
{%- endif %}
type Person = yup.InferType<typeof personSchema>;
const person: Person;
type Person = {
firstName: string;
nickName: string | null;
email?: string | null;
birthDate: Date;
};
const person = {
firstName: "Matt",
nickName: "The Hammer",
email: "matt@the-hammer.com",
birthDate: new Date(1976, 9, 5)
};
console.log(personSchema.isValidSync(person));
const personSchema = yup.object({
firstName: yup.string(),
nickName: yup.string().nullable(),
email: yup
.string()
.nullable()
.notRequired()
.email(),
birthDate: yup
.date()
import React from 'react';
import ListGroup from 'react-bootstrap/ListGroup';
import { url } from '../../shared/jokes-api';
import Loading from '../../shared/loading';
function reducer(state, action) {
switch (action.type) {
case 'loaded':
return { ...state, loading: false, jokes: action.payload };
@mauricedb
mauricedb / Joke.js
Last active January 18, 2020 10:28
useAbortableFetch
import React, { useState } from 'react';
import useAbortableFetch from './useAbortableFetch';
const Joke = () => {
const { json: joke, loading, error, abort } = useAbortableFetch(
'http://api.icndb.com/jokes/random/?limitTo=[nerdy]&escape=javascript'
);
if (loading) return 'Loading...';
if (error) return 'Error: ' + error;