Skip to content

Instantly share code, notes, and snippets.


Christoffer Niska crisu83

View GitHub Profile
crisu83 / pipe.ts
Last active Apr 3, 2021
Simple strongly typed pipe function
View pipe.ts
type OperatorFn<T> = (value: T) => T;
interface PipeFn {
<T>(...fns: OperatorFn<T>[]): (value: T) => T;
const pipe: PipeFn = (...fns) => value =>
fns.reduce((val, fn) => fn(val), value);
export default pipe;
crisu83 / utils.tsx
Last active Dec 4, 2020
Utility components built on top of Styled System.
View utils.tsx
// Utility components on top of styled-system.
// Inspired by [Rebass]( and adopted to our needs.
// See:
import {Theme} from '@/styles/theme';
import css, {SystemStyleObject} from '@styled-system/css';
import shouldForwardProp from '@styled-system/should-forward-prop';
import {
crisu83 / ErrorProvider.jsx
Last active Dec 2, 2019
Testing with Apollo Client
View ErrorProvider.jsx
import { ApolloProvider } from '@apollo/react-hooks';
import { InMemoryCache } from 'apollo-cache-inmemory';
import ApolloClient from 'apollo-client';
import { ApolloLink, Observable } from 'apollo-link';
import React from 'react';
const ErrorProvider = ({ errors, children }) => {
const errorLink = new ApolloLink(
() =>
new Observable(observer => {
crisu83 / init
Last active Apr 1, 2019
Releasing your library written in TypeScript on NPM code snippets
View init
$ yarn
$ yarn add -D typescript rollup rollup-plugin-typescript2
crisu83 / react.code-snippets
Created Jan 22, 2019
My VS Code React snippets
View react.code-snippets
"reactClassComponent": {
"prefix": "rcc",
"body": "import * as React from 'react'\n\nclass ${TM_FILENAME_BASE} extends React.Component {\n\trender() {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t$0\n\t\t\t</div>\n\t\t)\n\t}\n}\n\nexport default ${TM_FILENAME_BASE}\n",
"description": "Creates a React component class"
"reactPureComponent": {
"prefix": "rpc",
"body": "import * as React from 'react'\n\nclass ${TM_FILENAME_BASE} extends React.PureComponent {\n\trender() {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t$0\n\t\t</div>\n\t\t)\n\t}\n}\n\nexport default ${TM_FILENAME_BASE}\n",
"description": "Creates a React pure component class"
crisu83 / settings.json
Created Jan 22, 2019
My VS Code settings
View settings.json
"diffEditor.renderSideBySide": false,
"editor.fontFamily": "Operator Mono Lig",
"editor.fontLigatures": true,
"editor.fontSize": 14,
"editor.formatOnSave": true,
crisu83 / AbstractPageBuilder.php
Last active Apr 18, 2018
WIP Relay concept for our GraphQL implementation
View AbstractPageBuilder.php
namespace ALehdet\AspaApi\GraphQL\Relay;
use Digia\GraphQL\Relay\PageInfo;
use Digia\GraphQL\Relay\PageInfoBuilderInterface;
abstract class AbstractPageBuilder implements PageInfoBuilderInterface
View VehicleResolver.php
class VehicleResolver extends AbstractResolver
public function resolveFoo()
return 'foo';
public function resolveType($rootValue, $contextValues, $info)
if ($rootValue instanceof Airplane) {
View flow-error_2017-02-06
yarn run v0.19.1
$ flow; test $? -eq 0 -o $? -eq 2
The flow server's version didn't match the client's, so it exited.
Going to launch a new one.
Launching Flow server for /Users/juuso/projects/poc
Spawned flow server (pid=15149)
Logs will go to /private/tmp/flow/zSUserszSjuusozSprojectszSpoc.log
13: fork(function* () {
crisu83 / createEntityCrudSaga.js
Last active Sep 20, 2016
A work-in-progress implementation of an entity CRUD saga for redux-saga.
View createEntityCrudSaga.js
import isArray from 'lodash/isArray';
import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';
import { takeLatest } from 'redux-saga';
import { call, fork, put } from 'redux-saga/effects';
import { arrayOf, Schema } from 'normalizr';
import { callApi } from '../../api/helper';
import { normalizeEntityResponse } from '../../common/helper';