Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🏴

Elvis Morales elvismdev

🏴
View GitHub Profile
@kostysh
kostysh / promt.unit-tests.md
Last active March 22, 2024 02:46
ChatGPT prompt for unit tests writing

I want you to act as a Senior full stack Typescript developer. Once I provide the TypeScript code, your task is to develop a comprehensive suite of unit tests for a provided TypeScript codebase. Follow these guidelines for an effective testing process:

  1. Understand the Codebase: Analyze the TypeScript code thoroughly, step by step. Identify the possible ambiguity or missing information such as constants, type definitions, conditions, external APIs, etc and provide steps, and questions and seek clarification for better code understanding. Only proceed to the next step once you have analyzed the codebase fully.

  2. Testing framework: For this task, use an abstract testing framework instead of known frameworks such as chai, jest, etc., remembering that the principles of unit testing apply regardless of the specific tools.

  3. Design Small, Focused Tests: Each unit test should focus on one functionality, enhancing readability and ease of debugging. Ensure each test is isolated and does not depe

import { gql, useQuery } from '@apollo/client';
import { useWeb3React } from '@web3-react/core';
import { useEffect, useState } from 'react';
import { useAppContext } from '../components/AppContextWrapper';
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
export const useLastMints = () => {
const [eventHandlerBound, setEventHandlerBound] = useState(false);
const { library } = useWeb3React();
@pablodz
pablodz / install_docker_in_ubuntu_21-10.sh
Last active June 17, 2023 20:58
Install Docker in Ubuntu 21.10, Install Dockercompose on Ubuntu 21.10
# [🟨OPTIONAL] Uninstall old docker versions
sudo apt-get remove docker docker-engine docker.io containerd runc
# Refresh latest version
sudo apt-get update
# Install pre-req
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
@dabit3
dabit3 / basicmarket.sol
Last active January 9, 2024 08:54
Basic NFT marketplace
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract NFT is ERC721URIStorage {
using Counters for Counters.Counter;
@keepitsimple
keepitsimple / bitbucket-pipelines.yml
Last active June 19, 2023 09:02
Bitbucket pipeline to sync / copy code commits to GitHub. How to sync Bitbucket repo to GitHub
image: alpine/git:1.0.26
definitions:
services:
docker:
memory: 1024
steps:
- step: &Push-to-GitHub
name: Push code changes to GitHub
@dhruvilp
dhruvilp / README.md
Last active April 18, 2024 07:26
Copy commits from one git repo to another
@agungjk
agungjk / [slug].js
Last active April 7, 2024 15:22
Crawler example on Vercel using Puppeteer and NextJS API routes
const puppeteer = require('puppeteer-core');
const cheerio = require('cheerio');
const chrome = require('chrome-aws-lambda');
export default async (req, res) => {
const slug = req?.query?.slug;
if (!slug) {
res.statusCode = 200
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify({ id: null }))
@Niq1982
Niq1982 / example.php
Last active February 10, 2023 18:00
Add focal point to WordPress featured image with WP Smart Crop
<?php
// This requires the WP Smart Crop plugin
// Get the thumbnail ID
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
// Check if the crop is enabled on the thumbnail and get the dimensions
$crop_dimensions = get_post_meta( $thumbnail_id, '_wpsmartcrop_enabled', true ) ? get_post_meta( $thumbnail_id, '_wpsmartcrop_image_focus', true ) : [];
// Add percentage to dimensions and reverse array (top comes first in array)
@mauro-baptista
mauro-baptista / NumberFormat.php
Last active May 8, 2023 00:22
Easily readable numbers
<?php
/**
* Numbers more readable for humans
*
* It intends to change numbers as 1000 as 1K or 1200000 as 1.2M
*
* This code is heavly base in this one: https://gist.github.com/RadGH/84edff0cc81e6326029c
*
* How to use \NumberFormat::readable(1000);
*/