Skip to content

Instantly share code, notes, and snippets.

View thom4parisot's full-sized avatar

Thomas Parisot thom4parisot

View GitHub Profile
@thom4parisot
thom4parisot / gist:341080
Created March 23, 2010 11:43
WordPress − returns the number of posts from a category
<?php
/**
* Returns the number of posts from a category
*
*
* @version 1.0
* @since 2010-03-23
* @author Oncle Tom <http://case.oncle-tom.net>
* @param integer $category_id
@thom4parisot
thom4parisot / gist:410893
Created May 23, 2010 12:28
WordPress − Returns the number of candidate posts for the current query
<?php
/**
* Returns the number of candidate posts for the current query
*
* Written because I saw some heavy code like that to do the same thing: http://theandystratton.com/2009/show-total-search-results-wordpress-search-template/
*
* @version 1.0
* @since 2010-05-23
* @author Oncle Tom <http://case.oncle-tom.net>
@thom4parisot
thom4parisot / gist:667608
Last active September 24, 2015 04:27
Multi-line vertical alignment
<!DOCTYPE html>
<html>
<head>
<title>CSS vertical-align sample</title>
<style type="text/css" media="all">
body{
font: 80%/1.5em Verdana, sans-serif;
}
.multicolumn li{
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<name>content/view/kml/62</name>
<open>0</open>
<Placemark id="winery-66">
<name>La Tour de By</name>
<visibility>1</visibility>
<open>0</open>
<address>5 route de la tour de By
@thom4parisot
thom4parisot / theme-comments.php
Created September 15, 2011 13:13
The Morning After WP theme i18n fix for comments
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __('Reply to this comment'), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
@thom4parisot
thom4parisot / functions.php
Created January 10, 2012 16:08
WordPress Stylesheet inclusion best practice
<?php
if (!is_admin()){
add_action('init', 'theme_init_stylesheets');
}
/**
* Registers stylesheets for the current (child) theme
*
* @wordpress:action init
@thom4parisot
thom4parisot / functions.php
Created February 29, 2012 14:12
WordPress + AlwaysData + HTTPS = #win
<?php
add_action('init', 'alwaysdata_ssl');
/**
* Enables proper HTTPS detection with WordPress and Alwaysdata
*/
function alwaysdata_ssl()
{
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
@thom4parisot
thom4parisot / regexp.js
Created May 18, 2012 19:55
// vs. RegExp
var host = 'test.om';
/^.+\.[^\.]+\.om$/.exec(host); // returns 'null'
/*
* The move:
* 1) new RegExp(/^.+\.[^\.]+\.om$/).exec(host);
* 2) (new RegExp(/^.+\.[^\.]+\.om$/)).exec(host);
* 3) (new RegExp('^.+\.[^\.]+\.om$')).exec(host);
*/
@thom4parisot
thom4parisot / casper.js
Created July 12, 2012 13:33
Bootstrap Dropdown CasperJS check.
casper.start();
casper.open('http://twitter.github.com/bootstrap/javascript.html#dropdowns');
casper.then(function(){
this.test.assertExists('#navbar-example');
this.click('#dropdowns .nav-pills .dropdown:last-of-type a.dropdown-toggle');
this.wait(2000, function(){
this.test.assertExists('#dropdowns .nav-pills .open', 'Dropdown is open');
});
@thom4parisot
thom4parisot / casper-dump-headers.js
Created July 17, 2012 13:58
Dump Response Headers with CasperJS
var casper = require('casper').create();
casper.start();
casper.open('http://borisschapira.com/');
casper.then(function dumpHeaders(){
this.currentResponse.headers.forEach(function(header){
console.log(header.name +': '+ header.value);
});
});