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 / 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 [email protected]
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
@victorvhpg
victorvhpg / apache.sh
Created January 2, 2015 05:05
ativa virtual host e apache reload
#ativa o virtual host git
sudo a2ensite git.conf
#reinicia o apache
service apache2 reload
# ou
# sudo /etc/init.d/apache2 reload
@victorvhpg
victorvhpg / user.sh
Last active August 29, 2015 14:12
criar user
#este comando cria um usuário com login victorvhpg
#para a área "Acesso privado Git", a senha será solicitada logo após a execução do comando.
#o arquivo foi colocado em /var/www/git/ apenas para exemplo
#Eh recomendado que coloque ele em um local seguro
sudo htdigest -c /var/www/git/.htpasswd "Acesso privado Git" victorvhpg
@victorvhpg
victorvhpg / git.sh
Last active August 29, 2015 14:12
git remoto
#inicializa um repositorio git chamado meu_projeto.git com --bare,
#para que soh seja criado os arquivos do git
#este repositorio nao tera area de trabalho ele so tera os arquivos git.
git init --bare meu_projeto.git
@victorvhpg
victorvhpg / git.sh
Last active August 29, 2015 14:12
git remoto clone/push
#clonar o repositorio
git clone http://git.exemplo/git/meu_projeto.git
#sera solicitada a autenticacao
#Username for 'http://git.exemplo': victorvhpg
#Password for 'http://[email protected]': *****
#apos isso
#pode colaborar, fazer commits e push para o servidor
echo "oi servidor" > oi.txt
@victorvhpg
victorvhpg / downloadArquivo-arraybuffer.js
Last active August 29, 2015 14:14
faz download de arquivo com responseType ArrayBuffer //resolve a Promise com o ArrayBuffer do arquivo
//retorna uma Promise que faz download de urlArquivo com responseType ArrayBuffer
//resolve a Promise com o ArrayBuffer do arquivo
var downloadArquivo = function(urlArquivo,fnProgresso) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", urlArquivo, true);
//setar o responseType para arraybuffer
xhr.responseType = "arraybuffer";
//quando a requisicao completar
xhr.addEventListener("load", function() {
downloadArquivo("./logo.png").then(function(arrayBuffer) {
var blob = new Blob([arrayBuffer], {
type: "image/png"
});
var img = document.createElement("img");
img.addEventListener("load", function(e) {
window.URL.revokeObjectURL(img.src);
}, false);
img.src = window.URL.createObjectURL(blob);
downloadArquivo("./video.ogv", function(progresso, total, perc) {
document.querySelector("progress").value = perc;
}).then(function(arrayBuffer) {
//cria um Blob a partir do arrayBuffer
var blob = new Blob([arrayBuffer], {
type: "video/ogg"
});
//cria o elemento video
var video = document.createElement("video");
video.autoplay = true;