Skip to content

Instantly share code, notes, and snippets.

@andrescifuentesr
andrescifuentesr / Performance .htacces
Created Feb 23, 2015
Web perfomance gzipping and caching header from HTML5 Boilerplate
View Performance .htacces
# ######################################################################
# # WEB PERFORMANCE #
# ######################################################################
# ----------------------------------------------------------------------
# | Compression |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
@andrescifuentesr
andrescifuentesr / gzipping .htacces
Created Feb 20, 2015
Web perfomance gzipping from HTML5 boilerplate
View gzipping .htacces
# ######################################################################
# # WEB PERFORMANCE #
# ######################################################################
# ----------------------------------------------------------------------
# | Compression |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
View gist:38bdc173ff323d9e0035
<?php //different sizes ?>
<?php $large_image_urlLarge = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogLarge' ); ?>
<?php $large_image_urlMedium = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogMedium' ); ?>
<?php $large_image_urlSmall = wp_get_attachment_image_src( get_post_thumbnail_id(), 'imgBlogSmall' ); ?>
<?php //title == alt ?>
<?php $title = get_post(get_post_thumbnail_id())->post_title; //The Title ?>
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
@andrescifuentesr
andrescifuentesr / Simple grid
Last active Aug 29, 2015
A simple grid mixin
View Simple grid
//=================================
/* Simple grid */
@mixin simple-grid($nombre-items , $margin-right ){
width: ( (100% - ( ($nombre-items - 1) * $margin-right) ) / $nombre-items);
margin-right: $margin-right;
float:left;
&:nth-child(n) {
margin-right: $margin-right;
@andrescifuentesr
andrescifuentesr / ImageLightbox.js
Created Jul 23, 2014
ImageLightbox.js use code
View ImageLightbox.js
jQuery( function( $ )
{
// ACTIVITY INDICATOR
var activityIndicatorOn = function()
{
$( '<div id="imagelightbox-loading"><div></div></div>' ).appendTo( 'body' );
},
activityIndicatorOff = function()
{
@andrescifuentesr
andrescifuentesr / Insert PHP
Last active Aug 29, 2015
Insert Basic PHP
View Insert PHP
<?php
// Connexion BDD
mysql_connect('localhost', 'hostname', 'password'); //
mysql_select_db('mybdd');
mysql_query("SET NAMES 'utf8'");
// on start la session
session_start();
ini_set('session.gc_maxlifetime', 2592000); // durée de la session => 30 jours (2592000 secondes)
@andrescifuentesr
andrescifuentesr / gist:11326078
Last active Aug 29, 2015
Remove/Format [...] Excerpt in WP
View gist:11326078
//Remove [...] string using Filters
<?php
function new_excerpt_more( $more ) {
return '<div class="read-more"><a href="'. get_permalink( get_the_ID() ) . '">Read More</a></div>';
}
add_filter('excerpt_more', 'new_excerpt_more');
//Control Excerpt Length using Filters
function custom_excerpt_length( $length ) {
return 30;
@andrescifuentesr
andrescifuentesr / .htaccess wp-config.php
Created Apr 20, 2014
.htaccess to protect wp-config.php file
View .htaccess wp-config.php
<files wp-config.php>
order allow,deny
deny from all
</files>
@andrescifuentesr
andrescifuentesr / Resume xmots
Created Apr 18, 2014
A php function to cut a character chaine
View Resume xmots
//----------------------------------------------------------------------------------------------------
// Fonction pour limiter le nombre de caractere
//----------------------------------------------------------------------------------------------------
function resume_xmots($MaChaine,$xmots)
{
$ChaineTab=explode(" ",$MaChaine);
for($i=0;$i<$xmots;$i++)
{
$NouvelleChaine.=" "."$ChaineTab[$i]";
}
@andrescifuentesr
andrescifuentesr / detectingIE
Last active Dec 28, 2015 — forked from padolsey/gist:527683
Detecting versions of IE
View detectingIE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}