Skip to content

Instantly share code, notes, and snippets.

View AugustoCalaca's full-sized avatar

Augusto Calaca AugustoCalaca

View GitHub Profile
@AugustoCalaca
AugustoCalaca / workflow.yml
Last active October 16, 2023 19:18
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 / UserList.spec.tsx
Created November 5, 2019 15:04
Simple test using relay-test-utils and react-testing-library
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import { MockPayloadGenerator } from 'relay-test-utils';
import UserListDefault from '../UserList';
import Environment from 'path/to/Environment';
afterEach(cleanup);
describe('<UserList />', () => {
it('should reject query', () => {
@AugustoCalaca
AugustoCalaca / UserAddedSubscription.spec.ts
Last active March 22, 2023 23:43
An example of how to test graphql subscriptions with jest
import { graphql, subscribe, parse } from 'graphql';
import {
connectMongoose,
disconnectMongoose,
clearDbAndRestartCounters,
getContext,
} from '../../../../../test/helpers';
import { schema } from '../../../../schema/schema';
@AugustoCalaca
AugustoCalaca / TransactionList.spec.tsx
Last active February 7, 2023 22:27
test using relay hooks, relay-test-utils and react-testing-library
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import { MockPayloadGenerator } from 'relay-test-utils';
import { useRelayEnvironment } from 'react-relay/hooks';
import TransactionList from '../TransactionList';
afterEach(cleanup);
describe('<TransactionList />', () => {
it('should reject query', () => {
@AugustoCalaca
AugustoCalaca / UserAddedSubscription.ts
Created June 13, 2020 19:26
A graphql subscription using the lib graphql-relay-subscription
import { subscriptionWithClientId } from 'graphql-relay-subscription';
import UserType from '../UserType';
import * as UserLoader from '../UserLoader';
import pubSub, { EVENTS } from '../../../channels/pubSub';
const UserAddedSubscription = subscriptionWithClientId({
name: 'UserAdded',
inputFields: {},
subscribe: () => pubSub.asyncIterator(EVENTS.USER.ADDED),
@AugustoCalaca
AugustoCalaca / lodashGetToOptionalChaining.js
Created March 16, 2022 00:35
codemod to convert lodash get to use optional chaining
const lodashGetToOptionalChaining = (file, api) => {
const codeShift = api.jscodeshift;
const root = codeShift(file.source);
const importDeclaration = root.find(codeShift.ImportDeclaration, {
source: {
type: 'Literal',
value: 'lodash/get',
},
@AugustoCalaca
AugustoCalaca / graphiql-over-ws.html
Created January 14, 2022 18:28 — forked from enisdenjo/graphiql-over-ws.html
GraphiQL ❤️ graphql-ws
<!--
* Copyright (c) 2021 GraphQL Contributors
* All rights reserved.
*
* This code is licensed under the MIT license.
* Use it however you wish.
-->
<!DOCTYPE html>
<html>
<head>

AWS Fargate Docker Simple Deployment Setup with SSL termination

How to:

  • create a Docker-based AWS Fargate/ECS deployment
  • without the Docker containers having a public IP
  • with an Application Load Balancer as reverse proxy / SSL termination proxy sitting in front of the containers

For Fargate/ECS to be able to access your Docker images hosted on ECR (or somewhere else) you'll have to allow outbound internet access to the Fargate subnets. Here's how you do it.

@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");
@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