Skip to content

Instantly share code, notes, and snippets.

View verteb's full-sized avatar

Dominic Simard verteb

View GitHub Profile
@verteb
verteb / Redirect with query vars
Created March 8, 2016 19:04
Redirect with query vars
RewriteCond %{REQUEST_URI} ^/produits.aspx$
RewriteCond %{QUERY_STRING} ^catID=2$
RewriteRule ^(.*)$ http://canotslegare.com/nos-produits/? [R=301,L]
@verteb
verteb / js-async-loading.html
Last active September 2, 2016 19:58
Javascript async script loading
<script>
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src = '<?= TEMPLATE_DIRECTORY ?>/js/script.js?v=<?php echo filemtime (TEMPLATE_PHYSICAL_DIRECTORY.'js/script.js' ) ?>';
s.parentNode.insertBefore(g, s);
}(document, 'script'));
</script>
@verteb
verteb / gist:8655516
Created January 27, 2014 19:18
ACF: repeater
if( have_rows('repeater_field_name') ){
while ( have_rows('repeater_field_name') ){
the_sub_field('sub_field_name');
}
}
@verteb
verteb / gist:8549262
Created January 21, 2014 21:58
jQuery: getJSON
$.getJSON( "file.php", function(data) {
});
@verteb
verteb / gist:8549213
Created January 21, 2014 21:56
jQuery event handler
$('').on('', function(){
});
@verteb
verteb / datepicker.js
Created June 29, 2013 20:55
jQuery UI : datepicker Localized
//Localisation du calendrier
$.datepicker.regional['fr-CA'] = {
closeText: 'Fermer',
prevText: 'Précédent',
nextText: 'Suivant',
currentText: 'Aujourd\'hui',
monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin',
'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
@verteb
verteb / count-posts-by-term.php
Created June 26, 2013 13:56
Wordpress: Count posts by term
function fc_count_posts_with_term($term_slug, $taxonomy)
{
global $wpdb;
$term = get_term_by( 'slug', $term_slug, $taxonomy );
$st = $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts p
INNER JOIN $wpdb->term_relationships tr
ON (p.ID = tr.object_id)
INNER JOIN $wpdb->term_taxonomy tt
ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
@verteb
verteb / closure.js
Created June 21, 2013 02:52
Javascript: Closure function
(function(){
}());
#Forcer https
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://quebecboattour.com/$1 [R,L]
</IfModule>
@verteb
verteb / prenvent-ios-landscape-zoom.css
Created June 12, 2013 13:57
Mobile : Prevent IOS Landscape Zoom
/* iPhone */
@media only screen and (width:320px) and (device-width:320px) and (device-height:480px) and (orientation: landscape) {
body {
-webkit-transform: scale(0.667);
-webkit-transform-origin: top right;
position: absolute;
right: 0;
top: 0;
width: 480px;
}