Skip to content

Instantly share code, notes, and snippets.

View AugustoCalaca's full-sized avatar

Augusto Calaca AugustoCalaca

View GitHub Profile
@AugustoCalaca
AugustoCalaca / NotificationSentSubscription.js
Last active March 26, 2021 21:46
How to filter who might receive a subscription
import { NotificationSentModel } from '@entities';
import { GraphQLID, GraphQLNonNull } from 'graphql';
// import { subscriptionWithClientId } from 'graphql-relay-subscription';
import { withFilter } from 'graphql-subscriptions';
import { fromGlobalToId, subscriptionObjectType } from './utils';
import pubSub, { EVENTS } from '../../../pubSub';
import NotificationSentType from '../NotificationSentType';
const subscriptionAsyncIterator = () => pubSub.asyncIterator(EVENTS.NOTIFICATION.SENT);
@AugustoCalaca
AugustoCalaca / test.js
Created February 22, 2021 23:33 — forked from jmyrland/test.js
Socket-io load test?
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';
@AugustoCalaca
AugustoCalaca / .ngnix.config
Created February 22, 2021 22:45
How to config ngnix to use websockets at subscriptions location on server
server {
listen 80;
listen [::]:80;
server_name graphql.mydomain.com.br;
location / {
proxy_pass http://mydomain:8080;
}
@AugustoCalaca
AugustoCalaca / babel.config.js
Created January 12, 2021 21:31 — forked from jgcmarins/babel.config.js
Webpack configs for Node.js backends to run both locally and on AWS Lambda
module.exports = {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
@AugustoCalaca
AugustoCalaca / base64ToPDF.js
Created January 8, 2021 12:29
how to convert a base64 to pdf url
const base64ToPDF = (base64) => {
const byteString = window.atob(base64);
const arrayBuffer = new ArrayBuffer(byteString.length);
const int8Array = new Uint8Array(arrayBuffer);
for (let i = 0; i < byteString.length; i += 1) {
int8Array[i] = byteString.charCodeAt(i);
}
const blob = new Blob([int8Array], { type: 'application/pdf' });
const pdfURL = URL.createObjectURL(blob);
@AugustoCalaca
AugustoCalaca / FormWithTinymce.tsx
Last active September 22, 2020 12:22
Example of how to use tinymce as controlled component by formik with text field material-ui
import React from 'react';
import { useFormik } from 'formik';
import * as Yup from 'yup';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import EditorField from './EditorField';
type InitialValuesFormikType = {
editor: string;
@AugustoCalaca
AugustoCalaca / Fragments.md
Created September 11, 2020 13:52
Resume about relay fragments

About Fragment

  • Fragment is the building block of the relay
  • Fragment is a selection of fields on a GraphQL Type
  • Fragment allow you to colocate data
  • Relay composes fragments from multiple components into optimized and efficient batches to reduce round-trips to the server
  • Its hard to over-fetch and under-fetch
  • Components can only access data they've asked for - data mask - each one must declare its own data requirements without relying on others
  • Components only re-render when the exact data they're using is updated, preventing unnecessary re-renders
  • In short, colocating data make your components modular, easier to refactor, more performant and less error-prone
@AugustoCalaca
AugustoCalaca / liveStreaming.txt
Last active August 21, 2020 14:36
Serviços de live streaming
https://www.sitehosting.com.br/streaming-de-video-ao-vivo/
https://www.mediastream.com.br/
https://colorwhistle.com/live-stream-video-on-website/
https://habr.com/ru/post/453374/
https://www.twilio.com/voice/conference
https://whereby.com/
@AugustoCalaca
AugustoCalaca / AutocompleteRelay.tsx
Created July 29, 2020 13:40 — forked from sibelius/AutocompleteRelay.tsx
@material-ui Autocomplete lab with react-window + infinite-loader for GraphQL/Relay connections
import React, { useRef, useState } from 'react';
import { Typography } from '@material-ui/core';
import TextField from '@material-ui/core/TextField';
import CircularProgress from '@material-ui/core/CircularProgress';
import Autocomplete, {
AutocompleteChangeDetails,
AutocompleteChangeReason,
AutocompleteProps
} from '@material-ui/lab/Autocomplete';
@AugustoCalaca
AugustoCalaca / webpack.server.js
Created July 29, 2020 13:38 — forked from sibelius/webpack.server.js
Webpack config for server
const path = require('path');
const webpack = require('webpack');
const WebpackNodeExternals = require('webpack-node-externals');
const ReloadServerPlugin = require('reload-server-webpack-plugin');
const cwd = process.cwd();
module.exports = {