Skip to content

Instantly share code, notes, and snippets.

View adrianjguerrero's full-sized avatar
😎

Adrián Guerrero adrianjguerrero

😎
View GitHub Profile
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");
$timeout = isset($_GET['timeout']) ? $_GET['timeout'] : 0;
sleep($timeout);
echo json_encode([
'timeout' => $timeout
import re
import os
import urllib.parse
import urllib.request
from tqdm import tqdm
# pip install tqdm
class DownloadProgressBar(tqdm):
def update_to(self, b=1, bsize=1, tsize=None):
if tsize is not None:
self.total = tsize
@adrianjguerrero
adrianjguerrero / encoding-video.md
Created September 22, 2020 00:21 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@adrianjguerrero
adrianjguerrero / getSvg.js
Last active September 9, 2020 03:19
useful for when you need to get a very large svg and don't want to put it inline because it makes the page load very slow
const getSvg = async (svgUrl, svgContainer) => {
let request = await fetch(svgUrl)
let svgText = await request.text()
const parser = new DOMParser();
const svgHtml = parser.parseFromString(svgText, "text/html");
svgContainer.appendChild(svgHtml.body.querySelector('svg'))
}
@adrianjguerrero
adrianjguerrero / ffmpeg-compress-mp4
Created August 31, 2020 23:46 — forked from lukehedger/ffmpeg-compress-mp4
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
alert('CLICK SOBRE LA IMAGEN DEL PRODUCTO A EDITAR')
document.querySelectorAll('td.image').forEach(el=>el.addEventListener('click',function(e){
var nombre = e.target.parentElement.parentElement.querySelector('td.name').textContent
let precio = prompt('INGRESA PRECIO TAL COMO LO COPIASTE DEL DOC')
precio = precio.replace('$','').replace(',','.').trim()
var others = [...document.querySelectorAll('td.name')].filter(el=>el.textContent===nombre).map(el=>el.parentElement.querySelector('.cell_input'))
others.forEach(el=>{
from bs4 import BeautifulSoup
import requests
url = 'http://www.bcv.org.ve/estadisticas/tipo-de-cambio'
response = requests.get(url)
html = BeautifulSoup(response.text, 'html.parser')
tasa_bcv = html.select_one('#dolar strong').get_text()
tasa_bcv = float(tasa_bcv.replace('.','').replace(',','.'))
@adrianjguerrero
adrianjguerrero / bancos
Last active March 6, 2020 08:54 — forked from AlexR1712/bancos
Codigo y Bancos correspondientes de Venezuela
Banco:
<select name="banco">
<option value=""></option>
<option value="0156">100%BANCO</option>
<option value="0196">ABN AMRO BANK</option>
<option value="0172">BANCAMIGA BANCO MICROFINANCIERO, C.A.</option>
<option value="0171">BANCO ACTIVO BANCO COMERCIAL, C.A.</option>
<option value="0166">BANCO AGRICOLA</option>
<option value="0175">BANCO BICENTENARIO</option>
<option value="0128">BANCO CARONI, C.A. BANCO UNIVERSAL</option>
@adrianjguerrero
adrianjguerrero / toggle2classes.js
Created July 18, 2019 18:51
script to toggle between 2 classes using classList API
function classToggle(el,class1,class2) {
el.classList.toggle(class1);
el.classList.toggle(class2);
}
@adrianjguerrero
adrianjguerrero / hidenav.js
Created July 10, 2019 12:38
function to hide a nav on scroll down, then show it on scroll up
function hideNav(el, howMuch) {
var prevScrollpos = window.pageYOffset;
window.addEventListener('scroll', function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
el.style.transform = 'translateY(0%)'
} else {
el.style.transform = 'translateY(' + howMuch + '%)'