Skip to content

Instantly share code, notes, and snippets.


Sérgio Lopes sergiolopes

View GitHub Profile
sergiolopes / lazyload-v2.js
Last active February 2, 2023 03:55
Lazy load de imagens beeem simples
View lazyload-v2.js
// 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 /
Last active March 30, 2022 15:19
A script to generate SVG sprites, including CSS and PNG fallbacks.
sergiolopes /
Created February 28, 2012 21:57
Pure CSS fix to iOS zoom bug on device rotation

My approach to fix the iOS bug is documented here:

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 / 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('', "svg").createSVGRect ? 'svg':'nosvg')</script>
sergiolopes /
Last active April 3, 2018 17:48
Retorna o tempo total em segundos de um arquivo do ScreenFlow
# 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)
if [ "$file" = "" ] || [ ! -d "$file" ]; then
echo Passe o nome do arquivo pra detectar a duração
sergiolopes / 4shared.js
Last active July 2, 2017 03:02
urls do google drive / scribd
View 4shared.js
javascript:void function(){
var txt = []'.fname h1 a')).map(el => el.href).reduce((url,acc) => acc + '\r\n' + url);
var ta = document.createElement('textarea');
ta.value = txt;;
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"?>
<Manager pathname=""/> <!-- disables storage of sessions across restarts -->
<Resource name="BeanManager"
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
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 /
Created June 6, 2016 18:58
Extrai textos das noticias do nerdnews
for PAGINA in {1..2}; do
curl -s -L$PAGINA/ | sed -n 's/.*href="\(https:\/\/\/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