Skip to content

Instantly share code, notes, and snippets.

View gabssnake's full-sized avatar

gabssnake gabssnake

  • France
View GitHub Profile
@gabssnake
gabssnake / WP-media-library-stuff
Created February 16, 2013 18:13
functions to modify the behaviour of Media Library in Wordpress
// à mettre dans le fichier functions.php
// create a new category in Media Library for PDF file type
function modify_post_mime_types( $post_mime_types ) {
// select the mime type, here: 'application/pdf'
// then we define an array with the label values
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) );
@gabssnake
gabssnake / get images from html
Created March 19, 2013 10:08
get images from html using simple html DOM
<?php
require_once('libs/simple_html_dom.php');
$url = "http://gabrielvivas.com";
$html = file_get_html($url);
foreach($html->find('img') as $element) {
echo $element->src;
echo "<img src='$element->src'><br />";
@gabssnake
gabssnake / jquery-cdn
Last active December 15, 2015 03:49
jQuery by version from google CDN or local if not available
<!-- scripts -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery-1.7.2.min.js"><\/script>')</script>
<!-- /scripts -->
@gabssnake
gabssnake / box-model
Last active December 15, 2015 03:59
change box model to avoid conflicts
/* http://paulirish.com/2012/box-sizing-border-box-ftw/ */
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
@gabssnake
gabssnake / sublime-fetch
Last active December 15, 2015 05:59
sublime text fetch config
{
"files":
{
"html5shiv": "http://html5shiv.googlecode.com/svn/trunk/html5.js",
"jquery": "http://code.jquery.com/jquery.min.js",
"jquery ui": "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js",
"normalize": "http://necolas.github.com/normalize.css/2.1.1/normalize.css",
"prefixfree": "https://raw.github.com/LeaVerou/prefixfree/gh-pages/prefixfree.min.js",
"reset": "http://meyerweb.com/eric/tools/css/reset/reset.css",
"respond": "https://raw.github.com/scottjehl/Respond/master/respond.min.js"
@gabssnake
gabssnake / using git.txt
Last active May 13, 2016 06:00
commands git
// in folder, to setup repository
git init
// first time setup
git config --global color.ui true
git config --global user.name "name"
git config --global user.email "[email protected]"
@gabssnake
gabssnake / table_html.php
Created March 27, 2013 15:18
database to html table
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Table results</title>
<style>
body { margin: 20px; font: 1em/1.5 Geneva, sans-serif; }
table, td { border: 1px solid #bbb; border-collapse: collapse; }
td { padding: 5px 10px; } th { padding: 15px 10px; }
@gabssnake
gabssnake / composer.json
Created April 20, 2013 12:41 — forked from johnpbloch/composer.json
Install PhpUnit globally with Composer
{
"name": "phpunit",
"description": "PHPUnit Composer Package",
"require": {
"phpunit/phpunit": "3.7.*"
},
"config": {
"bin-dir": "/usr/local/bin/"
}
}
<?php
/*
By Marco Arment <[email protected]>.
This code is released in the public domain.
THERE IS ABSOLUTELY NO WARRANTY.
Usage example:
// In a registration or password-change form:
@gabssnake
gabssnake / wp-config.bits.php
Last active December 17, 2015 15:19
wordpress wp-config file bits to make life easier. not to use complete
<?php
// method A : uses uri string, like 'localhost'
// change settings if on local or remote
// lets you share the same config file in dev and prod
if (strpos($_SERVER['HTTP_HOST'], 'localhost') === false) {
// production
define('DB_NAME', 'database');