Skip to content

Instantly share code, notes, and snippets.

View doug2k1's full-sized avatar

Douglas Matoso doug2k1

  • Campinas - SP - Brazil
View GitHub Profile
@doug2k1
doug2k1 / learn-frontend-react-typescript.md
Last active November 17, 2022 01:34
Frontend, React, TypeScript Roadmap

Frontend, React, TypeScript Roadmap

Tips:

  • Read the introduction for each topic and dive deep only when needed
  • Official documentation is, most of the time, the best source

Foundation

@doug2k1
doug2k1 / config-template.json
Created May 7, 2020 19:17
Create JSON from template
{
"name": "Test",
"baseURL": "__baseURL__",
"otherBaseURL": "__baseURL__"
}
@doug2k1
doug2k1 / component.js
Created March 12, 2019 18:58
React detect changed props
componentDidUpdate(prevProps: Props) {
console.log('UPDATE');
Object.keys(this.props)
.filter(key => this.props[key] !== prevProps[key])
.map(key => {
console.log(
'changed property:',
key,
'from',
prevProps[key],
const { graphqlExpress } = require('apollo-server-express');
const { makeExecutableSchema } = require('graphql-tools');
const { importSchema } = require('graphql-import');
const resolvers = require('./graphql/resolvers');
const setup = app => {
const schema = makeExecutableSchema({
typeDefs: importSchema('src/graphql/schema.graphql'),
resolvers
});
scalar Date
type Query {
brokers(limit: Int): [Broker]
broker(id: ID!): Broker
investments(limit: Int): [Investment]
investment(id: ID!): Investment
}
type Broker {
const { GraphQLString } = require('graphql');
const { Broker, Investment, BalanceUpdate, Transaction } = require('../models');
module.exports = {
Query: {
brokers: (obj, args) => Broker.all(args),
broker: (obj, { id }) => Broker.findById(id),
investments: (obj, args) => Investment.all(args),
investment: (obj, { id }) => Investment.findById(id)
},
scalar Date
type Query {
brokers(limit: Int): [Broker]
broker(id: ID!): Broker
investments(limit: Int): [Investment]
investment(id: ID!): Investment
}
type Broker {
const expect = require('chai').expect;
const { Investment, Transaction } = require('../../src/models');
describe('Transaction', () => {
describe('attributes', () => {
it('should have amount and date', async () => {
const transaction = await Transaction.create({
amount: 1,
date: '2018-03-15'
});
@doug2k1
doug2k1 / index.js
Created March 11, 2018 21:28
Test model associations
const { Broker, Investment, Transaction, BalanceUpdate } = require('./models');
const test = async () => {
// create broker
const broker = await Broker.create({ name: 'Fooinvest' });
// create investment
const investment = await Investment.create({
name: 'Tesouro Foo',
BrokerId: broker.get('id')
});
@doug2k1
doug2k1 / webpack.config.js
Created October 2, 2017 18:04
Webpack multiple CSS entrypoints
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const path = require('path')
module.exports = {
entry: {
main: './src/index.js',
base: './src/css/base.css',
admin: './src/css/admin.css'
},