Noe Alonso Blog | bitácora de viaje entre datos y recordatorios

COMMAND NOT FOUND WITH A NODE MODULE (NPM) SOLUTION

To give you a little context: I ran the following command for installing Gulp (a node package module) globally: npm install -g gulp

The installation succeed but when I ran this gulp command in the command line I got a "gulp: command not found" error. It appeared that it installed “Gulp” in my local folder that is /Users/YOURUSERNAME/node_modules and not in the global NPM folder.

You can check this by running this command: npm root or npm root -g, which was returning my personal directory /Users/YOURUSERNAME/node_modules and not the expected /usr/local/lib/node_modules.

After some trial & error, I finally found the solution. You have to change the “npm config prefix” like so: npm config set prefix /usr/local

Then when I re-ran npm root -g, I got the correct root folder: /usr/local/lib/node_modules

When I reinstalled Gulp globally (with the -g param) it finally worked and appeared that it was now correctly installed in the global NPM folder. Yeay!

 

VIA>>

No se encontró la extensión mcrypt.

Al instalar LAMP salio que no se encontró la exención MCRYPT aquí la solución útil y sencilla sin tocar nada de los archivos de configuración de  PHP:

 DOS | 
 
 copy code |
?

  1. // instalamos el php5-mcrypt
  2. sudo apt-get install php5-mcrypt
  3. // crea un enlace simbolico  de la extencion a los modulos de PHP
  4. sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
  5. // damos de alta o registraremos mcrypt
  6. sudo php5enmod mcrypt
  7. // reiniciamos el server de Apache
  8. sudo service apache2 restart

Añadir tu usuario de linux al grupo www-data

Cuando instalo un LAMP en algún Linux suelo añadir mi usuario (user) al grupo www-data, cambio el directorio www al grupo www-data y le doy permisos de escritura a los usuarios del grupo para garantizarme que no vaya a tener problemas de permisos y cosas raras:

 DOS | 
 
 copy code |
?

  1. sudo usermod -a -G www-data user
  2. sudo chown www-data. /var/www/ -R
  3. sudo chmod g+rw /var/www -R
 Apache configuration | 
 
 copy code |
?

Si  no funciona, solo reinicia.

salu2

via >> 

Reverting to a Freshly Installed State

Overview

Sublime Text can be reverted to a freshly installed state by removing your data folder. Depending on your operating system, this folder is located in:

OS X: ~/Library/Application Support/Sublime Text 3
Windows: %APPDATA%\Sublime Text 3
Linux: ~/.config/sublime-text-3
To revert to a freshly installed state, you can:

Exit Sublime Text
Delete (or move) the data folder, as listed above
Start Sublime Text
When restarted, a fresh data folder will be created, just as it was the first time you ran Sublime Text. Keep in mind that this will also remove all of your settings and packages.

OS X Lion

In Lion, the ~/Library folder is hidden by default. To navigate there, select the Go/Go to Folder menu item in Finder, and type in ~/Library.

Windows

In Windows, cache files are stored in a separate location, %LOCALAPPDATA%\Sublime Text 3, to improve performance with roaming profiles.

[fix] Permalinks not working in Apache2 Ubuntu

How to get WordPress permalinks / pretty links to work in Ubuntu 10.10 with Apache2:

By the way, this should be the same in Ubuntu 10.04 as well, but I haven’t actually tested it there as well.

1. Manually create a “.htaccess” file and save it in your main WordPress directory. (This is the one with the wp-admin, wp-includes, and wp-content folders.)

2. Go to the Ubuntu terminal and type:

sudo chown -v :www-data "/enterYourFilePathHere/.htaccess"

You should see a line printed saying that the (group) file ownership has been changed to www-data (Apache2).

3. Give Apache2 write access to the file:

sudo chmod -v 664 "/enterYourFilePathHere/.htaccess"

You should see a line printed saying that the mode of the file has been retained.

4. Next, we have to allow WordPress to write to the .htaccess file by enabling mod_write in the Apache2 server. Type the following in the terminal:

sudo a2enmod rewrite

You should see a line printed saying that it is enabling mod rewrite and reminding you to restart the web server

5. So let’s do that. Restart the web server, Apache2, for the changes to take effect by typing:

