Skip to content

Instantly share code, notes, and snippets.

View JonathanRangelB's full-sized avatar
:octocat:
Never stop learning

Jonathan Rangel Bernal JonathanRangelB

:octocat:
Never stop learning
View GitHub Profile
@JonathanRangelB
JonathanRangelB / quicktype-typescript-keymap-lazyvim.lua
Created April 21, 2025 02:19
Este keymap es muy util para usar el lazyVim, lo que tengas en el clipbooard (el registro +) se manda como parametro al CLI de quicktype que debio de ser previamente instalado de manera global con npm, pnpm o lo que sea que uses
vim.keymap.set("n", "<leader>p", function()
local clipboard = vim.fn.getreg("+")
vim.ui.input({ prompt = "Enter Interface Name: " }, function(class_name)
if class_name then
local command = "echo "
.. vim.fn.shellescape(clipboard)
.. " | quicktype --lang typescript --just-types --top-level "
.. vim.fn.shellescape(class_name)
local result = vim.fn.system(command)
local lines = vim.split(result, "\n")
@JonathanRangelB
JonathanRangelB / .bash_aliases
Created April 19, 2025 23:56
My most used aliases in linux/mac 2025
# linux mint/ubuntu generic ones
alias i="sudo apt install"
alias up="sudo apt update && sudo apt upgrade -y"
# requires eza to be installed
# alternative to ls written in Rust
alias l="eza -lah --icons"
# requires neovim to be installed
# text editor
@JonathanRangelB
JonathanRangelB / angular17-purgecss.md
Last active October 21, 2024 14:13
angular 17 purgecss bundle config
module.exports = {
  content: ['dist/**/index.html', 'dist/**/*.js'],
  css: ['dist/**/*.css'],
  output: 'dist/my-app-test/browser/', // Ruta para un proyecto de angular 18
  safelist: {
    standard: [
      // Agrega aquí otros patrones de PrimeFlex que necesites
      /(^|\s)sm:(\s|$)/,
 /(^|\s)md:(\s|$)/,
@JonathanRangelB
JonathanRangelB / Angular .env generator
Last active April 3, 2024 20:46
sets up the .env file for Angular projects
const { mkdirSync, writeFileSync } = require("fs");
require("dotenv").config();
const targetPath = "./src/environments/environment.ts";
const envFileContent = `
export const environment = {
YOUR_KEY: "${process.env.YOUR_KEY}",
}
`;
@JonathanRangelB
JonathanRangelB / node_crypto_random
Created March 28, 2024 20:08
random number generator in node
require('crypto').randomBytes(64).toString('hex')
{
"_type": "export",
"__export_format": 4,
"__export_date": "2023-07-07T23:50:45.605Z",
"__export_source": "insomnia.desktop.app:v2023.3.0",
"resources": [
{
"_id": "req_1a4adae014ec41fc87e69f7a4f0a210b",
"parentId": "fld_99ef76ba8e484e02a1f5281af7fdc2d6",
"modified": 1684464842441,
openapi: 3.0.3
info:
title: mi primera API
description: this is a description
version: 1.0.0
contact:
name: "Jonathan Rangel Bernal"
email: "jonathan.rangelb@gmail.com"
url: www.algo.com
servers:
@JonathanRangelB
JonathanRangelB / jsSwitchAlternative
Created September 9, 2021 00:43
Alternative to switch on JavaSript, this approach scales better
// Scales better because you just need to add 1 single line to the object with all the availabe options.
const option = "complex-option"
// This object literal holds all options (keys) that we comonly use on the cases of a switch
const validOptions = {
option1: "the value for this first option",
option2: "the value for this second option",
"complex-option": "the value for this complex one"
}
@JonathanRangelB
JonathanRangelB / detectMobileBrowser.js
Created June 28, 2021 23:37
Based on the detectmobilebrowser implementation to detect fi the current code is running on mobile browser.
// Javascript Regex obtained from http://detectmobilebrowser.com/mobile
export default result = (function (navigatorString) {
let isMobileBrowser = false;
if (
/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(
navigatorString
) ||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip