Skip to content

Instantly share code, notes, and snippets.

View victorvhpg's full-sized avatar
🤖

Victor Hugo victorvhpg

🤖
View GitHub Profile
//disponivel no meu repositorio: https://github.com/victorvhpg/NumeroMagicoJS
////numeros magicos de alguns formatos
// //de arquivo
var _numeroMagicosArquivos = [{
tipo: "mp3",
numeroMagicos: [
[0x49, 0x44, 0x33],
[0xFF, 0xFB]
]
}, {
//retorna uma Promise que faz download de urlArquivo com responseType blob
//resolve a Promise com o blob 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 blob
xhr.responseType = "blob";
//quando a requisicao completar
xhr.addEventListener("load", function() {
downloadArquivo("./video.ogv", function(progresso, total, perc) {
document.querySelector("progress").value = perc;
}).then(function(blob) {
//cria o elemento video
var video = document.createElement("video");
video.autoplay = true;
//cria uma URL para o video // blob: xxxxxxx
video.src = window.URL.createObjectURL(blob);
//apos o video carregar pode remover url window.URL.revokeObjectURL(video.src);
//coloca o video no body
@victorvhpg
victorvhpg / instala.sh
Last active August 29, 2015 14:15
instalar browserify
#instalando o browserify globalmente
npm install -g browserify
@victorvhpg
victorvhpg / Poder.js
Created February 22, 2015 02:02
modulo Poder
"use strict";
//modulo Poder
var Poder = function(tipo) {
this.tipo = tipo;
};
Poder.prototype = {
constructor: Poder,
soltarPoder: function() {
@victorvhpg
victorvhpg / qualquerCoisa.js
Last active August 29, 2015 14:15
modulo qualquerCoisa
"use strict";
//exportando propriedades e metodos do modulo
exports.qualQuerValor = "1111111";
exports.fazAlgo = function() {
console.log("fazAlgo");
};
@victorvhpg
victorvhpg / qualquerCoisa.js
Created February 22, 2015 02:17
usando modulo qualquerCoisa
var qualquerCoisa = require("./qualquerCoisa");
qualquerCoisa.fazAlgo();
@victorvhpg
victorvhpg / usandoPoder.js
Last active August 29, 2015 14:15
usando modulo Poder.js
"use strict";
//dependencias do modulo
var Poder = require("./Poder");
var Personagem = function(n) {
this.nome = n;
this.poder = new Poder("normal");
};
"use strict";
//dependencias do modulo
var Personagem = require("./Personagem");
var qualquerCoisa = require("./qualquerCoisa");
var app = {
init: function() {
console.log("app init()");
var p1 = new Personagem("Personagem 1");
@victorvhpg
victorvhpg / jquery.sh
Last active July 12, 2018 06:11
npm install jquery --save
npm install jquery --save