Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Mike Boutin DWboutin

🎯
Focusing
  • Quebec city
View GitHub Profile
@DWboutin
DWboutin / gist:4757512
Created Feb 11, 2013
Sort by specific key
View gist:4757512
function subval_sort($a,$subkey) {
foreach($a as $k=>$v) {
$b[$k] = strtolower($v[$subkey]);
}
asort($b);
foreach($b as $key=>$val) {
$c[] = $a[$key];
}
return array_reverse($c);
}
@DWboutin
DWboutin / gist:5172346
Created Mar 15, 2013
Espace des numéros dans l'argent PHP
View gist:5172346
function formatMoney($number, $fractional=false) {
if ($fractional) {
$number = sprintf('%.2f', $number);
}
while (true) {
$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
@DWboutin
DWboutin / Bootstrap responsive mixin
Last active Dec 18, 2015
Bootstrap responsive mixin
View Bootstrap responsive mixin
@mixin responsive($size)
@if $size == 'large'
@media (min-width: 1200px)
@content
@if $size == 'normal'
@media (min-width: 992px) and (max-width: 1199px)
@content
@if $size == 'tablet'
@media (min-width: 768px) and (max-width: 991px)
@content
@DWboutin
DWboutin / gist:6040606
Created Jul 19, 2013
Boucle infini fadein fadeout slide
View gist:6040606
var timer = setInterval(function(){
for(var i = 0, liNbr = liEl.length; i < liNbr; i++){
liEl.eq(i).css({left: liEl.eq(i).position().left + 1 });
if(liEl.eq(i).position().left > liEl.eq(i).parent().width()){
if(!liEl.eq(i).is(':animated')){
liEl.eq(i).fadeOut(200, function(){
$(this).css({left: '0px'}).prependTo($(this).parent()).fadeIn(200);
});
@DWboutin
DWboutin / jQueryPluginStart.js
Last active Dec 20, 2015
Start for a jQuery plugin
View jQueryPluginStart.js
(function($) {
'use strict';
$.fn.pluginName = function(options, callback) {
//this selector
var thisEl = $(this);
// options
var settings = {
};
@DWboutin
DWboutin / taxonomy loop
Created Jul 31, 2013
Trouver toutes les taxonomies Wordpress
View taxonomy loop
<?php
$args = array(
'orderby' => 'term_id',
'order' => 'ASC',
'hide_empty' => 0,
);
$product_categories = get_terms( 'product_cat', $args );
$menuCat = array();
@DWboutin
DWboutin / azure-htaccess
Last active Dec 21, 2015
web.config base for Azure's "htaccess"
View azure-htaccess
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(*)$" ignoreCase="false" />
<action type="Rewrite" url="myUrl.html" appendQueryString="true" />
</rule>
@DWboutin
DWboutin / add-remove-menu-admin-bar
Created Sep 9, 2013
Add and remove menus in the admin bar (wordpress)
View add-remove-menu-admin-bar
function mytheme_admin_bar_render() {
global $wp_admin_bar;
// add a menu from the admin bar
$wp_admin_bar->add_menu( array(
'id' => 'home', // link ID, defaults to a sanitized title value
'title' => __('Home'), // link title
'href' => admin_url( '../index.php'), // name of file
'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
));
@DWboutin
DWboutin / web.config
Created Jan 14, 2014
web.config cache
View web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
@DWboutin
DWboutin / web.config
Created Jan 14, 2014
web.config GZIP compression Add the configuration shown below in the in web.config file. This configuration setup enable gzip compression on static and on dynamic content.
View web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="*/*" enabled="false"/>