Skip to content

Instantly share code, notes, and snippets.

View iamdanthedev's full-sized avatar
😃

Dan The Dev iamdanthedev

😃
  • Bonliva AB
  • Stockholm/Kiev
View GitHub Profile
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
=erl_crash_dump:0.3
Sat Aug 12 17:18:09 2017
Slogan: Kernel pid terminated (application_controller) ({application_start_failure,couch,{{shutdown,{failed_to_start_child,couch_secondary_services,{shutdown,{failed_to_start_child,couch_peruser,{badarg,[{e
System version: Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:3:3] [async-threads:16] [kernel-poll:true]
Compiled: Mon Apr 24 06:20:48 2017
Taints: snappy,khash,crypto
Atoms: 13216
=memory
total: 103938648
processes: 3682736
=erl_crash_dump:0.3
Sat Aug 12 17:18:09 2017
Slogan: Kernel pid terminated (application_controller) ({application_start_failure,couch,{{shutdown,{failed_to_start_child,couch_secondary_services,{shutdown,{failed_to_start_child,couch_peruser,{badarg,[{e
System version: Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:3:3] [async-threads:16] [kernel-poll:true]
Compiled: Mon Apr 24 06:20:48 2017
Taints: snappy,khash,crypto
Atoms: 13216
=memory
total: 103938648
processes: 3682736
@iamdanthedev
iamdanthedev / Field.tsx
Last active November 7, 2017 12:53
Typesafe redux-form field with custom props
/**
* Redux-form Field with custom property `nutrient` passed in directly and not via props
* Type safe and no typescript erros
*/
import { Field, WrappedFieldProps } from 'redux-form';
type ExtrasProps = { nutrient: Nutrient };
const ValueField = Field as new () => Field<ExtraProps>;
@iamdanthedev
iamdanthedev / scratch.tsx
Created November 13, 2017 18:51
React composition with apollo query, mutation and react-router
import { graphql, QueryProps } from 'react-apollo';
/**
* QUERY
*/
const PAYMENT_QUERY = gql`
query payment($id: ID!) {
payment(id: $id) {
id
@iamdanthedev
iamdanthedev / tsconfig.ts
Created November 16, 2017 01:12
tsconfig.ts paths
{
"compilerOptions": {
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"lib": ["dom", "es2017", "esnext"],
"module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "noEmit": true, /* Do not emit outputs. */
"strict": true,
"strictFunctionTypes": false,
"noImplicitAny": false,
"experimentalDecorators": true,
@iamdanthedev
iamdanthedev / dataLoadingOrError.tsx
Last active December 2, 2017 11:14
Apollo data loading or error HOC
import * as React from 'react';
import { Loading } from '@common/components/Loading/Loading';
import { ErrorMessage } from '@common/components/ErrorMessage/ErrorMessage';
import { IconSizeProp } from 'semantic-ui-react/src/elements/Icon/Icon';
type Options<T = any> = {
loaderSize?: IconSizeProp,
errorExtraCheck?: (props: T) => string | null | undefined,
loadingExtraCheck?: (props: T) => boolean,
@iamdanthedev
iamdanthedev / Nutrient.ts
Created December 19, 2017 14:21
Mongoose post init hook in typescript
// @ts-ignore
nutrientSchema.post('init', async function(this: NutrientInstance) {
// noinspection JSDeprecatedSymbols
if (!this.displayUnitCode && this.displayUnitId) {
const unit = await NutrientUnitModel.findById(this.displayUnitId);
if (unit) {
this.displayUnitCode = unit.code;
await this.save();
}
}
@iamdanthedev
iamdanthedev / gist:6d411a4f6441b5548eeadadfd1f7b60a
Created December 27, 2017 05:39
findOrCreate mongoose typescript plugin
import { Document, Model, Schema } from 'mongoose';
import { ObjectID } from 'bson';
/**
* Find or create mongoose static function creator
*/
export type WithFindOrCreate<T extends Document> = {
findOrCreate: (id?: string | ObjectID | null) => T;
};
@iamdanthedev
iamdanthedev / withTheme.tsx
Created December 27, 2017 16:47
react storybook styled-components theme provider decorator
import * as React from 'react';
import { StoryDecorator } from 'storybook__react';
import { ThemeProvider } from 'styled-components';
/**
* Storybook styled-components theme provider
*/
export function withTheme(theme): StoryDecorator {