Skip to content

Instantly share code, notes, and snippets.

View izquiratops's full-sized avatar
🐀
Lost in the sauce

Jordi izquiratops

🐀
Lost in the sauce
  • Barcelona - Spain
  • 06:44 (UTC -12:00)
View GitHub Profile
@izquiratops
izquiratops / idea.sh
Last active May 16, 2022 10:07 — forked from agoncal/idea
Open IntelliJ Idea from bash
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@izquiratops
izquiratops / vec3.js
Created April 17, 2022 09:16
3D vector math utils
const clamp = (v, min, max) => v < min ? min : (v > max ? max : v);
const scale = (v, in_min, in_max, out_min, out_max) => out_min + ((out_max) - out_min) * (((v) - in_min) / ((in_max) - in_min));
const anglemod = (r) => Math.atan2(Math.sin(r), Math.cos(r));
const vec3 = (x = 0, y = 0, z = 0) => ({x, y, z});
const vec3_rotate_yaw_pitch = (p, yaw, pitch) => vec3_rotate_y(vec3_rotate_x(p, pitch), yaw);
const vec3_rotate_y = (p, rad) => vec3(p.z * Math.sin(rad) + p.x * Math.cos(rad), p.y, p.z * Math.cos(rad) - p.x * Math.sin(rad));
const vec3_rotate_x = (p, rad) => vec3(p.x, p.y * Math.cos(rad) - p.z * Math.sin(rad), p.y * Math.sin(rad) + p.z * Math.cos(rad));
const vec3_2d_angle = (a, b) => Math.atan2(b.x - a.x, b.z - a.z);
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.Range;
public class TerstingLibs {
private static final ImmutableRangeSet<Integer> RANGE_SET_ONE =
ImmutableRangeSet.<Integer>builder()
.add(Range.closed(2, 4))
.add(Range.open(6, 7))
.add(Range.closedOpen(8, 10))
.add(Range.openClosed(15, 17))
@izquiratops
izquiratops / tweets.component.html
Last active July 25, 2021 08:52
Change Detection code snippets
<h1> Tweets absurdos </h1>
<p> {{ tweet }} </p>
@izquiratops
izquiratops / jwt-expiration.md
Created December 4, 2020 13:58 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

use('globalDrone-Main');
const aggregationTotalBytes = [
{ $match: {
deviceId: '78ea0d4d-876e-4543-bfbb-4a00789e9cfd',
time: { $gte: new Date('2019-01-01'), $lt: new Date('2020-06-19') }
} },
{ $group: {
_id: {
month: { $month: '$_id' },
@izquiratops
izquiratops / aggregation.md
Last active June 2, 2020 09:40
Date Aggregation Mongodb
{
  _id: {
    flightOperationHash: "$flightOperationHash",
    interval: {
      $subtract: [
        { "$minute": "$time" },
        { "$mod": [{ "$minute": "$time"}, 1] }
      ]
    }
@izquiratops
izquiratops / WebServer.java
Created February 21, 2020 08:31
Spark WebServer Template
import static spark.Spark.*;
import java.io.File;
import java.io.OutputStream;
import java.nio.file.Files;
public class WebServer {
public static void main(String[] args) {
enableCORS("*", "GET", "Content-disposition");
<i class="arrow"></i>
<style>
.arrow {
position: absolute;
font-size: 4em;
-webkit-animation:ease-in-out infinite alternate;
-webkit-animation-name: run;
-webkit-animation-duration: 1.15s;
}
@izquiratops
izquiratops / Install_OpenCV4_CUDA10.md
Created September 5, 2019 09:04 — forked from raulqf/Install_OpenCV4_CUDA12.6_CUDNN8.9.md
How to install OpenCV 4.1 with CUDA 10.0 in Ubuntu 18.04

How to install OpenCV 4.1.0 with CUDA 10.0 in Ubuntu distro 18.04

First of all install update and upgrade your system:

    $ sudo apt update
    $ sudo apt upgrade

Then, install required libraries: