Skip to content

Instantly share code, notes, and snippets.

View cabaalexander's full-sized avatar
👋
😬 👋

Alexander Caba (Nica) cabaalexander

👋
😬 👋
  • Santiago, DR
View GitHub Profile
import { Hono } from 'hono'
import { jsxRenderer } from 'hono/jsx-renderer'
import { Suspense } from 'hono/jsx/streaming'
const app = new Hono()
const Component = async () => {
const res = await fetch('https://ramen-api.dev/shops/yoshimuraya')
await new Promise((r) => setTimeout(r, 8000)) // <-- delay here
const data = await res.json<{ shop: { name: string } }>()
@cabaalexander
cabaalexander / debounce.js
Last active August 28, 2022 22:45
My take on the `debounce` function
/**
* Debounce
* This will create a function that can be called multiple times and only be
* executed once, within a threshold you speficy
* @param {function} callback Callback function to be executed
* @param {number} threshold Time to wait before executing the callback
* @return {function} The function that can be triggered multiple time
*/
function debounce(callback, threshold = 1000) {
// input validation
@cabaalexander
cabaalexander / awaitFor.js
Last active August 22, 2022 03:27
This function promises you to find an element on the page and return it back.
/**
* awaitFor
*
* given a selector this function promises to return a valid element when it finds it.
* you can manage the timeout and the step interval if needed.
*
* @param selector - the selector for the element you want
* @param options - configuration for the promise
* @param options.intervalStep - time between checking in seconds
* @param options.timeout - time in seconds to stop checking the element
@cabaalexander
cabaalexander / hookInto.js
Last active May 2, 2022 13:47
Util function to proxy a function arguments and do something with them (not harming the default function implementation)
/**
* hookInto
*
* This will hook into a function of an object so we can check the arguments
* used when it is called any time and do some calculations on those arguments.
*
* @param {object} targetObject Object where the function you want to target is
* @param {string} functionName The name of the function you want to target
* @param {function} handler The hook function that will handle the arguments
* @returns {undefined}
@cabaalexander
cabaalexander / trello-card-number.js
Last active October 6, 2020 14:30
This is a javascript code for showing the ticket number on the trello board ;)
// this is taken from here:
// https://dev.to/rfornal/creating-a-document-fragment-5g7l
let fragmentFromString = (stringHTML) => {
let temp = document.createElement('template')
temp.innerHTML = stringHTML
return temp.content
}
let createNumberLabel = (content) => fragmentFromString(`
<span

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@cabaalexander
cabaalexander / curl.md
Created July 9, 2018 21:12 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@cabaalexander
cabaalexander / tmux.md
Created December 30, 2017 08:12 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a