Skip to content

Instantly share code, notes, and snippets.

View julioflima's full-sized avatar
🏠
Working from home

Julio Lima julioflima

🏠
Working from home
View GitHub Profile
@julioflima
julioflima / index.js
Created June 12, 2024 10:42
Vigil - Backend Test
/*
# backend-challenge
After reading the Linux kernel coding style, you discover the magic of having lines of code with a maximum of 80 characters each.
So, you decide that from now on your outgoing emails will also follow a similar pattern and you decide to develop a plugin to help you with that.
Implement a function that receives:
- *any text*
- *a character limit per line*

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@julioflima
julioflima / widest-interval.js
Last active June 19, 2023 11:28
Google Step one
const data = [50, 60, 40, 80, 30, 56, 63, 42, 65, 23];
const findWidestInterval = (data) => {
if (Array.isArray(data) && !!data.length) {
const maxLostInterval = 0;
for (let i = 0; i < data.length - 1; i += 1) {
for (let j = i; j < data.length - 1; j += 1) {
const startPrice = data[i];
const endPrice = data[j];
import axios, { AxiosRequestConfig } from 'axios';
import useAuth from 'hooks/useAuth';
const findOperationName = (gql: string) => {
const indexOfParentesis = gql.indexOf('(');
const indexOfSpaceNearParentesis = Array(...gql).reduce(
(acc, curr, index) => (curr === ' ' && indexOfParentesis - index > acc ? index : acc),
0
);
@julioflima
julioflima / install-chrome-config.sh
Last active November 19, 2020 03:11
Install Chrome on any Linux and install the extensiom Custom Javascript for Websites 2
#!/bin/bash
echo 'installing git'
sudo apt install git -y
git config --global user.name "Julio Lima"
git config --global user.email "[email protected]"
clear
echo "Generating a SSH Key"
@julioflima
julioflima / SensorController.js
Created September 6, 2020 12:07
Controller reading, writing and deleting o db.
const Cloud = require('../model/database/Cloud');
const db = new Cloud('development').connection();
module.exports = class SensorController {
static async index(req, res) {
try {
const { name } = req.query;
const count = await db('sensor')
@julioflima
julioflima / migrations.js
Last active September 6, 2020 12:04
Migrations using Query Builder Knex.
exports.up = (knex) => {
return knex.schema.createTable('sensor', (table) => {
table.string('id').primary();
table.bigInteger('timestamp').notNullable().primary();
table.string('date').notNullable();
table.string('name').notNullable();
table.float('value').notNullable();
});
};
@julioflima
julioflima / Cloud.js
Last active September 6, 2020 10:54
Cloud in class, have all configuration of database.
const knex = require('knex');
module.exports = class Cloud {
constructor(enviroment) {
// Object
this.knex = knex;
// Variables
this.enviroment = enviroment;
}
@julioflima
julioflima / index.js
Last active September 6, 2020 09:52
Server listener.
const Routes = require('./Routes');
const App = require('./App.js');
const routes = new Routes();
const app = new App(routes).server;
app.listen(3000);
@julioflima
julioflima / App.js
Created September 5, 2020 05:58
App in class to facilitate reuse.
const express = require('express');
const cors = require('cors');
const { errors } = require('celebrate');
module.exports = class App {
constructor(routes) {
this.routes = routes;
this.server = express();
this.middleware();
this.router();