Skip to content

Instantly share code, notes, and snippets.

View ccamara's full-sized avatar

Carlos Cámara ccamara

View GitHub Profile
@ccamara
ccamara / drush sql-connect.sh
Last active December 22, 2015 07:29
How to import and export a #sql file into a database using #drush #drupal #database #sql-cli
# Export database.
drush sql-dump > ~/my-sql-dump-file-name.sql
# Import database.
drush sql-cli < backup.sql
@ccamara
ccamara / yourmodule.module
Last active December 22, 2015 10:58
How to rename a #variable in #drupal
<?php
/**
* Renames a function
*/
function yourmodule_default_theme_settings() {
$new_variable_name = variable_get('old_variable_name', NULL); //Loads the variable to be renamed from drupal's variables table and assigns it to a new one.
variable_set('new_variable_name', $new_variable_name); //Stores $new_variable_name into drupal's variables table.
variable_del('old_variable_name'); //Deletes the old variable from drupal's variables table
}
@ccamara
ccamara / une-50-104-94.csl.xml
Last active December 23, 2015 04:28
#zotero #citation-style #UNE 50-104-94
<?xml version="1.0" encoding="utf-8"?>
<style class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="es_ES" xmlns="http://purl.org/net/xbiblio/csl">
<!-- This style was edited with the Visual CSL Editor (http://editor.citationstyles.org/visualEditor/) -->
<info>
<title>UNE 50-104-94</title>
<id>http://www.zotero.org/styles/une-50-104-94</id>
<link href="https://gist.github.com/ccamara/6580003" rel="self"/>
<link href="http://www.aenor.es/aenor/normas/normas/fichanorma.asp?tipo=N&amp;codigo=N0005073&amp;PDF=Si#.UjbzZKxTlhE" rel="documentation"/>
<author>
<name>Carlos Cámara</name>
@ccamara
ccamara / drush.sh
Last active December 25, 2015 16:29
Simple #drush command to find which modules implement a certain #hook #drupal
drush php-eval 'print_r(module_implements("hook_name"))'
@ccamara
ccamara / drush.commands.sh
Last active December 26, 2015 03:38
#drush commands for files and databases #syncronization
# Creates a copy of current database, deletes it and syncs it with dev
drush ard && drush sql-drop && drush sql-sync @site.dev @site.local
# Sync files
drush rsync @site.dev:%files @site.local:%files
@ccamara
ccamara / nth-element.css
Created November 11, 2013 09:53
#CSS nth-element pseudo selector
//More info: http://css-tricks.com/how-nth-child-works/
ul li:nth-child(3n+3) {
color: #ccc;
}
ul li:nth-child(5) {
color: #ccc;
}
@ccamara
ccamara / images.scss
Last active December 30, 2015 03:49
if we are using images in #compass there's no need of using a full url path to them. We can use image-url() instead #css #scss #sass
.background-image {
background: image-url('image-name.png'); //image-url() is defined in config.rb file so its prefered
}
@ccamara
ccamara / .bash_profile
Last active December 31, 2015 14:49 — forked from modcab/gist:8002917
Aguasingas' .bash_profile, with some git goodness.
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
# Autocompletion for git.
# http://code-worrier.com/blog/autocomplete-git/
# Download doing curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
@ccamara
ccamara / yourmodule.module
Last active January 3, 2016 02:39
Programatically creation of nodes in #Drupal7
<?php
/**
* Creates 'nodetype' pages.
*
* @param array $content
* Assoc array with machine names as key and node title.
*/
function yourmodule_create_nodetype($content) {
foreach ($content as $machine_name => $content_item) {
@ccamara
ccamara / template.php
Last active August 29, 2015 13:57 — forked from gionn/gist:2308768
Modifying #drupal #search-form
<?php
function theme_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['search_block_form']['#title'] = t('Search'); // Change the text on the label element
$form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
//$form['search_block_form']['#size'] = 40; // define size of the textfield
$form['search_block_form']['#default_value'] = t('Search'); // Set a default value for the textfield
//$form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
$form['actions']['submit']['#value'] = decode_entities('&#61442;'); // Uses a unicode code (eg. useful when using awesomefonts)
//$form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/immagini/btnCerca.png'); // Adds an image