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 / modernizrInit.js
Last active October 26, 2016 18:01
Modernizr initializer
import './modernizr'
// Modernizr
// https://modernizr.com/docs
Modernizr.addTest('support', function() {
if (
Modernizr.svg &&
Modernizr.cssanimations &&
Modernizr.boxsizing &&
Modernizr.flexbox &&
@du5rte
du5rte / ImageLoad.jsx
Last active February 19, 2017 00:52
Redux Image Load
import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { actionsCreator } from 'actions'
// References
// http://blog.teamtreehouse.com/learn-asynchronous-image-loading-javascript
@connect(
state => state,
dispatch => actionsCreator(dispatch)
@du5rte
du5rte / Render.jsx
Last active February 26, 2017 21:40
GraphQL Subscriptions
import React, { Component, PropTypes } from 'react';
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
import update from 'immutability-helper'
import { Toggler, colors } from "./Toggler"
import View from "react-flexbox"
@graphql(gql`
@du5rte
du5rte / jwt.js
Created March 15, 2017 10:58
Regex JWT
const authorization = "Bearer abcefghijklmnopqrstu.vwxyzABCDEFGHIJKLMNOPQ.RSTUVWXYZ0123456789"
// (?:__) no selection group
// (__)? optional selection group
// (__) selection group
// searchers for digits seperated by three dots xx.xx.xx with an optional "Bearer "
// retrieve only the jwt (without Bearer)
const jwt = authorization.match(/(?:Bearer\s+)?(\w+\.\w+\.\w+)/)[1] // "abcef..."
const ProfileType = new GraphQLObjectType({
name: 'Profile',
description: 'User Profile',
fields: {
email: {type: new GraphQLNonNull(GraphQLString)},
username: {
type: new GraphQLNonNull(GraphQLString),
resolve(profile) {
return profile.split("@")[0]
@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
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
git flow bugfix vs hotfix
bugfix -> develop
hotfix -> master
@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
}
const stateFiles = [
{name: 'john'},
{name: 'lewis'},
]
const files = [
{name: 'ana'},
{name: 'john', email: "john@mail.com"},
]