Skip to content

Instantly share code, notes, and snippets.

View wendelnascimento's full-sized avatar
🎯
Focusing

Wendel Nascimento wendelnascimento

🎯
Focusing
View GitHub Profile
@wendelnascimento
wendelnascimento / azure-pipelines.yaml
Created August 11, 2021 20:49
Azure Functions remote build on Azure Pipelines
# Node.js Function App to Linux on Azure
# Build a Node.js function app and deploy it to Azure as a Linux function app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- main
variables:
@wendelnascimento
wendelnascimento / renamefiles.sh
Created October 22, 2020 20:34
Rename all files in directory sequentially (preserving file original extension)
ls | cat -n | while read n f; do mv "$f" "new name${n}_new name$n.${f##*.}"; done
throw new ExecutionError('USER_ERROR', 'Invalid credentials', 401);
try {
const user = await UserService.userMethod(req.body.code);
res.status(200).json(loggedUser);
} catch (e) {
res.status(e.status || 400).json({
error: e.name,
message: e.message,
});
}
class ExecutionError extends Error {
constructor(name, message, status = 400) {
super();
this.name = name;
this.message = message;
this.status = status;
}
}
module.exports = ExecutionError;
import React from 'react';
import { useMutation } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import { Box, Flex } from '@primer/components';
import styled from 'styled-components';
const ADD_CLAP_MUTATION = gql`
mutation addClap($postId: String!) {
addClap(postId: $postId) {
id
import React from 'react';
import { Flex, Box } from '@primer/components';
import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import PostItem from '../PostItem/PostItem';
const GET_POSTS_QUERY = gql`
query posts {
posts {
import React, { useRef, useState } from 'react';
import { Box, Flex, Button, TextInput, Flash } from '@primer/components';
import { useMutation } from '@apollo/react-hooks';
import gql from 'graphql-tag';
const ADD_POST_MUTATION = gql`
mutation addPost($post: AddPostInput!) {
addPost(post: $post) {
id
picture
@wendelnascimento
wendelnascimento / apolloConfig.js
Created November 25, 2019 21:17
apolloConfig
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { createUploadLink } from 'apollo-upload-client';
import { onError } from 'apollo-link-error';
import { ApolloLink } from 'apollo-link';
const client = new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
@wendelnascimento
wendelnascimento / removeFlowTypes.js
Created May 24, 2019 20:22
Remove flow types from all js and jsx files
const fs = require('fs');
const glob = require('glob-fs')();
const flowRemoveTypes = require('flow-remove-types');
const firstline = require('firstline');
const files = glob.readdirSync('src/**/@(**.js|**.jsx)', {});
files.forEach(async (file) => {
console.log(`Found file ${file}, checking if it has flow annotion on first line`);
const hasFlowAnnotation = await firstline(file);