Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Quintana joseluisq

View GitHub Profile
@joseluisq
joseluisq / settings.json
Created Jun 20, 2022
My custom VSCode settings for Mac
View settings.json
{
// ---- Editor ----
"editor.fontFamily": "Fira Code",
"editor.fontSize": 12,
"editor.fontLigatures": true,
"editor.detectIndentation": true,
"editor.wordWrap": "on",
"editor.formatOnSave": false,
"editor.rulers": [
132
View keybase.md

Keybase proof

I hereby claim:

  • I am joseluisq on github.
  • I am joseluisq (https://keybase.io/joseluisq) on keybase.
  • I have a public key ASCqLTIgaAbKLdRO9_EgKnYlH747jhjMPp_qFwFOcklXtgo

To claim this, I am signing this object:

@joseluisq
joseluisq / env.ts
Last active May 10, 2022
Get a Typescript typed environment variable value from `process.env` (NodeJS) with type casting for booleans, strings and numbers
View env.ts
/**
* Return an environment variable typed value from `process.env`.
* It also supports a default value in case of `undefined`.
*
* The function will follow these steps to take a typed value:
* 1. First it will try to get the env value from `process.env`.
* 2. Then if `undefined` then it try with the default environment variable value if defined.
* 3. Otherwise if the default value is `undefined` then it will return the Javascript default values:
* - Boolean: `false`
* - String: `""`
View 40-libinput.conf
# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
# Identifier "something or other"
# MatchDriver "libinput"
#
# MatchIsTouchpad "on"
@joseluisq
joseluisq / try_files.rs
Created Jun 27, 2021
A simple Nginx `try_files` directive parsing example written in Rust
View try_files.rs
enum Token {
Start,
Middle,
End,
}
/// Parses the Nginx-like `try_files` directive string and returns a vector of tokens.
pub fn parse(val: &str) -> Vec<String> {
let mut kind = Token::Start;
let mut token = String::new();
@joseluisq
joseluisq / response.ts
Created Apr 5, 2021
Una simple convención que representa respuestas de servidor JSON.
View response.ts
/** Representa una respuesta JSON satisfactoria */
interface ResponseOk<T = null> {
success: true
data: T
}
/** Representa una respuesta JSON errónea */
interface ResponseFail<T = null> {
success: false
code: string|number
@joseluisq
joseluisq / random_hash.js
Created Apr 5, 2021
Generate secure random string values in Javascript using cryto-random bytes
View random_hash.js
/** Generate secure random string values in Javascript using cryto-random bytes */
function randomHash (len) {
return Array.from(
window.crypto.getRandomValues(new Uint8Array(Math.ceil(len / 2))),
(b) => ("0" + (b & 0xFF).toString(16)).slice(-2)
).join("")
}
// Simple tests with various lengths
@joseluisq
joseluisq / resize_disk_image.md
Last active Aug 15, 2022
How to resize a qcow2 disk image on Linux
View resize_disk_image.md

How to resize a qcow2 disk image on Linux

This example takes olddisk.qcow2 and resizes it into newdisk.qcow2, extending one of the guest's partitions to fill the extra space.

1. qcow2 format

1.1. Verify the filesystems of olddisk.qcow2

@joseluisq
joseluisq / main.rs
Created Feb 10, 2021 — forked from lu4nm3/main.rs
Tokio Async: Concurrent vs Parallel
View main.rs
use futures::StreamExt;
use std::error::Error;
use tokio;
use tokio::macros::support::Pin;
use tokio::prelude::*;
use tokio::time::{Duration, Instant};
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut multi_threaded_runtime = tokio::runtime::Builder::new()
.threaded_scheduler()