Skip to content

Instantly share code, notes, and snippets.

View victorvhpg's full-sized avatar
🎯
Focusing

Victor Hugo victorvhpg

🎯
Focusing
View GitHub Profile
@victorvhpg
victorvhpg / ajaxUpload.js
Created February 2, 2014 03:05
upload de arquivo com jquery ajax - fle upload ajax
(function($){
//=========================================================================================
$.ajaxUpload = function(config) {
var formData = new FormData();
var data = config.data;
for(var i in data){
formData.append(i, data[i]);
}
return $.ajax({
type: "POST",
@victorvhpg
victorvhpg / paginacao.js
Created February 2, 2014 03:10
paginacao de table
var Paginacao = (function($) {
"use strict";
var Paginacao = function() {
this.qtdRegistroPorPagina = 10;
this.qtdDePaginacao = 7;
this.template = ["<ul data-pg=\"container\" class=\"pagination\" > ",
"<li data-pg=\"anterior\" ><a href=\"javascript:;\">&laquo;</a></li>",
"<li data-pg=\"numeros\" > <a href=\"javascript:;\"> {@numero} </a> </li>",
"<li data-pg=\"proximo\" ><a href=\"javascript:;\">&raquo;</a></li> ",
"</ul>"
@victorvhpg
victorvhpg / clona.sh
Last active August 29, 2015 14:10
Clonar todos os repositorios publicos de um usuário - github
#!/bin/bash
#id do usuario
USUARIO="victorvhpg"
# pega json que contem todos os repositorios e extrai as URLs
LISTA_URL_CLONES=`curl --silent https://api.github.com/users/${USUARIO}/repos -q | grep "\"clone_url\"" | awk -F': "' '{print $2}' | sed -e 's/",//g'`
#para cada url faz um 'git clone'
for URL in $LISTA_URL_CLONES; do
@victorvhpg
victorvhpg / ajaxPromise.js
Last active August 29, 2015 14:10
exemplo ajax com promise
function ajaxPromise(config) {
return new Promise(
function(resolve, reject) {
var xhr = new XMLHttpRequest();
var p = [];
var parametros = null;
config.parametros = config.parametros || {};
for (var parametro in config.parametros) {
p.push(parametro + "=" + config.parametros[parametro]);
}
@victorvhpg
victorvhpg / comparacao.js
Created November 24, 2014 04:59
Comparação callbacks / Promise
//callbacks dentro de callbacks
algumaCoisa1(function(resposta1) {
//...
algumaCoisa2(function(resposta2) {
//...
algumaCoisa3(function(resposta3) {
//...
acaoFinal(resposta3);
});
});
@victorvhpg
victorvhpg / jQueryAMD.js
Created December 1, 2014 05:48
jQueryAMD
(function(window) {
"use strict";
//criamos uma funcao auto executavel que recebe uma function "fnCriaPlugin"
//que eh a implementacao do nosso plugin
(function(fnCriaPlugin) {
//agora eh so verificar se possui AMD ou nao
if (typeof define === "function" && define.amd) {
// COM suporte AMD
//entao registra o plugin com a depedencia jquery
@victorvhpg
victorvhpg / install.sh
Created January 1, 2015 06:25
instalar apache
sudo apt-get install apache2 apache2-utils
@victorvhpg
victorvhpg / modulos.sh
Last active August 29, 2015 14:12
habilitar modulos mod_cgi, mod_alias, mod_env e auth_digest no Apache
#habilita os modulos necessarios
sudo a2enmod cgi alias env auth_digest
@victorvhpg
victorvhpg / install git.sh
Last active August 29, 2015 14:12
install/compilar o git
#usando apt-get
sudo apt-get install git
#compilando a partir do codigo fonte
#baixe a ultima versao do GIT aqui: https://www.kernel.org/pub/software/scm/git
#por exemplo a versao 2.2.1 https://www.kernel.org/pub/software/scm/git/git-2.2.1.tar.gz
#depois descompacte e compile ele:
wget https://www.kernel.org/pub/software/scm/git/git-2.2.1.tar.gz
tar -zxf git-2.2.1.tar.gz
@victorvhpg
victorvhpg / git.conf
Last active August 29, 2015 14:12
configuracao do apache para o git
<VirtualHost *:80>
ServerAdmin victorvhpg@gmail.com
ServerName git.exemplo
DocumentRoot /var/www/git
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#local onde estao os repositorios git