Skip to content

Instantly share code, notes, and snippets.

View du5rte's full-sized avatar
🏠
Working from home

Duarte Monteiro du5rte

🏠
Working from home
View GitHub Profile
@du5rte
du5rte / injectProps.jsx
Created June 29, 2017 09:44
Prop injector
function injectProps(options) {
return function(InitialComponent) {
return function DndStateInjector() {
return <InitialComponent {...options} />;
};
};
}
@du5rte
du5rte / store.js
Created June 23, 2017 12:51
Redux Store on different development modes
export default (
process.env.NODE_ENV === "production"
? require("./productionStore").default
: require("./developmentStore").default
);
@du5rte
du5rte / UserConnection.js
Last active November 9, 2023 10:29
GraphQL UserConnection with totalCount
import { GraphQLInt, GraphQLNonNull, GraphQLInputObjectType } from "graphql";
import { connectionDefinitions, connectionArgs } from "graphql-relay";
import UserType from "./UserType";
// References
// http://graphql.org/learn/pagination/
// http://dev.apollodata.com/react/pagination.html
// https://www.reindex.io/blog/relay-graphql-pagination-with-mongodb/
// https://github.com/graphql/graphql-relay-js
export default function formCollectionToPlainObject(HTMLFormControlsCollection) {
return Object.entries(HTMLFormControlsCollection).reduce((acc, [key, value]) => {
return {
...acc,
[key]: value.value
};
}, {});
}
creating custom Graphql Types
https://github.com/stylesuxx/graphql-custom-types/blob/master/src/scalars.js
const stateFiles = [
{name: 'john'},
{name: 'lewis'},
]
const files = [
{name: 'ana'},
{name: 'john', email: "john@mail.com"},
]
@du5rte
du5rte / HoverDecorator.jsx
Last active May 8, 2017 10:45 — forked from laem/HoverDecorator.jsx
React Hover Component Decorator
import React, { Component } from "react"
export default function hoverDecorator(InitialComponent) {
return class HoverDecorator extends Component {
constructor() {
super()
this.state = {
hover: false
}
git flow bugfix vs hotfix
bugfix -> develop
hotfix -> master
let x = 0
console.log(x)
let y = 1
console.log(y)
let z = 0
for (let i=0; i < 20; i++) {
z = x + y
@du5rte
du5rte / gist:2e580ea588a9f7843cdde9376efc6ff6
Last active April 26, 2017 16:41
dotenv improvements
// better file checker
// https://nodejs.org/dist/latest-v7.x/docs/api/fs.html#fs_fs_readfilesync_file_options
fs.accessSync(path.resolve(__dirname,'./config-local.json'), fs.R_OK);
// add .env.js