Skip to content

Instantly share code, notes, and snippets.

View juanAFernandez's full-sized avatar
🎯
Focusing

Juan Antonio Fernández juanAFernandez

🎯
Focusing
View GitHub Profile
@juanAFernandez
juanAFernandez / randomFromEnum.ts
Last active September 13, 2022 11:14
How to get random keys from any enum
function randomFromEnum(TEnum: any): typeof TEnum {
return Object.values(TEnum)[Math.floor(Math.random() * (Object.keys(TEnum).length - 1 + 1))];
}
@juanAFernandez
juanAFernandez / gist:0c82e870f11421586b7b7fe1ada79761
Created April 7, 2021 15:22
Titlelize, a simple angular pipe to capitalize first letter of first word of a phrase.
import { Pipe, PipeTransform } from '@angular/core';
/**
* Used to capitalize the first word of a phrase. The rest of words keeps equal.
* Example: {{ 'hello world' | titlelize }} will render 'Hello world'
* Example: {{ 'HELLO world' | titlelize }} also will render 'Hello world'
*/
@Pipe({
name: 'titlelize'
@juanAFernandez
juanAFernandez / json_reader.py
Created November 28, 2018 17:51
A json reader plugin to do Pelican able to read json files to render in html instead of Markdown or RST files.
from pelican import signals
from pelican.readers import BaseReader
import json
class JsonReader(BaseReader):
enabled = True
def __init__(self, settings):
super(JsonReader, self).__init__(settings)
@juanAFernandez
juanAFernandez / keybindings.json
Last active January 27, 2018 18:37
Simple keybindings for VSCode to work easily with terminal when you need constantly change between code and one or more intergrated terminals (using CRTL).
// Add to your keybindings.json
[
// To change between code and terminal.
{
"key": "ctrl+`",
"command": "workbench.action.terminal.toggleTerminal"
},
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
@juanAFernandez
juanAFernandez / .py
Created March 29, 2017 20:40
Fabric example
# -*- coding: utf-8 -*-
from fabric.api import local, lcd, run # to run local commands.
from fabric.colors import red, blue
import time
# TODO: REFACTOR and clean methods!!!!!
#####################################################################
# FABRIC Fabfile. <http://www.fabfile.org/>