Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View emersonbroga's full-sized avatar
:octocat:
Let's code!

Emerson Brôga emersonbroga

:octocat:
Let's code!
View GitHub Profile
@emersonbroga
emersonbroga / randomWord.swift
Last active April 22, 2024 15:59
Swift Random Word Generator
//Inspired by: http://planetozh.com/blog/2012/10/generate-random-pronouceable-words/
func randomWord(wordLength: Int = 6) -> String {
let kCons = 1
let kVows = 2
var cons: [String] = [
// single consonants. Beware of Q, it"s often awkward in words
"b", "c", "d", "f", "g", "h", "j", "k", "l", "m",
"n", "p", "r", "s", "t", "v", "w", "x", "z",
@emersonbroga
emersonbroga / Awesome2DCamera.cs
Last active February 27, 2024 01:53
Awesome 2D Camera (Unity 2d C# Script)
using UnityEngine;
using System.Collections;
public class Awesome2DCamera : MonoBehaviour {
// the target the camera should follow (usually the player)
public Transform target;
// the camera distance (z position)
public float distance = -10f;
@emersonbroga
emersonbroga / components-and-events.md
Last active September 6, 2023 22:42
React: Componentes e eventos

React: Componentes e Eventos.

Uma situação muito comum em projetos React é a gente criar uma lib de componentes pra reutilizar. Em sua grande maioria, fazemos apenas para deixar certos estilos e coisas que gostamos de padronizar.

Vou dar o exemplo usando um input text, mas imagine que o que eu to falando se aplica a tudo select, checkbox, radio, textarea, input file, etc.

Vamos la:

@emersonbroga
emersonbroga / index.js
Last active August 4, 2023 16:36
[QuickNode] Update TabOrder on Chain JSON files.
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const [, , folderPath] = process.argv;
if (!folderPath) {
console.error(
"Please provide the chains json folder path [metadata/chains/]"
);
@emersonbroga
emersonbroga / useLocalStorage.ts
Created June 5, 2023 16:29
Use localStorage Hook for TypeScript
import { useState, useEffect } from 'react'
const getStorageValue = <T>(key: string, defaultValue?: T): T | undefined => {
const fallback = defaultValue || undefined
if (typeof window === 'undefined') return fallback
const value = localStorage.getItem(key)
if (value === null) return fallback
try {
@emersonbroga
emersonbroga / JsonHelper.js
Created September 30, 2021 02:48
Json Helper
const fs = require('fs');
const JSONWrite = (filePath, data, encoding = 'utf-8') => {
const promiseCallback = (resolve, reject) => {
fs.writeFile(filePath, JSON.stringify(data, null, 2), encoding, (err) => {
if (err) {
reject(err);
return;
}
resolve(true);

Coordinates from adrress with Javascript and Google Maps

How to run

open coordinates-axios.html or coordinates-jquery.html in your browser.

Blog Post

@emersonbroga
emersonbroga / Readme.md
Last active October 25, 2022 13:28
Convert images from CR2 to JPG.

Conversor de imagens de CR2 para JPG

instruções

salve o código como index.js crie uma pasta chamada CR2 adicione os seus arquivos CR2 la crie uma pasta chamada JPG e deixe ela vazia abra o seu terminal e rode npm install --save cr2-raw depois rode node index.js

@emersonbroga
emersonbroga / contato.php
Created August 31, 2012 19:25
Emerson Carvalho.com >> Formulário de contato em php + ajax (snippet 4)
<?php
$toName = 'Emerson Carvalho';
$toEmail = 'abc@abc.com.br';
$name = '';
$email = '';
$phone = '';
$subject = '';
@emersonbroga
emersonbroga / index.html
Created September 20, 2020 23:48
JSBin Test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSBin Test</title>
</head>
<body>
<div class="container">