Skip to content

Instantly share code, notes, and snippets.

View BrunoQuaresma's full-sized avatar

Bruno Quaresma BrunoQuaresma

View GitHub Profile
@BrunoQuaresma
BrunoQuaresma / bootstrap-send-form-modal.js
Last active December 31, 2015 05:58
Simple send form on the Bootstrap modal footer.
function sendForm(id){
var form = document.getElementById(id);
form.submit();
}
@BrunoQuaresma
BrunoQuaresma / jquery-bootstrap-nav-tabs.js
Last active December 31, 2015 05:59
You can use links generates by tabs like users/show/2#edit.
/**
* Bootstrap Nav Tabs
*
* Completely navigation with tabs and URL.
*/
function navTabs(){
$('*[href=' + window.location.hash + ']').tab('show');
@BrunoQuaresma
BrunoQuaresma / Time.js
Created December 16, 2014 13:19
Time for JS
function Time(str){
"use strict";
var values = str.split(':'),
seconds = parseInt(values[2]),
minutes = parseInt(values[1]),
hours = parseInt(values[0]);
@BrunoQuaresma
BrunoQuaresma / task2.mkd
Last active February 1, 2017 15:37
Task 2 - Front-End

Task 2: build a workout log

The system should cover all the previous use cases.

Additional information

Please, follow this mockup.

You should provide a workout log that works looks this mock, but remmember this is a mock and we are open to new ideas on how it should work.

@BrunoQuaresma
BrunoQuaresma / brazil_cities.json
Created December 21, 2017 23:57
Todas as cidades brasileiras
["Acrelândia - AC","Assis Brasil - AC","Brasiléia - AC","Bujari - AC","Capixaba - AC","Cruzeiro do Sul - AC","Epitaciolândia - AC","Feijó - AC","Jordão - AC","Mâncio Lima - AC","Manoel Urbano - AC","Marechal Thaumaturgo - AC","Plácido de Castro - AC","Porto Acre - AC","Porto Walter - AC","Rio Branco - AC","Rodrigues Alves - AC","Santa Rosa do Purus - AC","Sena Madureira - AC","Senador Guiomard - AC","Tarauacá - AC","Xapuri - AC","Água Branca - AL","Anadia - AL","Arapiraca - AL","Atalaia - AL","Barra de Santo Antônio - AL","Barra de São Miguel - AL","Batalha - AL","Belém - AL","Belo Monte - AL","Boca da Mata - AL","Branquinha - AL","Cacimbinhas - AL","Cajueiro - AL","Campestre - AL","Campo Alegre - AL","Campo Grande - AL","Canapi - AL","Capela - AL","Carneiros - AL","Chã Preta - AL","Coité do Nóia - AL","Colônia Leopoldina - AL","Coqueiro Seco - AL","Coruripe - AL","Craíbas - AL","Delmiro Gouveia - AL","Dois Riachos - AL","Estrela de Alagoas - AL","Feira Grande - AL","Feliz Deserto - AL","Flexeiras - AL","Gir
@BrunoQuaresma
BrunoQuaresma / types_spec.mkd
Last active July 24, 2019 16:11
Faunadb-JS types spec

Type improvements for FaunaDB JS driver

This is a draft where we can think of how to improve the FaunaDB JS driver type system, so if you have any suggestions on how we can improve this, feel free to comment and submit your changes.

1. Acessible values in the root path

Current

import faunadb from "faunadb";

type Note = {

Keybase proof

I hereby claim:

  • I am brunoquaresma on github.
  • I am faunadb (https://keybase.io/faunadb) on keybase.
  • I have a public key ASDHoShbI8liosOWuuCGFWQ8_f4dfamUjTQt-aL5YZ8sMwo

To claim this, I am signing this object:

@BrunoQuaresma
BrunoQuaresma / zeit-now-test-utils.ts
Created April 19, 2020 05:48
Zeit Now Test Utils for Cloud Functions/Lambda
import logsFunction from '../logs';
import { IncomingMessage, ServerResponse } from 'http';
import { Socket } from 'net';
import { NowRequestQuery, NowRequestCookies, NowRequestBody } from '@now/node';
class NowRequestMock extends IncomingMessage {
public query: NowRequestQuery = {};
public cookies: NowRequestCookies = {};
public body: NowRequestBody;
@BrunoQuaresma
BrunoQuaresma / nextapimock.ts
Last active July 18, 2023 17:12
NextApiResponse and NextApiRequest mocks
import { IncomingMessage } from 'http'
import {
NextApiRequestCookies,
NextApiRequestQuery,
} from 'next/dist/next-server/server/api-utils'
import { Socket } from 'net'
import { ServerResponse } from 'http'
import { NextApiRequest, NextApiResponse } from 'next'
import { Env } from 'next/dist/lib/load-env-config'
@BrunoQuaresma
BrunoQuaresma / initializeForm.js
Created August 25, 2020 14:48
Form Initialize for React
function initializeForm(form) {
return Object.keys(form).reduce((newForm, key) => {
let value
if(form[key] === null || form[key] === undefined) {
value = ''
} else if(typeof form[key] === 'string') {
value = form[key]
} else if(typeof form[key] === 'object') {
value = initializeForm(form[key])