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
@vmattos
vmattos / attachEvent-polyfill.js
Last active May 23, 2018 11:23
attachEvent polyfill I made for my buddy @leandrooriente, who is nuts about IE. Now you can enjoy your Micro$oft event handlers everywhere! I'm a douchebag.
(function(win){
if(win.attachEvent) return;
var attachEvent = function(on, callback) {
var on = on.substring(2,on.length);
return this.addEventListener(on, callback);
}
win.Element.prototype.attachEvent = attachEvent;
@vmattos
vmattos / gist:7936534
Created December 12, 2013 22:14 — forked from oli/gist:1637874
# ~/.gitconfig from @boblet
# initially based on http://rails.wincent.com/wiki/Git_quickstart
[core]
excludesfile = /Users/oli/.gitignore
legacyheaders = false # >git 1.5
quotepath = false
# http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
pager = less -r
# if ↑ doesn’t work, try: pager = less -+$LESS -FRX
@vmattos
vmattos / notas-wd47.md
Last active August 29, 2015 14:04
Notas WD-47
@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 / 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 / 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 / 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
++++++++++
[
>+++++++++++
>++++++++++
>++++++++++++
>+++++++++++
>+++++++++++
>+++++
>+++++++++++
>+++++++++++
#!/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 / 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...
*
*/