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
// bad
let name = 'Emerson Broga';
let hello = 'Hello ' + name;
// good
let name = 'Emerson Broga'
let hello = `Hello ${name}`;

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 November 25, 2018 14:43
Coordinates from adrress with NodeJs and Google Maps

Coordinates from adrress with NodeJs and Google Maps

How to run

npm install --save request
node coordinates.js
@emersonbroga
emersonbroga / README.md
Last active November 25, 2018 14:14
Bitcoin value with Javascript

Bitcoin Price

How to run

npm install --save request
node bitcoin-price.js
@emersonbroga
emersonbroga / logger.js
Created September 25, 2018 02:36
Simple JS Logger that logs to a TXT file.
const fs = require('fs');
const path = require('path');
const DEFAULT_PATH = './output/log.txt';
const getAbsolutePath = (filePath) => {
const absolutePath = path.resolve(filePath);
const fileExists = fs.existsSync(absolutePath);
if (!fileExists) {
throw new Error(`File doesn't exist: ${absolutePath}`);
@emersonbroga
emersonbroga / README.md
Last active August 29, 2017 16:28
Wordpress + Mailgun

Wordpress + Mailgun

This is a simple snippet to create a wordpress contact form that sends email using mailgun api.

Installation

. Install the mailgun plugin for wordrpess https://wordpress.org/plugins/mailgun/

. Add the config constants to your wp-config.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
input {
height: 30px;
width: 50%;
@emersonbroga
emersonbroga / gist:619084f79f21a0e97bbc343fb6c52cdf
Created February 27, 2017 16:25
Check if element is visible (in view)
function Utils() {}
Utils.prototype = {
constructor: Utils,
isElementInView: function (element, fullyInView) {
var pageTop = $(window).scrollTop();
var pageBottom = pageTop + $(window).height();
var elementTop = $(element).offset().top;
var elementBottom = elementTop + $(element).height();
@emersonbroga
emersonbroga / smoothScroll.js
Created February 27, 2017 16:23
SmoothScroll without jquery.
var smoothScroll = {
timer: null,
stop: function () {
clearTimeout(this.timer);
},
scrollTo: function (id, callback) {
var settings = {
duration: 1000,
getAccountSports: function getAccountSports(accountId, callback) {
var allSports = ['lacrosse', 'soccer'];
var result = [];
Account.findOne(accountId).populate('events').then(function(account) {
// if admin return all sports.
if (account.type === 'admin') {
return callback(null, allSports);
}