Skip to content

Instantly share code, notes, and snippets.

View franciscohanna92's full-sized avatar

Francisco Hanna franciscohanna92

View GitHub Profile
@franciscohanna92
franciscohanna92 / tanks.js
Created March 20, 2023 12:30
p5.js tanks game
let tank;
let bullet;
let obstacles = [];
let tankImg, bulletImg;
let aiTanks = [];
// Add constants for the play area size
const PLAY_AREA_WIDTH = 1000;
const PLAY_AREA_HEIGHT = 1000;
@franciscohanna92
franciscohanna92 / async_functions_in_order.js
Last active March 2, 2022 12:18
Execute array of async functions in order
/*
Given an array of async functions, execute them in order.
*/
// Our async functions array
const asynFunctions = [
() => new Promise((resolve) => setTimeout(() => resolve("1"), 200)),
() => new Promise((resolve) => setTimeout(() => resolve("2"), 300)),
() => new Promise((resolve) => setTimeout(() => resolve("3"), 100))
]
@franciscohanna92
franciscohanna92 / post-form.component.tsx
Last active August 2, 2021 01:17
An idea on how to organize a Model module in React (using react-query as the caching/store service)
import React from "react";
import { useForm } from "react-hook-form";
import { Post, usePostModel } from "../models/post.model";
interface Props {
post?: Post;
onSubmit?: () => void;
}
interface PostForm {
@franciscohanna92
franciscohanna92 / stored_procedure_live_template
Created April 28, 2019 02:25
Stored procedure with error handling live template for Intellij Datagrip
use $database$
DELIMITER $$
drop procedure if exists $procedureName$ $$
create procedure $procedureName$()
begin
declare exit handler for sqlexception
begin
get diagnostics condition 1 @sqlstate = returned_sqlstate , @errno = mysql_errno , @text = message_text ;
set @full_error = concat('ERROR ', @errno, @`sqlstate`, @text);
@franciscohanna92
franciscohanna92 / switch-to-php5.6.sh
Created July 25, 2018 13:46
witch from php7.2 to php5.6
# change apache's php
a2dismod php7.2
a2enmod php5.6
service apache2 restart
# change system's php
update-alternatives --set php /usr/bin/php5.6
update-alternatives --set phar /usr/bin/phar5.6
update-alternatives --set phar.phar /usr/bin/phar.phar5.6
update-alternatives --set phpize /usr/bin/phpize5.6
@franciscohanna92
franciscohanna92 / switch-to-php7.2.sh
Created July 25, 2018 13:43
Switch from php5.6 to php7.2
# change apache's php
a2dismod php5.6
a2enmod php7.2
service apache2 restart
# change system's php
update-alternatives --set php /usr/bin/php7.2
update-alternatives --set phar /usr/bin/phar7.2
update-alternatives --set phar.phar /usr/bin/phar.phar7.2
update-alternatives --set phpize /usr/bin/phpize7.2
@franciscohanna92
franciscohanna92 / gulpfile.js
Last active June 12, 2018 16:52
Uglify js, preprocess scss and watchers
const gulp = require('gulp');
var gutil = require('gulp-util');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify-es').default;
const rename = require('gulp-rename');
var sass = require('gulp-sass');
let cleanCss = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');
const vendorJs = [
@franciscohanna92
franciscohanna92 / reinstall_docker.sh
Last active April 13, 2021 22:29 — forked from jeygeethan/reinstall_docker.sh
reinstall docker on any machine
#!/usr/sh
sudo service docker stop && sudo apt-get purge -y docker-ce && sudo apt-get autoremove --purge -y docker-ce && sudo rm -rf /var/lib/docker && sudo apt-get update && sudo apt-get install -y docker-ce && sudo service docker start && sudo docker run hello-world && sudo usermod -aG docker $USER