Skip to content

Instantly share code, notes, and snippets.

@Cezarion
Cezarion / less
Created February 5, 2013 20:01
Mixin column
@mixin makeColumn($columns: 1, $offset: 0, $makeColumnWidth: $gridColumnWidth) {
float: left;
margin-left: ($makeColumnWidth * $offset) + ($gridGutterWidth * ($offset - 1)) + ($gridGutterWidth * 2);
width: ($makeColumnWidth * $columns) + ($gridGutterWidth * ($columns - 1));
}
@Cezarion
Cezarion / Clean git repository
Last active December 13, 2015 22:39
Git > suppression des fichiers ingnorésdu dépôt
git rm -r --cached .
This removes everything from the index, then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"
@Cezarion
Cezarion / EntityFiledQuery debug
Last active December 14, 2015 12:49
Drupal debuging EntityFieldQuery
/* Require Devel module */
Database::startLog('node_load_debug');
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
...
->execute;
dpm(Database::getLog('node_load_debug'));
@Cezarion
Cezarion / gist:5301645
Created April 3, 2013 14:21
Wrapper js drupal
(function ($, Drupal, window, document, undefined) {
$(document).ready(startApp);
})(jQuery, Drupal, this);
<?php
/**
* Class Chainable
* Wrapper for convenient chaining methods
*
* @author Stefano Azzolini <lastguest@gmail.com>
*/
class Chainable {
private $instance = null;

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@Cezarion
Cezarion / gist:5465770
Last active December 16, 2015 16:49
Git add options
git add -A stages All
git add . stages new and modified, without deleted
git add -u stages modified and deleted, without new
cf : http://stackoverflow.com/questions/572549/difference-of-git-add-a-and-git-add
<?php
function roots_root_relative_url($input) {
$output = preg_replace_callback(
'!(https?://[^/|"]+)([^"]+)?!',
create_function(
'$matches',
// if full URL is site_url, return a slash for relative root
'if (isset($matches[0]) && $matches[0] === site_url()) { return "/";' .
// if domain is equal to site_url, then make URL relative
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
<?php
/**
* @package WordPress
* @subpackage WP-Skeleton
*/
// REMOVE SOME HEADER OUTPUT
function Wps_remove_header_info() {
remove_action('wp_head', 'rsd_link');