Skip to content

Instantly share code, notes, and snippets.

@LaboratorioEfe5
LaboratorioEfe5 / javascript.js
Created January 21, 2016 11:51
sticky header pure javascript/css (no jquery)
/*paste this code in the footer*/
<script>
window.onscroll = function() {
var el = document.getElementById('headerWrapper'); // rename with your header wrapper id
if(window.pageYOffset > 1) {
//sticky header
el.classList.add("sticky");
} else {
//normal header
el.classList.remove("sticky");
@LaboratorioEfe5
LaboratorioEfe5 / grunt livereload + vagrant
Last active September 20, 2017 22:31
Easy way to get grunt livereload in vagrant
Install one of these extension packages
- Chrome extension https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei/related
- Firefox http://download.livereload.com/2.0.8/LiveReload-2.0.8.xpi
- Safari http://download.livereload.com/2.0.9/LiveReload-2.0.9.safariextz
configure
- if you want to use it with local files (or vagrant), be sure to enable “Allow access to file URLs” checkbox in Tools > Extensions > LiveReload after installation
In your terminal run:
- grunt watch
@LaboratorioEfe5
LaboratorioEfe5 / siempre sin www
Created August 5, 2014 20:14
redirigir por htaccess con y sin www
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
@LaboratorioEfe5
LaboratorioEfe5 / .bash_aliases
Created July 31, 2014 10:09
cygwin + heroku
alias heroku="/cygdrive/c/Program\ Files\ \(x86\)/Heroku/bin/heroku.bat"
@LaboratorioEfe5
LaboratorioEfe5 / word&char count bookmarklet
Created April 25, 2014 15:46
cuenta de palabras y caracteres del texto seleccionado
javascript:(function(){var%20t;if%20(window.getSelection)%20t%20=%20window.getSelection();else%20if%20(document.selection)%20t%20=%20document.selection.createRange();if%20(t.text%20!=%20undefined)%20t%20=%20t.text;if(!t%20||%20t%20==%20""){%20a%20=%20document.getElementsByTagName("textarea");%20for(i=0;%20i<a.length;%20i++)%20{%20%20if(a[i].selectionStart%20!=%20undefined%20&&%20a[i].selectionStart%20!=%20a[i].selectionEnd)%20%20{%20%20%20%20t%20=%20a[i].value.substring(a[i].selectionStart,%20a[i].selectionEnd);%20%20%20%20break;%20%20}%20}}if(!t%20||%20t%20==%20"")alert("please%20select%20some%20text");else%20alert("word%20count:%20"%20+%20t.toString().match(/(\S+)/g).length+"%20chars:"+t.toString().length);})()
@LaboratorioEfe5
LaboratorioEfe5 / wp_excerpt_char_count
Created March 7, 2014 13:53
Wordpress excerpt character count qtranslate compatible
/**
* excerpt char count
* qtranslate compatible
* just cut&paste in your functions.php
* author: http://somosf5.com
*/
function excerpt_count_js(){
$languajes=array('es');
@LaboratorioEfe5
LaboratorioEfe5 / Show WP Theme Bookmarklet
Last active August 14, 2017 12:29
Bookmarklet para mostrar los datos relativos al theme actual si la página está construida con el CMS WordPress.
javascript:(function(){var links=document.getElementsByTagName("link");var neededElements=[];var reg=/\/wp-content\/themes\/(.)+\/style\.css/;var themeStyle="";for(var i=0,length=links.length;i<length;i++)if(links[i].rel.indexOf("stylesheet")>=0)if(links[i].href.match(reg))themeStyle=links[i].href;if(themeStyle===""){alert("Vaya parece que la web actual no est\u00e1 construida con WordPress");return false;}var txtFile=new XMLHttpRequest;txtFile.open("GET",themeStyle,true);txtFile.onreadystatechange=function(){if(txtFile.readyState===4)if(txtFile.status===200){allText=txtFile.responseText;themeName=allText.match(/theme name:(.)+/i)||{};themeURI=allText.match(/theme URI:(.)+/i)||{};description=allText.match(/Description:(.)+/i)||{};author=allText.match(/Author:(.)+/i)||{};authorURI=allText.match(/Author URI:(.)+/i)||{};version=allText.match(/Version:(.)+/i)||{};tags=allText.match(/Tags:(.)+/i)||{};alert(themeName[0]+"\n"+themeURI[0]+"\n"+description[0]+"\n"+author[0]+"\n"+authorURI[0]+"\n"+version[0]+"\n"+tags[
@LaboratorioEfe5
LaboratorioEfe5 / Access WP admin bookmarklet
Last active November 15, 2016 17:13
Bookmarktlet Simple para lanzar el panel de control de wordpress desde cualquier página de un site construido con este CMS. Para utilizarlo crear un nuevo favorito con el código proporcionado.
javascript:(function(){host=window.location.hostname;window.open("http://"+host+"/wp-admin");})()