Skip to content

Instantly share code, notes, and snippets.

View isholgueras's full-sized avatar

Ignacio Sánchez isholgueras

View GitHub Profile
@isholgueras
isholgueras / configure.sh
Last active December 16, 2015 05:09
Configure some things of Linux Mint DE
# Configurations of editor and bash
# as root, in /etc/vim/vimrc uncomment
syntax on
# as root, in /etc/bash.bashrc add after 'alias ls'
alias ll='ls -l --color=auto'
# Config for apache, php, mysql,...
cd /etc/apache2/mods-enabled/
ln -s ../mods-available/rewrite.load
@isholgueras
isholgueras / start.sh
Last active December 16, 2015 05:09
Tune up my Linux Mint DE
# Installing ia32-libs
apt-get install ia32-libs
# Installing LAMP
apt-get install mysql-server
apt-get install phpmyadmin
# Installing browsers
apt-get install chromium
@isholgueras
isholgueras / drubox.make
Created October 25, 2012 09:19
Drupal make from the scratch
; This file was auto-generated by drush make
core = 7.x
api = 2
projects[drupal][version] = "7.x"
; Profiles
; Please fill the following out. Type may be one of get, git, bzr or svn,
; and url is the url of the download.
projects[soc][download][type] = ""
@isholgueras
isholgueras / Config_Debian_Proxy.sh
Created October 23, 2012 08:05
Configuración de servidores Debian 6 después de instalar el SO si están detrás de proxy para hacer cosas turbias con Drupal
##### Meter en el .bashrc ################################
export PATH="$PATH:/usr/local/share/drush:/usr/local/bin"
export http_proxy=http://user:pass@IP:Port
export ftp_proxy=http://user:pass@IP:Port
## Recargar el fichero .bashrc sin tener que reiniciar la consola
source ~/.bashrc
##### Meter en el /etc/apt/sources.list ##################
# non free packages
deb http://ftp.fr.debian.org/debian/ squeeze non-free
@isholgueras
isholgueras / gist:3271864
Created August 6, 2012 07:14
Add fields of an entity to a form
<?php
$form['#prefix'] = '<div id="wrapper-form">';
$form['#suffix'] = '</div>';
$form['hidden_tipo'] = array(
'#type' => 'hidden',
'#value' => $tipo,
);
@isholgueras
isholgueras / add_file_to_node_D7.php
Created July 30, 2012 09:04
Add files tod node programatically in Drupal 7
<?php
$existing_filepath = "/home/nzcodarnoc/sites/default/files/imported/picture.jpg"
$new_filepath = "public://picture.jpg"
// Load a node
$node = node_load($nid, NULL, TRUE);
// Create the file object
$drupal_file = file_save_data(file_get_contents($existing_filepath), $new_filepath);
$drupal_file->alt = $node->title;
$drupal_file->title = $node->title;
// Assign the file object to the node, as an array
@isholgueras
isholgueras / group-by-with-pager.sql
Created July 17, 2012 13:56
Consulta que la pone dura. Posiblemente muy poco eficaz.
SELECT DISTINCT `title`
FROM `aggregator_item`
WHERE `title` IN
(SELECT *
FROM
(SELECT DISTINCT `title`
FROM {aggregator_item} ORDER BY `iid` desc limit $first_page, $last_page) as titles)
@isholgueras
isholgueras / gist:1993676
Created March 7, 2012 15:03
Transliteration in javascript
var normalize = (function() {
var from = "ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛãàáäâèéëêìíïîòóöôùúüûÑñÇç",
to = "AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc",
mapping = {};
for(var i = 0, j = from.length; i < j; i++ )
mapping[ from.charAt( i ) ] = to.charAt( i );
return function( str ) {
var ret = [];
for( var i = 0, j = str.length; i < j; i++ ) {
var c = str.charAt( i );