By alexmoreno, 20 December, 2012

Paginating the results in Drupal is incredible incredible easy. You just have to remember the two "magic functions":

 

  • pager_query($sql, $count);
  • theme('pager',10);

 

pager_query substitutes the typical db_query. Just something like that: 

 

  • // $resource = db_query($sql);  // -> old sentence without pager
  • $resource = pager_query($sql, $count); // -> pager

 

Then, we simple come back to the function that is called by our hook_menu, and we change:

By alexmoreno, 18 December, 2012

This days i'm discovering a new Linux flavour, which it remembers me a lot to another old friend: Gentoo. It has a really similar way of installing, it's very very customizable like Gentoo, and it's quite minimalistic. I'm speaking about Archlinux.

I have to say that this days I was thinking in changing from more than 3 or 4 idilic years with Debian/Ubuntu to a more customizable system. I really don't like the last change which Ubuntu has made on the Desktop, and I really loved when I had the possibility of using last releases of software when using Gentoo (5 or 6 years ago).

By alexmoreno, 17 December, 2012

Have you ever had a big (and when i say big I mean BIG) database which you need to import in a sql file?

If so, you'll probably have found this issue (or even you are having the problem just now and you are reading this looking for a solution):

ERROR 2013 (HY000): Lost connection to MySQL server

This uses to happen when trying to import the dump with the mysql -u command:

mysql -u root -p database < databasetoimport.sql

You can try to play with the my.ini settings, but a best secure solution is just to do the import from the mysql own console. How? easy.

By alexmoreno, 7 December, 2012

Very very easy in CentOS, just like it would be in a Debian system:

# yum install ruby -y

# yum install rubygems -y

# gem install capistrano

Really, it couldn't be easier. Next step, just having fun with Capistrano :-)

By alexmoreno, 7 December, 2012

There is a simple way of upgrading or executing a command immediatly after a push has been done.

We just need to go to the server repository (the one which is going to receive the push), and enter in hooks (.git/hooks or hooks if it's a bare repository).

Then, we rename the post-receive.sample to post-receive, without extension, and add this content:

echo "********************"

echo "Post receive hook: Updating User Staging"

echo "********************"

cd ../live

GIT_DIR='.git'

git pull origin master

By alexmoreno, 7 December, 2012

set :application, "bounty app"

#set :repository,  "localhost:/var/www/git/bountyrepo"

set :repository,  "localhost:/var/www/git/blessed"

set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

#

default_run_options[:pty] = true

set :use_sudo, false

#role :web, "localhost"                          # Your HTTP server, Apache/etc

By alexmoreno, 6 December, 2012

Contradictory? Yes, a bit, but you cannot allways choose the systems and architecture in which you are working.

solution? Runing apache under linux instead of runing wamp or some weird solutions like that (i don't like at all, sorry).

First, install vbox: https://www.virtualbox.org/

Second, download the iso of your preffered linux distro, and install it.

Third, when you machine is running, go to Devices>install guest additions.

Now you have to come back to your linux machine, and install a few things, kernel upgrades included (if needed).

 

By alexmoreno, 6 December, 2012

 

 

  • Configuring your network to start when booting: chkconfig network on (via http://nixcraft.com/centos-rhel-fedora/18643-centos-linux-6-2-eth0-network-service-not-starting-boot.html)
  • configuring services to start apache (or any other daemon) when system boots: chkconfig --level 2345 httpd on
  • ... more coming
  • Override Apache permissions problem: "You don't have permission to access ... on this server". Simply execute: setenforce 0

 

By alexmoreno, 4 December, 2012

This is the scenario. You installed vbox in your Mac, windows or Linux computer. Then you´ve installed Centos or Red Hat (or any other Red Hat flavor) in this virtual box.

Next step, installed httpd (apache2) and... even it is running and httpd status confirms it with a "running" message, it cannot be accesible from your host machine.

The problem is on iptables. Red Hat by default denies access to this machine from other (external) machines. Solution? Very easy, open iptables file:

vim /etc/sysconfig/iptables

(vim is my favourite editor for a loooong long time)

By alexmoreno, 30 November, 2012

 

IN BLESSED

mkdir gitlab/blessedrepo

cd gitlab/blessedrepo

git init

 

Creating new files:

vim README

adding:

git add .

git commit -m "first file in blessed repository"

git push

 

IN DEVELOPERS

mkdir developer2

cd developer2

git clone /Users/air/gitlab/blessedrepo

ls

blessedrepo

ls blessedrepo/

README

cd blessedrepo

vim fileindev2.html

git add .

 

 

MacBook-Air-de-Air:blessedrepo air$ git commit -m "added file by developer2"