Skip to content

Instantly share code, notes, and snippets.

View vmattos's full-sized avatar

Vitor Mattos vmattos

  • OLX
  • Rio de Janeiro, Brazil
View GitHub Profile

Git

Vamos falar de um problema comum agora. Você provavelmente já viu isso acontecendo em algum projeto:

script.js
script_final.js
script_FINAL_2.js
script_FINAL_AGORA_VAI.js

Funções

Pense em funções como pequenas máquinas. Elas recebem uma entrada, executam alguma lógica, e produzem uma saída

    Entrada
     +   +
 | |
@vmattos
vmattos / functional.c
Last active April 5, 2017 02:18
Functional C
#include <stdio.h>
/***************************
* Estratégias de cálculo *
***************************
*
* Essas funções devem retornar void e receber dois int como parametros
* Por quê? Veja o próximo comentário...
*
*/
#!/bin/bash
# Deploys project to WebDAV-compliant server
# Uses a package.json for semantic versioning
# Requires: curl, jq
# Required env vars:
# WEBDAV_REMOTE: remote url of WebDAV-compliant server. Protocol and path included
# WEBDAV_PROJECT: project name
# WEBDAV_USER: basic auth/digest user name
++++++++++
[
>+++++++++++
>++++++++++
>++++++++++++
>+++++++++++
>+++++++++++
>+++++
>+++++++++++
>+++++++++++
@vmattos
vmattos / vmattos.vim
Last active August 29, 2015 14:08
Favorite vim theme
"
" Author: Vitor Mattos <mattos.trk@gmail.com>
"
" My favorite VIM theme
" Based on Lucario: https://github.com/raphamorim/lucario
"
"
set t_Co=256
@vmattos
vmattos / theme.sh
Last active August 29, 2015 14:07
My favorite theme
#!/bin/sh
#
# Author: Vitor Mattos <mattos.trk@gmail.com>
#
# Shell script that configures gnome-terminal to use my custom theme
# based on X::DotShare. Written for Ubuntu 11.10, tested on Ubuntu 14.04
#
# Works for gnome-terminal < 3.8
#BLACK
@vmattos
vmattos / cache.js
Last active August 29, 2015 14:06
Simple caching algorithm for javascript functions that can be optionally added as middleware
function sleep(seconds)
{
var e = new Date().getTime() + (seconds * 1000);
while (new Date().getTime() <= e) {}
}
var Obj = function() {
this.fn = function(arg) {
console.log('Long operation zzzz...');
@vmattos
vmattos / rest-soa.md
Created August 7, 2014 22:04
Ajax/REST - SOA

Ajax/REST - SOA

Para consumir os dados servidos pelo servidor usando Ajax, podemos usar o CORS (Cross-Origin Resource Sharing). Ele consiste de 2 headers, um na requisiçáo e um na resposta.

Setando header Access-Control-Allow-Origin com JAX-RS:

// Alteraramos o método buscaPagamento para usar um ResponseBuilder
// e setar o header
@vmattos
vmattos / notas-wd47.md
Last active August 29, 2015 14:04
Notas WD-47