Skip to content

Instantly share code, notes, and snippets.

View AugustoCalaca's full-sized avatar

Augusto Calaca AugustoCalaca

View GitHub Profile
@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 / 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 / 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 / MEMOIZE.md
Created April 5, 2021 00:42 — forked from mrousavy/MEMOIZE.md
Memoize!!! 💾 - a react (native) performance guide
In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and  
returning the cached result when the same
inputs occur again.                                         
                                                     — wikipedia
@AugustoCalaca
AugustoCalaca / devTraining.md
Created April 5, 2021 01:05 — forked from sibelius/devTraining.md
How to train your dev team

you should review every pull request of your team

  • each pull request will make understand what everyone in your team is working on
  • it will ensure you keep consistency of file location, and code patterns
  • it will catch bugs/regression early on
  • it will teach the best way to solve the problem

you should ensure consistency of the code base

you should pair programming with all devs of your team

@AugustoCalaca
AugustoCalaca / debugRelay.ts
Created April 12, 2021 14:54 — forked from sibelius/debugRelay.ts
debug relay utils
import prettyFormat from 'pretty-format';
const excludeKeys = ['__fragments', '__id', '__fragmentOwner'];
// strip __fragments, __id, __fragmentOwne
export const relayTransform = (key: string, value: string) => {
if (excludeKeys.includes(key)) {
return undefined;
}
name: Test, Build and Deploy
on:
pull_request:
types: [closed]
jobs:
build-test-release:
if: github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
@AugustoCalaca
AugustoCalaca / workflow.yml
Last active September 6, 2024 17:22
example of workflow ci/cd for monorepo with github actions
name: CI/CD Monorepo
env:
AWS_REGION: us-east-1 # N. Virginia
on:
push:
branches:
- main
paths-ignore:
@AugustoCalaca
AugustoCalaca / query.sql
Created September 10, 2021 00:22
How to find duplicate text values with postgres
select id, name from table t1
where (
select count(*) from table t2
where regexp_replace(unaccent(trim(t1.name)), '\W+', '', 'g') ilike regexp_replace(unaccent(trim(t2.name)), '\W+', '', 'g')
) > 1
order by name asc
@AugustoCalaca
AugustoCalaca / esbuild-relay.js
Created October 13, 2021 13:25 — forked from sciyoshi/esbuild-relay.js
Esbuild plugin for compiling relay queries
import { promises } from "fs";
import crypto from "crypto";
import path from "path";
import { print, parse } from "graphql";
const plugin = {
name: "relay",
setup: build => {
build.onLoad({ filter: /\.tsx$/, namespace: "" }, async args => {
let contents = await promises.readFile(args.path, "utf8");