Skip to content

Instantly share code, notes, and snippets.

View sergiolopes's full-sized avatar

Sérgio Lopes sergiolopes

View GitHub Profile
@sergiolopes
sergiolopes / build.sh
Created October 28, 2013 13:58
Compressão de HTML, JSP e Tagfiles em build time usando htmlcompressor. O arquivo regex.txt exclui patterns (no caso, scriptlets e diretivas JSP).
java -jar war/WEB-INF/lib/htmlcompressor-*.jar \
--type html --recursive --mask '*.jsp;*.html;*.tag;*.htm' \
--compress-css --compress-js --js-compressor closure \
--remove-intertag-spaces --remove-quotes \
--preserve-server-script -p regex.txt \
-o war/ war/ 2> /dev/null
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/pt_BR/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
@sergiolopes
sergiolopes / svg_stack.py
Created August 12, 2013 19:18
svg_stack com suporte a viewBox e output das coordenadas
#!/usr/bin/env python
## Copyright (c) 2009 Andrew D. Straw
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
@sergiolopes
sergiolopes / svg.html
Created August 2, 2013 19:03
Detect SVG support with pure JS
<script>document.documentElement.className = 'js '+ (!!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect ? 'svg':'nosvg')</script>
@sergiolopes
sergiolopes / async-define.js
Last active February 11, 2024 23:10
AMD-compatible async 'define' modularization.
/*
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 / Gruntfile.js
Created June 10, 2013 22:07
Exemplo mínimo de Grunt.js pro blog da Caelum
module.exports = function(grunt) {
grunt.initConfig({
uglify: {
'build/teste.js': 'src/teste.js'
},
less: {
'build/estilo.css': ['src/*.less']
}
});
@sergiolopes
sergiolopes / bookmarklet.js
Created March 24, 2013 08:21
Bookmarklet pra habilitar o zoom em páginas mobile mesmo quando o autor desabilita o zoom. Adicione esse bookmarklet no seu navegador mobile e acione-o em cima de qualquer página pra sobrescrever a meta tag viewport por uma usável com zoom habilitado.
javascript:document.querySelector('meta[name=viewport]').setAttribute('content','width=device-width,initial-scale=1,maximum-scale=10,user-zoom=yes');
function load(url) {
var scripts = document.getElementsByTagName('script')[0]
var script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
}
load('//apis.google.com/js/plusone.js');
load('//platform.twitter.com/widgets.js');
load('//s.widgetsite.com/widget.js');
@sergiolopes
sergiolopes / README.md
Last active February 11, 2024 23:57
A script to generate SVG sprites, including CSS and PNG fallbacks.
@sergiolopes
sergiolopes / autogrow.js
Created August 7, 2012 13:58
Textarea autogrow
function autogrow(textarea) {
// create fake div with same content
// (only works with box-sizing border-box)
var dv = document.createElement("div");
dv.className = 'fm-growable';
dv.style.visibility="hidden";
dv.style.position="absolute";
textarea.parentNode.appendChild(dv);