Skip to content

Instantly share code, notes, and snippets.

@isholgueras
isholgueras / configure.sh
Last active Dec 16, 2015
Configure some things of Linux Mint DE
View configure.sh
# 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 Dec 16, 2015
Tune up my Linux Mint DE
View start.sh
# 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 Oct 25, 2012
Drupal make from the scratch
View drubox.make
; 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 Oct 23, 2012
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
View Config_Debian_Proxy.sh
##### 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 Aug 6, 2012
Add fields of an entity to a form
View gist:3271864
<?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 Jul 30, 2012
Add files tod node programatically in Drupal 7
View add_file_to_node_D7.php
<?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 Jul 17, 2012
Consulta que la pone dura. Posiblemente muy poco eficaz.
View group-by-with-pager.sql
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 Mar 7, 2012
Transliteration in javascript
View gist:1993676
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 );