Mostrando las entradas con la etiqueta TipsAndTricks. Mostrar todas las entradas
Mostrando las entradas con la etiqueta TipsAndTricks. Mostrar todas las entradas

20130425

Loading modules in Zend Framework 2 for the lazy (only for Development purposes)

When you are developing modules for ZF2, you have to add your model name manually to the application.config.php file:

If you want to "load" your module without doing this (use this only for development!!! not in production!!!) you can hack the application.config.php to construct the array with the modules in your filesystem.

This will read your modules directory and fill the configuration array with them. Just a quick hack!

When deploying to production just add your production modules in the original config array and its ready to work.

Update:
As Manuel Stosic pointed out in the ZF2 group in facebook, this is not a good approach if you you need to preserve loading order. This is intended to be use in your own modules while developing (i use this approach with a dev partner), if you are going to use zfcUser, etc... just put those modules in the original config array.

20121127

tmux magic



tmux es una herramienta increíble para los que usamos terminales todo el día. Si usas screen, y no conoces tmux, ponete las pilas.

Estos son los shortcuts que uso en todo momento:
  • Mostrar ayuda
    • Ctrl-b ? 
  • Crear una ventana nueva: 
    • Ctrl-b c 
  • Moverte a la siguiente ventana
    • Ctrl-b n 
  • Detach tmux
    • Ctrl-b d 

  • Partir el panel verticalmente
    • Ctrl-b % 
  • Partir el panel horizontalmente
    • Ctrl-b " 
  • Moverse de panel
    • Ctrl-b flechas 
  • Matar el panel actual
    • Ctrl-b x
  • Mostrar el numero de panel 
    • Ctrl-b q 
  • Cambiarnos al siguiente panel
    • Ctrl-b o 
  • Scroll dentro del panel
    • Ctrl-b + [ luego simplemente usar las flechas arriba y abajo. q para salir de este modo. 
  • Cambiar tamaño del panel
    • Ctrl-b + Alt-flecha (5 lineas a la vez)
    • Ctrl-b + Ctrl-flecha

20120716

Resume scp transfer AAARRRGGGG

Had to upload a big file (300MB yeah its a big file for the kind of connection we have down here) to a remote server via scp. When it reached like 50% (1 hour after initiated) the connection drops!!! DAMN!

So after some research i found this :
rsync --partial --progress my_local_file.gz --rsh ssh user@server:my_remote_file.gz

yessss!!

If your ssh connection needs to use a port you can use
rsync --partial --progress my_local_file.gz --rsh 'ssh -pMY_PORT' user@server:my_remote_file.gz

20111024

How to merge selected files from a branch in git

I've being learning git for some time and i love it, i will start blogging some tips and tricks about it.

First you need to bookmark this: http://gitref.org/

Now, how to merge selected files from a branch to my master branch?
Move to the branch you want to "merge to", and:

20110201

How to create a .iso image of a cd on a Mac OsX

As OsX is Unix based we have a lot of tools that came in the standard installation of our Mac.
To create an ISO file we have to use the dd command in our terminal.

Insert your CD-ROM into your CD-ROM drive, and then fire up your Teminal (Applications/Utilites/Terminal). Run this command to get the name of the device: drutil status

diegoMB:~ diego$ drutil status
 Vendor   Product           Rev 
 HL-DT-ST DVDRW GWA4080MA   BE39

           Type: DVD-ROM              Name: /dev/disk1
       Sessions: 1                  Tracks: 1 
   Overwritable:   00:00:00         blocks:        0 /   0.00MB /   0.00MiB
     Space Free:   00:00:00         blocks:        0 /   0.00MB /   0.00MiB
     Space Used:  336:26:02         blocks:  1513952 /   3.10GB /   2.89GiB
    Writability: 
      Book Type: DVD-ROM (v1)

As we can see here our drives name is disk1. To use dd we need to umount the CD-ROM:

diskutil unmountDisk disk1

Now we can use dd to create the iso file:

dd if=/dev/disk1 of=my_file.iso

after the iso file is created you can mount the CD-ROM with:

diskutil mountDisk disk1

;)

20110128

Tips and Tricks - MYSQL - how to dump a database

So you want to backup your mysql database??? Mysql has many ways of doing it, i will explain the easier one: mysqldump.


Being strict, msqldump is not a "backup utility", it creates a script with  "CREATE TABLE" and "INSERT INTO" commands that you can run in your server to re-create your database.  mysqldump  is shipped with MYSQL so everybody should have it installed.

Using mysqldump command line is very straightforward, just type this in your command line or terminal (using your username and password):
mysqldump -u USERNAME -pPASSWORD OUR_DATABASE > filename.sql
This will give us a file (filename.sql) containing "CREATE TABLE" and "INSERT INTO" commands for OUR_DATABASE.
Some times you need to dump ALL your databases (you are moving you dev machine) in your MYSQL server:
mysqldump -u USERNAME -pPASSWORD --all-databases > filename.sql
If you are using MAMP (in macOS), your mysqldump binary is located in /Applications/MAMP/Library/bin/mysqldump.


There is a lot more options here in the official MYSQL documentation: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html


To restore our database, we have to we have to run this script in our MYSQL server. You can do it using any utility (phpmyadmin for instance) or jus (again) the command line:
mysql -u USERNAME -pPASSWORD DATABASE_NAME < filename.sql
So, good backup!! ;-)