Skip to content

Instantly share code, notes, and snippets.

View HallexCosta's full-sized avatar
:octocat:
Learning on-demand!

Hállex da Silva Costa HallexCosta

:octocat:
Learning on-demand!
View GitHub Profile
@HallexCosta
HallexCosta / App.js
Last active October 7, 2023 16:26
Awesome Timer
import React, { useState, useRef } from 'react';
import {
SafeAreaView,
StyleSheet,
Text,
View,
TouchableHighlight,
} from 'react-native';
@HallexCosta
HallexCosta / atalhos-ij.md
Created September 6, 2023 20:57 — forked from boaglio/atalhos-ij.md
Atalhos do IntelliJ - para quem veio do Eclipse

Atalhos do IntelliJ

Principais

Caiu no IntelliJ agora?

Aprenda só esses:

Tipo de Atalho IntelliJ IDEA
@HallexCosta
HallexCosta / CheckoutService.php
Last active May 8, 2023 23:43
CheckoutService.php
<?php
namespace app\modules\api\services\pagarme\orders;
class CheckoutService
{
private string $SECRET_API_KEY = '';
private array $headers;
public function __construct()
{
$username = $this->SECRET_API_KEY;
@HallexCosta
HallexCosta / gist:2490587b61a130c90f611ea942cf990e
Created April 25, 2023 17:54
Como ativar php7.4 no ec2 da amazon
https://linux.how2shout.com/how-to-install-php-7-4-on-amazon-linux-2/
@HallexCosta
HallexCosta / calculateHourlyRate.js
Created March 28, 2023 00:17
Calculate Hourly Rate
function isTimeFormatValid(timeString) {
const timeRegex = /^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$/;
const dateTimeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
return timeRegex.test(timeString) || dateTimeRegex.test(timeString);
}
function calculateHourlyRate({ startTime, endTime, pricePerHour }) {
// Check if start time and end time are in a valid format
if (!isTimeFormatValid(startTime) || !isTimeFormatValid(endTime)) {
@HallexCosta
HallexCosta / bounded-functions-with-bind.js
Last active October 29, 2022 03:42
Example how to use bounded functions with bind or call
const father = {
name: 'Zeus',
}
const mother = {
name: 'Demeter',
}
const persephone = {
say() {
console.log(`"Persephone" is daughter from "${this.name}"`)
}
@HallexCosta
HallexCosta / WSL freezes and won't start.md
Created October 17, 2022 02:31
WSL freezes and won't start
  1. First get the PID of svchost.exe running LxssManager, open the cmd as administrator and run: tasklist /svc /fi "imagename eq svchost.exe" | findstr LxssManager
  2. Run task manager as administrator, in the details tab, search for the svchost.exe containing the PID
  3. Right click it and select 'end process tree'
  4. Now you should be able to restart wsl normally with wsl --shutdown and wsl.

References:
Can't restart WSL2, LxssManager hangs in stopping state, how to restart?
WSL don't start, don't open and don't answer

@HallexCosta
HallexCosta / metro.config.js
Created July 25, 2022 22:45
Example of configure metro.config.js in Expo
const { createMetroConfiguration } = require('expo-yarn-workspaces')
const { getDefaultConfig } = require('metro-config')
const configuration = createMetroConfiguration(__dirname)
module.exports = (async () => {
const {
resolver: { sourceExts }
} = await getDefaultConfig()
return {
@HallexCosta
HallexCosta / DebuggingNodeJSHerokuApps.md
Created November 14, 2021 03:10 — forked from Choonster/DebuggingNodeJSHerokuApps.md
How to debug Node.js web applications running on Heroku using ngrok

Debugging Node.js web applications running on Heroku using ngrok

Introduction

Heroku only allows each dyno to send and receive external network traffic on a single port, which means you can't simply run node --debug server.js and attach your debugger to your-app.herokuapp.com:5858.

To work around this, you can use ngrok and Heroku ngrok Buildpack to tunnel to the debugger's port and access it externally.

@HallexCosta
HallexCosta / index.js
Created November 12, 2021 21:39
Factory create SQL statments
// i will use playcode.io
// depedencies -> moment and faker
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}
class Depto {