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 / app-navigation-tree.json
Last active June 23, 2023 02:25
App Navigation Tree JSON Schema
{
"$id": "https://gist.githubusercontent.com/tzkmx/0b31897ea96fb3e36f8debdc050121b9/raw/bdda2e9b636d1130e4000d6c829113d62c4bcd4c/app-navigation-tree.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "App Contents Navigation Manifest",
"description": "A blueprint for application navigation",
"properties": {
"home": {
"description": "First screen interactive for users (after authentication flow if required)",
"type": "object",
"properties": {
@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 / pivot_example.php
Created October 16, 2019 11:38 — forked from fractefactos/pivot_example.php
Laravel Custom Pivot Model definition example
<?php
//https://github.com/laravel/framework/issues/2093#issuecomment-39154456
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Pivot;
class User extends Eloquent {
public function groups() {
return $this->belongsToMany('Group');
@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 / .babelrc
Last active January 20, 2023 01:50
NestJS as sub app of express.js vanilla
{
"presets": [
["env", { "targets": {"node": "current" }, "debug": true }],
"stage-0"
],
"plugins": [
"transform-decorators-legacy",
"transform-runtime"
]