Skip to content

Instantly share code, notes, and snippets.

View DWboutin's full-sized avatar
🎯
Focusing

Mike Boutin DWboutin

🎯
Focusing
  • Quebec city
View GitHub Profile
@DWboutin
DWboutin / gist:4757512
Created February 11, 2013 20:52
Sort by specific key
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 March 15, 2013 19:20
Espace des numéros dans l'argent PHP
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 December 18, 2015 00:08
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 July 19, 2013 16:44
Boucle infini fadein fadeout slide
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 December 20, 2015 04:48
Start for a jQuery plugin
(function($) {
'use strict';
$.fn.pluginName = function(options, callback) {
//this selector
var thisEl = $(this);
// options
var settings = {
};
@DWboutin
DWboutin / taxonomy loop
Created July 31, 2013 17:44
Trouver toutes les taxonomies Wordpress
<?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 December 21, 2015 00:58
web.config base for Azure's "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 September 9, 2013 20:06
Add and remove menus in the admin bar (wordpress)
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 January 14, 2014 21:18
web.config cache
<?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 January 14, 2014 21:41
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.
<?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"/>