Skip to content

Instantly share code, notes, and snippets.

View tzkmx's full-sized avatar
🎉
estrenando repositorios privados

Jesus Franco tzkmx

🎉
estrenando repositorios privados
View GitHub Profile
@tzkmx
tzkmx / formDataToObject.ts
Created April 30, 2024 23:43
Extract from Next.js adapter for tRPC
/* eslint-disable @typescript-eslint/no-non-null-assertion */
function set(
obj: Record<string, any>,
path: string[] | string,
value: unknown,
): void {
if (typeof path === 'string') {
path = path.split(/[\.\[\]]/).filter(Boolean);
}
@tzkmx
tzkmx / handlerClass.ts
Last active April 23, 2024 23:39
Decorating App Router Route Handlers (next.js)
class HawkExperiment
{
async getEndpoint(request: Request, params: any)
{
// headers = array of key value pairs extracted from headers
let headers: {[p: string]: string} = {}
request.headers.forEach((val, key, allHeaders) => {
headers[key] = val
})
return Response.json({
@tzkmx
tzkmx / DisposableStack.ts
Created September 13, 2023 05:22
Polyfill to use DisposableStack in Node16
class DisposableStack {
constructor() {
if (!(this instanceof DisposableStack)) {
throw new TypeError('DisposableStack must be constructed with new');
}
this.#state = 'pending';
this.#disposeCapability = newDisposeCapability();
}
get disposed() {
@tzkmx
tzkmx / in.md
Created September 7, 2023 23:31
Example of logger using DI with awilix

Notable example of Dependency Injection and use of FileTransports discussed in awilix issues

jeffijoe/awilix#128

@tzkmx
tzkmx / auth.js
Created August 23, 2023 21:17 — forked from mrpinghe/auth.js
Veracode custom HMAC request signing algorithm (used for API authorization)
var crypto = require('crypto');
const id = process.env.API_ID; // your API ID, reading from environment variable
const key = process.env.KEY; // your API key, reading from environment variable
const preFix = "VERACODE-HMAC-SHA-256";
const verStr = "vcode_request_version_1";
var resthost = "api.veracode.com"; // rest host
var xmlhost = "analysiscenter.veracode.com"; // xml host
@tzkmx
tzkmx / instructions.md
Created April 14, 2023 02:25
Script to split by chapters and convert audible to mp3.

Easy use

You use this script passing:

  • as first argument the input file
  • second argument is the content code

You can get your activation_bytes or content code from this site:

https://audible-converter.ml/

@tzkmx
tzkmx / PageObject.py
Last active February 10, 2023 16:53
ejemplos de pageObject con ChatGPT
class PageObject:
def __init__(self, driver):
self.driver = driver
def takeScreenshot(self):
# Código para tomar una captura de pantalla
pass
def checkTitle(self, expectedTitle):
self.takeScreenshot()
@tzkmx
tzkmx / cursor_update.sql
Created August 30, 2022 17:17
Cursor Mysql update row by row
DELIMITER $$
CREATE PROCEDURE fixVersionAggregate ()
BEGIN
DECLARE finished INTEGER DEFAULT 0;
DECLARE evId BIGINT DEFAULT 0;
DECLARE evVersion INT DEFAULT 0;
-- declare cursor for
DEClARE curEvent
CURSOR FOR
@tzkmx
tzkmx / README.md
Created June 30, 2022 09:27 — forked from vanushwashere/README.md
Systemd unit file for supervisord service

Systemd unit file for supervisord service

  • place this config in /etc/systemd/system/supervisord.service
  • kill all supervisord processes
  • sudo systemctl daemon-reload
  • sudo systemctl enable supervisord
  • start with sudo systemctl start supervisord if already not started
@tzkmx
tzkmx / sentry-serverless-firebase.ts
Created February 18, 2022 04:49 — forked from zanona/sentry-serverless-firebase.ts
Missing Sentry's firebase serverless wrappers
/**
* Temporary wrapper for firebase functions until @sentry/serverless support is implemented
* It currently supports wrapping https, pubsub and firestore handlers.
* usage: https.onRequest(wrap((req, res) => {...}))
*/
import type {Event} from '@sentry/types';
import type {https} from 'firebase-functions';
import type {onRequest, onCall} from 'firebase-functions/lib/providers/https';
import type {ScheduleBuilder} from 'firebase-functions/lib/providers/pubsub';
import type {DocumentBuilder} from 'firebase-functions/lib/providers/firestore';