Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Quintana joseluisq

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

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 Aug 18, 2020
Custom Typescript slugify function
View slugify.ts
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 Aug 10, 2020
How to get just the name of first Docker service running
View README.md

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 Aug 10, 2020
How to run InfluxData Telegraf using Docker compose in order to collect host and containers metrics
View docker-compose.yml
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 Apr 8, 2020
Rust web frameworks benchmark focus on static-file serving.
View BENCHMARK
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 Feb 28, 2020
Checking for a specific Emacs version on .emacs file
View .emacs
;; 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 Feb 25, 2020 — forked from mihow/load_dotenv.sh
Load environment variables from a .env file from a Bash shell script
View dotenv.sh
#!/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 Feb 17, 2020
Testing download file speed using cUrl and get its stats into a log file. Unix-like systems only.
View download_testing_stats.sh
#!/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\
View xpath_searching.md

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 Sep 14, 2020
JSON of programming languages and their keywords. Additionally it contains a summary and extensions. Originally adapted from https://github.com/leighmcculloch/keywords
View programming_languages_keywords.json
{
"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": [
You can’t perform that action at this time.