Skip to content

Instantly share code, notes, and snippets.

View gleydson's full-sized avatar
🏠
Working at home

Gleydson Rodrigues gleydson

🏠
Working at home
View GitHub Profile
async function retry<T>(fn: () => Promise<T>, retries: number = 5) {
try {
return await retry()
} catch (err) {
if (retries > 0) {
console.log("Retrying...")
return await retry(fn, retries - 1)
}
throw err
}
export type Class<T = unknown> = new (...args: unknown[]) => T
class DependencyManager {
// eslint-disable-next-line no-use-before-define
private static instance: DependencyManager
public deps: Record<string, Class> = {}
private constructor() {}
public static getInstance(): DependencyManager {
@gleydson
gleydson / generate-random-characters.js
Created March 30, 2020 16:49
Function to create random characters
export default function random(length) {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i += 1) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
@gleydson
gleydson / settings-vscode.json
Last active May 22, 2020 07:38
My standard VSCode setting
{
// Define o tema do VSCode
"workbench.colorTheme": "Atom One Dark",
// Aumenta a fonte do terminal
"terminal.integrated.fontSize": 14,
// Define o tema dos ícones na sidebar
"workbench.iconTheme": "material-icon-theme",
"workbench.startupEditor": "newUntitledFile",
@gleydson
gleydson / rn-tranform-percent-to-dp.js
Last active March 1, 2024 06:15
Functions that transform percentages into pixel density to react native
import { Dimensions } from 'react-native';
const widthPercentageToDP = widthPercent => {
const screenWidth = Dimensions.get('window').width;
const elemWidth = parseFloat(widthPercent);
return PixelRatio.roundToNearestPixel((screenWidth * elemWidth) / 100);
};
const heightPercentageToDP = heightPercent => {
const screenHeight = Dimensions.get('window').height;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerBehaviourScript : MonoBehaviour {
private float x;
private float y;
private float z;
public bool canJump = true;
#include <iostream>
using namespace std;
bool is_palindrom(int number);
int main() {
int number;
le (number > 0) {
#!/bin/bash
DIR=~/
FILE_PROFILE=.profile
FILE_BASH=.zshrc
DOWNLOADS=Downloads
cd ~/Downloads/
wget -c --tries=3 -O ${$DIR$DOWNLOADS}"/jdk.tar.gz http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1522841007_f9dd76d4f638494498691469a78af142
tar -xvf ${$DIR$DOWNLOADS}/jdk.tar.gz