Skip to content

Instantly share code, notes, and snippets.

View julienbourdeau's full-sized avatar
🏠
Working from home

Julien Bourdeau julienbourdeau

🏠
Working from home
View GitHub Profile
@julienbourdeau
julienbourdeau / spriteHelpers.less
Created October 13, 2012 11:44
Sprite with LESScss from smashing mag
.spriteHelper(@image, @x, @y, @spriteX, @spriteY) {
background: url("img/@{image}.png") no-repeat;
background-position: -(@x*@spriteX) -(@y*@spriteY);
}
.sprite(@image, @x, @y) when (@image = sprite1), (@image = sprite3){
@spriteX: 32px;
@spriteY: 16px;
.spriteHelper(@image, @x, @y, @spriteX, @spriteY);
}
.sprite(@image, @x, @y) when (@image = sprite2){
@julienbourdeau
julienbourdeau / gist:3922983
Created October 20, 2012 10:59
Change selection color
::selection {
background: #ffb7b7; /* Safari */
}
::-moz-selection {
background: #ffb7b7; /* Firefox */
}
p.red::selection {
/* here */
}
@julienbourdeau
julienbourdeau / gist:3999772
Created November 2, 2012 09:34
function_exists('posix_getpwuid')
if ( function_exists('posix_getpwuid') ) {
$this->wwwUser = \posix_getpwuid(\posix_geteuid());
} else {
$this->wwwUser = get_current_user();
}
@julienbourdeau
julienbourdeau / gist:4147154
Created November 26, 2012 08:14
clearfix (from bootstrap)
.clearfix {
*zoom: 1;
}
.clearfix:before,
.clearfix:after {
display: table;
line-height: 0;
content: "";
}
$('html, body').animate({
scrollTop: $("#elementID").offset().top
}, 2000);
@julienbourdeau
julienbourdeau / git rm all files
Created June 9, 2013 08:21
The command essentially says, "Use grep to find all the lines ouput by 'git status' that have the word 'deleted' in it, then grab the 3rd column on the line and run 'git rm' on it."
git rm `git status | grep deleted | awk '{print $3}'`
@julienbourdeau
julienbourdeau / gist:7288383
Created November 3, 2013 09:29
Remove yellow notification ribbon for wordpress update
add_action('admin_menu','wphidenag');
/**
* Remove notification ribbon for wordpress update
*
* @since 0.1.0
* @return void
*/
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
function home_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'home_page_menu_args' );
@julienbourdeau
julienbourdeau / get_wp_version.php
Created January 25, 2014 09:50
This PHP function will return your wordpress version. It uses grep to search in /wp-includes/version.php since the wordpress version is not stored in the database (only the db_version is).
function get_wp_version( $wp_folder ) {
preg_match("/'(.*?)'/", exec( "grep wp_version ".$wp_folder."/wp-includes/version.php" ), $matches);
return $matches[1];
}
@julienbourdeau
julienbourdeau / get_wordpress_last_version_number.php
Created January 26, 2014 14:25
This function will give you the last stable version of WordPress. It fetches the home page of wordpress.org and return the version number from the download buttons. Curl is required.
function get_wordpress_last_version_number() {
$link = `curl http://wordpress.org | grep '<a class="button download-button button-large"'`;
preg_match_all("/\<a.*href=\"(.*?)\".*?\>(.*)\<\/a\>+/", $link, $matches, PREG_SET_ORDER);
$last_version = str_replace("Download&nbsp;WordPress&nbsp;", '', $matches[0][2]);
return $last_version;
}