Skip to content

Instantly share code, notes, and snippets.

Avatar

Sérgio Lopes sergiolopes

View GitHub Profile
@sergiolopes
sergiolopes / lazyload-v2.js
Last active February 2, 2023 03:55
Lazy load de imagens beeem simples
View lazyload-v2.js
(function(){
// como vamos usar o throttle varias vezes (no scroll e no resize),
// encapsulei essa funcionalidade numa função
function throttle(fn) {
fn.jarodei = false;
return function(){
if (fn.jarodei) return;
fn.jarodei = true;
@sergiolopes
sergiolopes / README.md
Last active March 30, 2022 15:19
A script to generate SVG sprites, including CSS and PNG fallbacks.
View README.md
@sergiolopes
sergiolopes / README.md
Created February 28, 2012 21:57
Pure CSS fix to iOS zoom bug on device rotation
View README.md

My approach to fix the iOS bug is documented here:

https://github.com/sergiolopes/ios-zoom-bug-fix

Here I present one experiment with a pure CSS solution, no JS required. It uses width=device-width normally (no device-height hacking) and scales down the page on landscape.

Works fine on all iOS versions.

There's only one problem: on old iOS versions (prior to 4.3.5), the page will get a big empty space at bottom, below the content, when on landscape. Recent iOS versions don't show this behavior.

@sergiolopes
sergiolopes / svg.html
Created August 2, 2013 19:03
Detect SVG support with pure JS
View svg.html
<script>document.documentElement.className = 'js '+ (!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect ? 'svg':'nosvg')</script>
@sergiolopes
sergiolopes / duracao.sh
Last active April 3, 2018 17:48
Retorna o tempo total em segundos de um arquivo do ScreenFlow
View duracao.sh
#!/bin/bash
# Retorna o tempo total em segundos de um arquivo do ScreenFlow
#
# Requisito: Dar permissão de acessibilidade pro Terminal ou outra App que vai executar
# (System Preferences > Security & Privacy > Privacy > Accessibility > Add Application)
file=$1
if [ "$file" = "" ] || [ ! -d "$file" ]; then
echo Passe o nome do arquivo pra detectar a duração
@sergiolopes
sergiolopes / 4shared.js
Last active July 2, 2017 03:02
urls do google drive / scribd
View 4shared.js
javascript:void function(){
var txt = [].slice.call(document.querySelectorAll('.fname h1 a')).map(el => el.href).reduce((url,acc) => acc + '\r\n' + url);
var ta = document.createElement('textarea');
document.body.appendChild(ta);
ta.value = txt;
ta.select();
document.execCommand('copy');
}();
@sergiolopes
sergiolopes / context.xml
Created April 23, 2012 07:08
Arquivo de configuração do Weld no Tomcat (crie dentro da pasta META-INF)
View context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Manager pathname=""/> <!-- disables storage of sessions across restarts -->
<Resource name="BeanManager"
auth="Container"
type="javax.enterprise.inject.spi.BeanManager"
factory="org.jboss.weld.resources.ManagerObjectFactory"/>
</Context>
@sergiolopes
sergiolopes / web.xml
Created April 23, 2012 07:09
Configuração do Weld para um Servlet Container sem CDI - copie dentro do web.xml
View web.xml
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>
javax.enterprise.inject.spi.BeanManager
</resource-env-ref-type>
</resource-env-ref>
@sergiolopes
sergiolopes / async-define.js
Last active February 22, 2017 14:23
AMD-compatible async 'define' modularization.
View async-define.js
/*
AMD-compatible async 'define' modularization.
Contains only the 'define' module syntax compatible with the official API
and a flexible dependency resolver with no restrictions on how you load your files.
This implementation doesn't load your JS files so you have to do it. You can bundle
one big file, load multiple files, load them asynchronously, out of order, your call.
(doesn't include the 'require' and 'requirejs' objects)
@sergiolopes
sergiolopes / nerdnews.sh
Created June 6, 2016 18:58
Extrai textos das noticias do nerdnews
View nerdnews.sh
#!/bin/bash
for PAGINA in {1..2}; do
curl -s -L https://jovemnerd.com.br/categoria/nerdnews/page/$PAGINA/ | sed -n 's/.*href="\(https:\/\/jovemnerd.com.br\/nerdnews\/[^"]*\).*/\1/p'
done | \
while read link; do
curl -s $link > /tmp/nerdtech.html
xmllint --html --xpath '//div[@class="title"]/h2/text()' /tmp/nerdtech.html 2> /dev/null