Wednesday, October 17, 2012

Lazy DHCP pool configuration on Cisco IOS

To add a DHCP server to your router you can add these lines on terminal configuration mode:

ip dhcp excluded-address <address start> <address end>
!
ip dhcp pool <pool name>
   network <network> <netmask>
   default-router <router IP>
   dns-server <DNS1> <DNS2>


i.e:

gw#config t
Enter configuration commands, one per line.  End with CNTL/Z.
gw(config)#ip dhcp excluded-address 10.2.17.1 10.2.17.15

gw(config)#ip dhcp pool MyOffice                  #network 10.2.17.0 255.255.255.0
             
#default-router 10.2.17.1
             
#dns-server 10.2.17.201 


Lazy batch resize of jpeg pictures using ImageMagick

The suite ImageMagick provides a tool called convert that will help us to do the trick.

-rwx------ 1 amartin amartin 1.3M Oct 17 14:00 IMAG0315.jpg
$ convert IMAG0315.jpg -density 36 -geometry 40x40% IMAG0315.jpeg
$ ls -lh IMAG0315.jpeg
-rw-r--r-- 1 amartin amartin 301K Oct 17 14:00 resize/IMAG0315.jpeg

If we want to reside a batch of files, whiting the same directory, we can use the following command to convert all the .jpg files to reduces .jpeg:

$ for file in `ls -1 *.jpg| cut -d '.' -f 1`; do convert $file.jpg -density 36 -geometry 40x40% $file.jpeg; done

Lazy install of flash player on Firefox and Chrome on Debian

To install the plugin we download it from Adobe and place it on our downloads folder. We will use the .tar.gz file format.

The file contains this structure:

$ tar -xvzf install_flash_player_11_linux_x86_64.tar.gz
libflashplayer.so
readme.txt
usr/
usr/bin/
usr/bin/flash-player-properties
usr/share/
usr/share/pixmaps/
usr/share/pixmaps/flash-player-properties.png
usr/share/kde4/
usr/share/kde4/services/
usr/share/kde4/services/kcm_adobe_flash_player.desktop
usr/share/applications/
usr/share/applications/flash-player-properties.desktop
usr/share/icons/
usr/share/icons/hicolor/
usr/share/icons/hicolor/32x32/
usr/share/icons/hicolor/32x32/apps/
usr/share/icons/hicolor/32x32/apps/flash-player-properties.png
usr/share/icons/hicolor/22x22/
usr/share/icons/hicolor/22x22/apps/
usr/share/icons/hicolor/22x22/apps/flash-player-properties.png
usr/share/icons/hicolor/24x24/
usr/share/icons/hicolor/24x24/apps/
usr/share/icons/hicolor/24x24/apps/flash-player-properties.png
usr/share/icons/hicolor/16x16/
usr/share/icons/hicolor/16x16/apps/
usr/share/icons/hicolor/16x16/apps/flash-player-properties.png
usr/share/icons/hicolor/48x48/
usr/share/icons/hicolor/48x48/apps/
usr/share/icons/hicolor/48x48/apps/flash-player-properties.png
usr/lib/
usr/lib/kde4/
usr/lib/kde4/kcm_adobe_flash_player.so
usr/lib64/
usr/lib64/kde4/
usr/lib64/kde4/kcm_adobe_flash_player.so


As root, we will excecute this command to install the files:

root# tar -xvzf install_flash_player_11_linux_x86_64.tar.gz -C /

The plugins must be located at /usr/lib/mozilla/plugins, we will check first if there's an old plugin to deactivate:

 /usr/lib/mozilla/plugins# ls -l
total 76
drwxr-xr-x 2 root root    69 Sep 25 12:42 ./
drwxr-xr-x 4 root root    37 Mar 18  2012 ../
lrwxrwxrwx 1 root root    34 Sep 25 12:42 flash-mozilla.so -> /etc/alternatives/flash-mozilla.so
lrwxrwxrwx 1 root root    37 Apr  9  2012 libnpjp2.so -> /usr/local/java/lib/amd64/libnpjp2.so
-rw-r--r-- 1 root root 75448 May 17  2011 skypebuttons.so



There's the bundled flash enabled... we will remove the symlink to disable it.

/usr/lib/mozilla/plugins# rm flash-mozilla.so
rm: remove symbolic link `flash-mozilla.so'? y



Then we copy over the plugin and delete trash from the installation:


/usr/lib/mozilla/plugins# mv /libflashplayer.so .
/usr/lib/mozilla/plugins# rm /readme.txt

And we confirm the permissions will allow our user to read the plugin:

 -rw-rw-r-- 1  501  501 19223376 Sep 29 12:13 libflashplayer.so

Now we can go to youtube.com and check out the latest videos to test our plugin.

Note: You might want to disable the PepperFlash version of Chrome and use only the one from adobe, here's how: