Skip to content

Instantly share code, notes, and snippets.

View emrivero's full-sized avatar
💻
Road to computer engineering

Emilio Martínez Rivero emrivero

💻
Road to computer engineering
  • G+D
  • Seville, Spain
View GitHub Profile
@emrivero
emrivero / moon_phase.js
Created March 26, 2022 11:41 — forked from Dither/moon_phase.js
JS function to calculate moon phase
function moon_phase(date) { // ported from http://www.voidware.com/moon_phase.htm
var year = date.getYear(),
month = date.getMonth(),
day = date.getDay();
if (month < 3) {
year--;
month += 12;
}
@emrivero
emrivero / apuntes
Created February 16, 2022 17:22
Apuntes
FTP (File Transfer Protocol - Protocolo de Transferencia de Archivos) es un programa que se
utiliza para transferir información, almacenada en ficheros, de una máquina remota a otra local,
o viceversa (RFC 959). Para poder realizar esta operación es necesario conocer la dirección IP (o
el "nombre") de la máquina a la que nos queremos conectar para realizar algún tipo de
transferencia.
El Servicio FTP es ofrecido por la capa de Aplicación del
modelo de capas de red TCP/IP al usuario, utilizando
normalmente el puerto de red 20 y el 21. Un problema
básico de FTP es que está pensado para ofrecer la
máxima velocidad en la conexión, pero no la máxima
import os
import pathlib
import shutil
import csv
import json
import urllib.request
# with open("./main.py", mode='r', encoding='utf8') as f:
# for line in f:
# print(line)
@emrivero
emrivero / auth-hook.js
Created December 9, 2021 16:37 — forked from ulises-jeremias/auth-hook.js
Examples of hooks utils using axios, recoil.js, keycloak-js, @react-keycloak/web and more.
import { useCallback, useEffect, useState } from 'react';
import { useSetRecoilState } from 'recoil';
import { useKeycloak } from '@react-keycloak/web';
import { commonNotification } from './common';
/**
* Returns the auth info and some auth strategies.
*
*/
@emrivero
emrivero / cloudSettings
Last active January 26, 2022 09:12
Visual Studio Code Settings Sync Gist
{"lastUpload":"2022-01-26T09:11:47.492Z","extensionVersion":"v3.4.3"}
@emrivero
emrivero / context_adesalambrar.xml
Last active November 23, 2020 12:32
WMC Mapea
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<ViewContext version="1.1.0" id="Idea"
xmlns="http://www.opengis.net/context"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/context
http://schemas.opengis.net/context/1.1.0/context.xsd">
<General>
@emrivero
emrivero / base64.js
Created October 16, 2020 12:56 — forked from enepomnyaschih/base64.js
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@emrivero
emrivero / base64.js
Created October 16, 2020 12:56 — forked from enepomnyaschih/base64.js
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@emrivero
emrivero / greedy.js
Created August 15, 2020 00:25
Knapsack Problem
const items = [{ v: 4, w: 5 }, { v: 2, w: 3 }, { v: 5, w: 6 }];
class Bag {
constructor(maximumWeight) {
this.weight = 0;
this.maximumWeight = maximumWeight;
this.value = 0;
this.items = [];
}
@emrivero
emrivero / square.js
Created November 29, 2019 09:07
Simple square movement
const canvas = document.querySelector('#canvas');
let posX = 0;
let posY = 0;
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(posX, posY, 20, 20);
const moveLeft = (ctx) => {
ctx.clearRect(posX, posY, 20, 20);
posX -= 10;