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 / LayerGroup.md
Last active September 11, 2019 08:37
Documentación de la API de M.layer.LayerGroup

API LayerGroup

Constructor:

new M.layer.LayerGroup({
  id: <string>,
  title: <string>,
  collapsed: <boolean>,
  zIndex: <number>,
 children: &gt;,
@emrivero
emrivero / event_manager.js
Created November 28, 2019 21:46
Small key event manager
class EventManager {
constructor(keyBindings, options) {
this.pressedKeys = {};
this.keyBindings = keyBindings;
this.options = options;
if (document) {
document.addEventListener('keydown', e => this.pressedKeys[e.key] = true);
document.addEventListener('keyup', e => this.pressedKeys[e.key] = false);
}
@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;
@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 / 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 / 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 / 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 / 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.
*
*/
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)