Skip to content

Instantly share code, notes, and snippets.

View chibani's full-sized avatar

Loïc Gerbaud chibani

View GitHub Profile
@chibani
chibani / WP : custom posts_per_page for custom post type
Created January 3, 2012 09:45
WordPress : Hack to give a custom posts_per_page value for a custom post type
//This code should be added in the plugin that manages the custom post type or in the functions.php of you theme
add_filter('request', 'hack_pagination');//Register the filter
/**
* Hack to give a custom posts_per_page value for a custom post type
* @param string $query_string automatically given by the filter
*/
function hack_pagination($query_string){
if($query_string['post_type']=='MY_CUSTOM_POST_TYPE' && !is_single() && !is_admin()) {
@chibani
chibani / custom_post_type_columns
Created January 11, 2012 14:26
WordPress : adding custom columns in the posts list while using a custom post type
//This filter will allow us to add new columns
add_filter("manage_edit-mycustom_columns", "edit_columns");
//This action will populate the new columns
add_action("manage_posts_custom_column", "custom_columns");
/**
* First step : declaring the new columns (in this function, we could also remove the default columns...)
* @param array $columns
*/
@chibani
chibani / mycustom-archive.php
Created January 11, 2012 16:04
WordPress : Load custom posts using their custom fields
//WordPress Query to load custom posts using their custom fields
$myquery = new WP_Query(array(
'post_type' => 'mycustom',
'posts_per_page' => 15,
'orderby' => 'meta_value',
'meta_key'=>'mycustom_date_start',
'order' => 'ASC',
'meta_query'=>array(
'relation'=>'AND',
array(
@chibani
chibani / gitolite.conf
Created February 23, 2012 11:03
gitolite example config file
@first_team first_dev second_dev
@second_team third_dev fourth_dev
@first_repo_group one_repo second_repo
@second_repo_group third_repo fourth_repo
repo @first_repo_group
RW = @first_team
R = @second_team
@chibani
chibani / unbound.conf
Created March 18, 2013 14:58
Exemple de config pour unbound.conf
server:
#verbosity: 1
#definition des interfaces réseaux du serveur
interface: 127.0.0.1
interface: 192.168.0.20
#ouverture à tout le monde
access-control: 0.0.0.0/0 allow
chroot: ""
@chibani
chibani / 107-devcom
Created March 18, 2013 15:06
Exemple d'utilisation du mod_alias et des VirtualDocumentRoot pour configurer facilement une machine de dev
<VirtualHost *:80>
ServerName www.loicg.dev.com
ServerAlias *.*.dev.com
VirtualDocumentRoot /home/web/workspace/%2/%1
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
@chibani
chibani / gist:f24ad9feded5134a3600
Created October 23, 2014 09:04
Count different lines between 2 text (csv) files
diff -U 0 file1.csv file2.csv | grep '^-[^-]' | wc -l
@chibani
chibani / .htaccess
Created November 16, 2014 13:21
.htaccess specific version
# Use case (mine) :
# You're deploying a new version of a website on client's hosting.
# Of course, the previous website is in the root directory...
# You want your v2/ directory to be visible only for you and the client
# And the client (and perhaps you) doesn't have a static IP...
#
# In this case, I've decided to use a cookie.
# But, how may I set a cookie in the clients browser ?
# What if she wants to browser thi shinny new website with her smartphone or tablet ???
# What if she wants to show it to her team or even family ???

Keybase proof

I hereby claim:

  • I am chibani on github.
  • I am chibani (https://keybase.io/chibani) on keybase.
  • I have a public key whose fingerprint is 0FA5 1579 2BF6 456E 57E4 385C FD26 F7FA AEE0 C351

To claim this, I am signing this object: