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 / bright_control.md
Last active February 12, 2025 15:06
Bright Control

I did something, better then Apple 🍎. I don't know if you noted, but everytime I logoff in our call, my computer shutdown, because I didn't saw the alert about battery.

With this the screen will turn off, it's impossible doesn't notice, but this will happen before the computer turn off, 1% before.

touch ~/bright_control.sh


while true; do
    # Get the battery level
@julioflima
julioflima / daily.sh
Created February 10, 2025 10:16
Daily
#!/bin/bash
# Do it:
# git config --global alias.daily '!~/projects/scripts/daily.sh'
# git daily
# Define variables
AUTHOR_NAME="Julio Lima"
TODAY=$(date "+%Y-%m-%d")
API_KEY="your-openai-api-key" # Replace with your OpenAI API key
@julioflima
julioflima / colorParser.js
Last active January 30, 2025 12:04
Get all HEX colors from text and remove repeated.
// select all the lines that doesn't have an color in #hex
// #(?:[0-9a-fA-F]{3}){1,2}\b
// select all the lines that doesn't have an color in #hex
// replace it for something unique: "lalalallalalallalalalallalalla"
// select all CMD + D, then remove lines
// ^(?!.*#(?:[0-9a-fA-F]{3}){1,2}\b).*
const text = `45: @function photoshop-shadow($angle: 0, $distance: 0, $spread: 0, $size: 0, $color: #000, $inner: false) {
@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();
});
};