Skip to content

Instantly share code, notes, and snippets.

View YuriFontella's full-sized avatar
💭
sad dev

Yuri Fontella YuriFontella

💭
sad dev
  • Porto Alegre - RS
View GitHub Profile
@YuriFontella
YuriFontella / app.js
Created May 25, 2021 22:17
nextjs-graphql-request
import Head from 'next/head'
import { GraphQLClient, gql } from 'graphql-request'
import { useState, useEffect } from 'react'
const Home = () => {
const [data, setData] = useState()
const endpoint = 'http://localhost:4000/graphql'
@YuriFontella
YuriFontella / server.js
Last active May 28, 2021 05:54
graphql schemas and resolvers with auth
'use strict'
const Fastify = require('fastify')
const mercurius = require('mercurius')
const auth = require('mercurius-auth')
const { ErrorWithProps } = mercurius
const app = Fastify()
https://developer.android.com/studio#downloads (command line)
Depois de baixado criar a seguinte estrutura de pastas (você pode fazer a sua)
Terminal
mkdir -p /opt/android-sdk
Dentro da pasta android-sdk descompacte o conteudo do zip baixado
@YuriFontella
YuriFontella / api.js
Last active January 18, 2021 21:24
hook api requests react (axios, swr)
import { getSession } from 'next-auth/client'
import { useCallback, useState } from 'react'
import axios from 'axios'
import useSWR, { mutate } from 'swr'
const api = axios.create({
baseURL: process.env.API,
'use strict'
const fastify = require('fastify')()
const db = require('./knexfile')
fastify.register(require('fastify-knexjs'), db.development, err => console.error(err))
fastify.register(require('fastify-jwt'), {
secret: '@xyZ33#a21'
#!/bin/sh
## CONFIGURAÇÃO
touch /etc/hostname
echo "emcasadormindo" > /etc/hostname
sed -i -- 's/#pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/g' /etc/locale.gen
sed -i -- 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
'use strict'
const readline = require('readline')
module.exports = hint => {
return new Promise((resolve, reject) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
# Add support for https on wget
RUN apk update && apk add --no-cache wget && apk --no-cache add openssl wget && apk add ca-certificates && update-ca-certificates
# Add phantomjs
RUN wget -qO- "https://github.com/dustinblackman/phantomized/releases/download/2.1.1a/dockerized-phantomjs.tar.gz" | tar xz -C / \
&& npm config set user 0 \
&& npm install -g phantomjs-prebuilt
# Add fonts required by phantomjs to render html correctly
RUN apk add --update ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family && rm -rf /var/cache/apk/*
@YuriFontella
YuriFontella / rtm.js
Created May 14, 2019 20:20
integração dois workspaces slackbots
'use strict'
const { RTMClient } = require('@slack/rtm-api')
const { WebClient } = require('@slack/web-api');
const { sleep } = require('sleep')
const web = new WebClient()
const _ = require('lodash')
let alarm = { hostname: 'arch', ip: '127.0.0.1', group: 'servers', item: 'cpu', trigger: 'low' }
let rule = await model.Rules.findOne({
include: [{ as: 'acls', model: model.Acls, attributes: ['hostname', 'ip', 'group', 'item', 'trigger', 'status', 'time_start', 'time_end'], where: { type: 'zabbix' } }],
attributes: ['uuid', 'status'],
where: { client: '5bbcab43c4ba0b3f9ba4eca6' },
order: [[{ as: 'acls', model: model.Acls }, 'sequence', 'DESC']]
})