sudo /etc/init.d/apache2 restart

We are all done with the command line prompt; you can close the command line window now.

5. Go into your WordPress admin panel (i.e. http://yourDomain/wp-admin). Go to the Settings –> Permalinks and select the permalink format of your choice. Hit the “Save Changes” button.

6. DONE! Go to your site and check any page (other than your homepage) to ascertain that everything is working as expected.

Hope this helps someone. Leave me a comment below.

[[additional step]]

in case you are on ubuntu edit the file /etc/apache2/apache2.conf (here we have an example of/var/www)

 DOS | 
 
 copy code |
?

  1. <Directory /var/www/>
  2.         Options Indexes FollowSymLinks
  3.         AllowOverride None
  4.         Require all granted
  5. </Directory>

and change it to;

 DOS | 
 
 copy code |
?

  1. <Directory /var/www/>
  2.         Options Indexes FollowSymLinks
  3.         AllowOverride All
  4.         Require all granted
  5. </Directory>

then

 DOS | 
 
 copy code |
?

  1. sudo service apache2 restart

this should work :)

cheers!

via wordpress.org and stackoverflow

Respaldo parcial de tablas MySQL

En ocasiones ocupamos realizar un respaldo de alguna tabla gigante y en definitiva no es opción hacer un respaldo completo, para llevar acabo dicha tarea he pensado en una solución alternativa a mysqldump y es la siguiente:

Crear una tabla con diferente nombre pero misma estructura que la tabla a respaldar, cuando este lista solo realizamos la siguiente consulta:

 SQL | 
 
 copy code |
?

  1. INSERT INTO tbl_espejo (campo1, campo2) SELECT campo1, campo2 FROM tbl_original

y si queremos podemos hacer mas un respaldo parcial mas filtrado podemos incluir la lcausual where de la siguiente manera:

 SQL | 
 
 copy code |
?

  1. INSERT INTO tbl_espejo (campo1, campo2) SELECT campo1, campo2 FROM tbl_original where campoN= 'valor' and campoN2 = 3 order by campoN3 desc

salu2

How to disable notice and warning in PHP.ini file

Several times, I have  some warnings or Notices from my web php apps then I find a solution to fix this issue.

Sometime if you are working on some php code and fed up of Warnings or Notices in the browser then easy way out is to disable the settings in PHP.ini file. This is a configuration file which is loaded each time you start your PHP+Apache. It was doing everything it was supposed to but at the same time it was throwing errors and warning which doesn’t make sense and were harmful for the application.

Here is the method to change the settings in PHP.ini file:

Open PH.ini file.

In this file search for the phrase “ error_reporting = E_ALL” ,[without inverted commas]

Here replace this with “error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING “

(Show all errors, except for notices and coding standards warnings)

Make sure you change the real enabled part of this , there are certain other examples given in the file.

Restart your PHP + Apache

Now, no warnings and messages will appear in the browser.

via > zoomtemplate

How to merge two mysql query results into one array?

You can use UNION operator to merge the result-set of two or more SELECT statements into one array.
The default behavior for UNION is that duplicate rows are removed from the result. UNION ALL does not remove duplicate.

There are few things need to be kept in mind.

A. SELECT statement within the UNION must have the same number of columns.
B. The field should have similar data types.
C. Fields in each SELECT statement must be in the same order if not make them.
D. If column have diffrent name make column another name by using an alias with “AS” kewords as given in the example

SELECT column1 AS alias_name FROM table

Here is the full example of UNION.

 PHP | 
 
 copy code |
?

  1.   $select_btemp_1 = "SELECT * FROM table1 WHERE enable='1' AND aid='1'";
  2.    $select_btemp_2 = "SELECT * FROM table1 WHERE enable='1' AND user_id='$user_id' ORDER BY  aid ASC";
  3.    $select_btemp =  $select_btemp_1." ".UNION." ".$select_btemp_2;
  4.    $btemp_query = mysql_query($select_btemp);
  5.    $btemp_count = mysql_num_rows($btemp_query);
  6.    if($btemp_count > 0)
  7.    {
  8. while($row_images = mysql_fetch_array($btemp_query))
  9. {
  10. echo $row_images[temp_desc];
  11. }
  12.    }

 

VIA>>