Skip to content

Instantly share code, notes, and snippets.

View joseluisq's full-sized avatar

Jose Quintana joseluisq

View GitHub Profile
@joseluisq
joseluisq / renew-gpgkey.md
Created September 2, 2020 21:55 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@joseluisq
joseluisq / slugify.ts
Created August 18, 2020 20:22
Custom Typescript slugify function
export function slugify (text: string, separator = "-", ampersand = "and") {
const a = "àáäâèéëêìíïîòóöôùúüûñçßÿỳýœæŕśńṕẃǵǹḿǘẍźḧ"
const b = "aaaaeeeeiiiioooouuuuncsyyyoarsnpwgnmuxzh"
const p = new RegExp(a.split("").join("|"), "g")
return text.toString().toLowerCase()
// Replace whitespaces and underscores with single hyphens
.replace(/[\s_]+/g, separator)
// Replace special chars
.replace(p, (c) => b.charAt(a.indexOf(c)))
@joseluisq
joseluisq / README.md
Last active August 10, 2020 12:22
How to get just the name of first Docker service running

How to get just the name of first Docker service running

Following command will get just the name of the first Docker service running (usually the last one deployed) of a list of N services with running/shutdown/etc status.

Format name: service_name.N.ID

docker service ps my_service_name \
    --no-trunc --format="{{.Name}}.{{.ID}}/{{.DesiredState}}" | grep "Running" | cut -f1 -d "/" | head -n1
# my_service_name.1.abcd1v23ui456pyu7lx8k9fze
@joseluisq
joseluisq / docker-compose.yml
Last active August 10, 2020 11:36
How to run InfluxData Telegraf using Docker compose in order to collect host and containers metrics
version: "3"
services:
telegraf:
image: telegraf:1.14-alpine
environment:
HOST_ETC: /hostfs/etc
HOST_PROC: /hostfs/proc
HOST_SYS: /hostfs/sys
HOST_MOUNT_PREFIX: /hostfs
volumes:
@joseluisq
joseluisq / BENCHMARK
Created April 8, 2020 21:24
Rust web frameworks benchmark focus on static-file serving.
This is an opinioned benchmark that I have made for testing some Rust web frameworks focus on static-file serving feature using the minimal code that every framework provides.
Yes! This can vary per use case and is just another "benchmark".
-------------------------------------
OS: Arch Linux
Kernel: Linux 5.6.2-arch1-2 x86_64
------
$ rustc -vV
rustc 1.42.0 (b8cedc004 2020-03-09)
@joseluisq
joseluisq / .emacs
Created February 28, 2020 15:17
Checking for a specific Emacs version on .emacs file
;; Emit a warning when Emacs version is not greater or equal to 24.1
(when (and (<= emacs-major-version 24) (< emacs-minor-version 1))
(warn (format "\
Emacs v%s.%s is not supported for this configuration. Try to upgrade to v24.1+." emacs-major-version emacs-minor-version)))
;; Continue installing MELPA packages etc...
@joseluisq
joseluisq / dotenv.sh
Last active February 25, 2020 10:55 — forked from mihow/load_dotenv.sh
Load environment variables from a .env file from a Bash shell script
#!/usr/bin/env bash
set -e
set -u
if [ -f .env ]; then
export $(cat .env | xargs)
else
echo ".env file not found"
fi
@joseluisq
joseluisq / download_testing_stats.sh
Last active February 17, 2020 14:22
Testing download file speed using cUrl and get its stats into a log file. Unix-like systems only.
#!/bin/bash
# For customize the writeout take a look at https://ec.haxx.se/usingcurl/usingcurl-verbose/usingcurl-writeout
curl -Skw "\
CURL download file testing\n\
==========================\n\
URL: %{url_effective}\n\
Response code: %{response_code}\n\
Download size: %{size_download}B\n\
@joseluisq
joseluisq / xpath_searching.md
Created February 13, 2020 13:07
XPath v1.0 searching

XPath v1.0 searching

Search all attributes in a xml node

//my-node/attribute::*

Search all namespaces in a xml node

@joseluisq
joseluisq / programming_languages_keywords.json
Last active September 14, 2020 14:32
JSON of programming languages and their keywords. Additionally it contains a summary and extensions. Originally adapted from https://github.com/leighmcculloch/keywords
{
"data": [
{
"name": "Lua",
"version": 5.3,
"summary": "Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming and data description.",
"extensions": [
"lua"
],
"keywords": [