Skip to content

Instantly share code, notes, and snippets.

View alexcastrodev's full-sized avatar
🚀
Let's go !!!!

Alexandro Castro alexcastrodev

🚀
Let's go !!!!
  • Flecto
  • Portugal
View GitHub Profile
import { Browser, Page } from '@playwright/test'
import path from 'node:path';
interface IBaseTestController {
browser?: Browser
page: Page
baseURL: string
path?: string
har: {
title: string
version: '3.8'
x-postgres-defaults: &postgres-defaults
image: postgres:latest
environment:
POSTGRES_USER: postgres_user
POSTGRES_PASSWORD: your_password
POSTGRES_DB: your_database
volumes:
- pgdata:/var/lib/postgresql/data
private async requestWithRetry(
query: string,
username: string,
retryDelay: number = 1000, // Set the delay between retries (in milliseconds)
) {
const tokens = [
Deno.env.get("GITHUB_TOKEN1"),
Deno.env.get("GITHUB_TOKEN2"),
];
const maxRetries = tokens.length
@alexcastrodev
alexcastrodev / db.json
Last active August 7, 2023 04:42
public_links
[
{
"details": {
"summary": "An Elo-type rating model for players and teams of variable strength",
"p": "The Elo rating system, which was originally proposed by Arpad Elo for chess, has become one of the most important rating systems in sports, economics and gaming nowadays. Its original formulation is based on two-player zero-sum games, but it has been adapted for team sports and other settings. In 2015, Junca and Jabin proposed a kinetic version of the Elo model..."
},
"link": "https://arxiv.org/abs/2109.15046"
}
]
const transform = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' })
async function readUserInput(): Promise<number> {
const buffer = new Uint8Array(1024);
const bytesRead = await Deno.stdin.read(buffer);
const input = new TextDecoder().decode(buffer.subarray(0, Number(bytesRead)));
if (Number.isNaN(Number(input))) {
throw new Error('No bytes read');
}
import express from "express"
const app = express ();
app.get("/events",(req, res) => {
res. setHeader ("Content-Type", "text/event-stream");
res.setHeader ("Cache-Control", "no-cache");
res.setHeader ("Connection","keep-alive");
// Clean headers
res.flushHeaders();
version: '3.3'
services:
postgres:
image: postgres
restart: always
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
ports:
function closureRequest() {
let success = false, error = false, data = null;
const dispatch = async (fn) => {
try {
data = await fn();
success = true;
error = false;
} catch {
success = false;
@alexcastrodev
alexcastrodev / bash_log.txt
Created April 17, 2023 20:56
streams_question_linux_foundation
12_streams git:(main) ✗ node 8_kb_data.js
read chunk <Buffer 4e 61 6d 65 2c 41 67 65 2c 4c 6f 63 61 74 69 6f 6e 0a 42 75 64 64 79 2c 35 2c 4e 65 77 20 59 6f 72 6b 0a 4c 75 63 6b 79 2c 32 2c 4c 6f 73 20 41 6e 67 ... 8287 more bytes>
stop reading
12_streams git:(main) ✗ node 16_kb_data.js
read chunk <Buffer 4e 61 6d 65 2c 41 67 65 2c 4c 6f 63 61 74 69 6f 6e 0a 42 75 64 64 79 2c 35 2c 4e 65 77 20 59 6f 72 6b 0a 4c 75 63 6b 79 2c 32 2c 4c 6f 73 20 41 6e 67 ... 17332 more bytes> 17382
stop reading
➜ 12_streams git:(main) ✗ node 128_kb_data.js
read chunk <Buffer 4e 61 6d 65 2c 41 67 65 2c 4c 6f 63 61 74 69 6f 6e 0a 42 75 64 64 79 2c 35 2c 4e 65 77 20 59 6f 72 6b 0a 4c 75 63 6b 79 2c 32 2c 4c 6f 73 20 41 6e 67 ... 65486 more bytes> 65536
@alexcastrodev
alexcastrodev / ModuleDecorator.tsx
Last active March 10, 2023 15:13
React Decorator as High order component without class
import React from 'react'
import { IAsyncAppDispatch } from 'my-package'
export interface IHandlers {
onSuccess: IAsyncAppDispatch['onSuccess']
onError: IAsyncAppDispatch['onError']
}
export interface DefaultFormProps {
handlers?: IHandlers