Skip to content

Instantly share code, notes, and snippets.

View markusand's full-sized avatar

Marc Vilella markusand

View GitHub Profile
@markusand
markusand / functional.py
Last active December 28, 2023 01:11
Set of functional programming utilities for working with lists.
""" Functional module """
from typing import List, Dict, Callable, TypeVar, Optional
T = TypeVar('T')
U = TypeVar('U')
def map(predicate: Callable[[T], U], items: List[T]) -> List[U]:
'''
Applies a given function to all items in the list and returns a new list
containing the results.
@markusand
markusand / proxy.py
Created November 4, 2022 01:49
HTTP Proxy to redirect GET requests to POST
import os
import json
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib import parse
from requests import post
port = os.environ['PROXY_PORT']
url = os.environ['FORWARD_URL']
token = os.environ['TOKEN']
@markusand
markusand / Brewfile
Last active March 30, 2024 02:14
macOS auto setup
tap "homebrew/bundle"
# BASIC SOFTWARE
brew "mas"
mas "Slack", id: 803453959
mas "The Unarchiver", id: 425424353
mas "Spark", id: 1176895641
mas "Dropover", id: 1355679052
mas "Bitwarden", id: 1352778147
cask "rectangle"
@markusand
markusand / logger.js
Created January 15, 2022 18:33
Express logger module with Winston + Morgan
import winston from 'winston';
import morgan from 'morgan';
import json from 'morgan-json';
/* WINSTON */
const filterLevel = level => winston.format(info => info.level === level ? info : undefined)();
const logger = winston.createLogger({
levels: { error: 0, warn: 1, info: 2, debug: 3, http: 4 },
transports: [
@markusand
markusand / markdown.md
Last active June 10, 2022 19:27
Andorra Recerca + Innovació Toolbox - https://bit.ly/2YLNQU1

Seminari markdown

header

💡 Què és?

Markdown és un llenguatge de marcat lleuger per donar format simple a textos.

  • Estàndard (més o menys)
  • Simple
@markusand
markusand / README.md
Last active August 12, 2023 22:51
stats-fns: Calculate simple statistics metrics

Statistics functions

Set of statistics functions for simple analysis.

Install

npm i gist:acb7729589f6ef734449c483045efe0c
@markusand
markusand / README.md
Last active July 23, 2021 15:18
Create fancy enter/leave animations in page elements, when switching between vue-router views.

Vue 3 Router Animations

Create fancy enter/leave animations in page elements, when switching between vue-router views.

Vue Router Animations

📦 Install

npm i gist:bd502b019ba91f8f70b3a8f5cbb6f4d8
@markusand
markusand / README.md
Last active May 23, 2021 18:28
Syntactic sugar helpers for Vuex

Vuex Saccharin

Syntactic sugar helpers to leverage Vuex usage and write less repetitive code.

📦 Install

npm i gist:7b2bec2ef24eb5c1d30d83660af49ed6
@markusand
markusand / README.md
Created May 21, 2020 10:23
Create a Processing library

Create a Processing library

Compile a Processing sketch into a library that can be used with an import. This is helpful to reduce the amount of Processing tabs in a project, specially for that bunch of classes that won't be changed and belong to a same conceptual group.

Translate Processing's .pde files to .java files, getting rid of all the Processing core functions by java equivalents (ex. sin() to Math.sin()) and/or import Processing classes (ex. PVector). Add package name at the beginning of every java class file.

Open Terminal and go to sketch's directory. Type the following command

javac -cp [processing_path]:[extra_libraries] -source 1.6 -target 1.6 -d . *.java
@markusand
markusand / use-luhn.js
Last active June 29, 2021 00:11
Use function to generate and validate Luhn mod N algorithm checksums for strings
export default (chars = 'ABCDEFGHJKMNPQRSTUVWXYZ0123456789') => {
const checksum = input => {
const { sum } = input.split('').reverse().reduce((acc, char) => {
const addend = acc.factor * chars.indexOf(char);
acc.factor = acc.factor === 2 ? 1 : 2;
acc.sum += Math.floor(addend / chars.length) + (addend % chars.length);
return acc;
}, { sum: 0, factor: 2 });
const remainder = sum % chars.length;
return chars[(chars.length - remainder) % chars.length];