Skip to content

Instantly share code, notes, and snippets.

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

Gabriel Guerra ogabrielguerra

🏠
Working from home
View GitHub Profile
@ogabrielguerra
ogabrielguerra / branch_as_composer_dependency.json
Created September 25, 2020 01:18
Branch as Composer Dependency
{
"repositories": [
{
"type": "git",
"url": "https://github.com/pressbooks/new-private-project"
}
],
"require": {
"pressbooks/new-private-project": "dev-bugfixes"
}
@ogabrielguerra
ogabrielguerra / AstronautController.php
Last active September 25, 2020 01:36
AstronautController
<?php
class AstronautController{
private string $name;
private float $pounds;
function __construct(string $name, float $pounds){
$this->setName($name);
@ogabrielguerra
ogabrielguerra / detectAnagram.php
Created October 8, 2020 18:35
Detect Anagram
<?php
/*
must return TRUE:

('arc', 'car')

('listen', 'silent')

('malarm', 'malmar')

('peer', 'eper')

must return FALSE:

@ogabrielguerra
ogabrielguerra / onlyNumbers.js
Created December 31, 2020 19:16
Only numbers
$(document).ready(() => {
$(".onlyNumbers").keypress(function (e) {
if (e.which !== 8 && e.which !== 0 && (e.which < 48 || e.which > 57)) {
return false;
}
});
});
new Promise<XMLHttpRequest>((resolve, reject) => {
xhr.onreadystatechange = ()=> resolve(xhr);
})
.then(result => {
(result.status == 200) ? statusMessage(messageSuccess) : statusMessage(messageError);
})
.catch(error => console.log('ERROR:', error.message));
const handleResumeForm = (inputTargetId)=>{
const RESUME_INPUT = document.getElementById(inputTargetId);
const RESUME_FILE_NAME = RESUME_INPUT.value;
const ALLOWED_EXTENSIONS = ['pdf','doc','docx'];
const ERROR_CLASS = 'form-error';
const inArray = (array, key)=>{
let result = false;
array.forEach((item)=>{ item === key ? result = true : '' })
return result;
find . -name "*.[extension]" | xargs wc -l | tail -1
@ogabrielguerra
ogabrielguerra / dump_object_or_table.lua
Created October 26, 2021 11:10
LUA - Dump a table or object
local inspect = require('inspect')
local table = { a='a', b='b', c='c'}
print(inspect(table))
@ogabrielguerra
ogabrielguerra / backup-projects.sh
Created February 28, 2022 21:24
Bash script for backing up web projects.
#!/bin/bash
printf "[BACKUP PROJECTS]\n\n"
temp_dir=$(mktemp -d)
package_name=backup_package
mkdir ~/$package_name
printf "COPYING TO TEMP DIR...\n\n"
@ogabrielguerra
ogabrielguerra / UpscaleWorkaround.py
Created June 10, 2023 22:50
Workaround for Super Resolution Upscaling with any aspect ratio
import math
from PIL import Image, ImageChops
class AdjustImages:
@staticmethod
def get_next_height(height):
fullhd_height = 1080
if height % fullhd_height == 0: