Author Archives: Rene

Install Ionic on Linux (Linux mint 17.1 rebecca)

The first step is to install NodeJS

sudo apt-get install nodejs

The nodejs installed from the repositories use nodejs, since we may need node, we create a symlink so we can use both

sudo ln -s /usr/bin/nodejs /usr/bin/node

We also need to install ant

sudo apt-get install ant

Now we will install ionic and cordoba

sudo npm install -g cordova ionic

Change the ownership of tmp folder created by npm, replace user:group by your username group

sudo chown user:group ~/tmp/

You need android sdk installed, and to add this lines to the file ~/.bashrc, change /opt/android/sdk by the path your are installing

export ANDROID_HOME=/opt/android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Install gulp

sudo npm install -g gulp

if your are going to use SASS we should install ruby

sudo apt-get install ruby
sudo su -c "gem install sass"

Now you can start your proyect like

ionic start myApp blank
cd myApp/
ionic platform add android
ionic build android
ionic emulate android

Combine video files in linux

To combine mp4/M4V files in linux, we will use MP4Box, so first let’s install it

sudo apt-get install gpac

once installl on terminal let’s type

MP4Box -cat video1.mp4 -cat video2.mp4 -new newVideo.mp4

To combine avi files in linux we will use cat

cat video1.avi video2.avi >newVideo.avi

Now if you play the video, it will show the first video only, now let’s fix it usong mencoder

mencoder -forceidx -oac copy -ovc copy newVideo.avi -o newVideoFixed.avi

Install Eclipse PDT ( PHP Development Tools ) on Ubuntu

First lets install Eclipse

sudo apt-get install eclipse

Once installed open Eclipse then go to “Help->Install New Software”, from the options “Work with:” chose one, in my case the only one available was “Indigo Update Site – http://download.eclipse.org/releases/indigo/” once selected, click on search an select “PHP Development Tools (PDT) SDK Feature”

Smarty templates needs to be reload twice to see changes

I was having some issues with Smarty, when i updated a template i have to reload it twice to see my changes.

After some digging i realized that Zend OPcache was causing it.

So i jut disable Zend OPcache and now is working as it should.

just edit php.ini as root.

sudo nano /etc/php5/apache2/php.ini

Find the line where “opcache.enable=1” is and change it to 0, if it has a “;” remove it and that’s all

[opcache]
; Determines if Zend OPCache is enabled
opcache.enable=0

Then we simple reload apache

  1.  
  2. sudo /etc/init.d/apache2 restart
  3.  

Extract MP3 from SWF files on Linux (Ubuntu)

We will use a tool called swfextract contained on the package swftools, so first we will install it

  1.  
  2. sudo apt-get install swftools
  3.  

Once installed first we will see wich media we can extract from our swf file.

  1.  
  2. rene@rene-desktop:~/Music$ swfextract test.swf
  3. Objects in file test.swf:
  4.  [-i] 5 Shapes: ID(s) 7, 14, 22, 23, 28
  5.  [-j] 16 JPEGs: ID(s) 1-6, 11-13, 16-21, 27
  6.  [-s] 1 Sound: ID(s) 29
  7.  [-F] 1 Font: ID(s) 8
  8.  [-f] 1 Frame: ID(s) 0
  9.  [-m] 1 MP3 Soundstream
  10.  

Then just use the option between brackets and the ID the element you want to extract, in our example we will extract the sound with ID 29, but you can extract also images if you want

  1.  
  2. rene@rene-desktop:~/Music$ swfextract -s 29 test.swf -o test.mp3
  3.  

How to disable directory listing in apache?

First option is to edit the file /etc/apache2/sites-avalible/default (i am using ubuntu), then look for the following lines:

  1.  
  2. <Directory /var/www/>
  3.     Options Indexes FollowSymLinks MultiViews
  4.     AllowOverride None
  5.     Order allow,deny
  6.     allow from all
  7.     # This directive allows us to have apache2’s default start page
  8.     # in /apache2-default/, but still have / go to the right place
  9.     #RedirectMatch ^/$ /apache2-default/
  10. </Directory>
  11.  

And then take out the word Indexes, then your file will look like

  1.  
  2. <Directory /var/www/>
  3.     Options FollowSymLinks MultiViews
  4.     AllowOverride None
  5.     Order allow,deny
  6.     allow from all
  7.     # This directive allows us to have apache2’s default start page
  8.     # in /apache2-default/, but still have / go to the right place
  9.     #RedirectMatch ^/$ /apache2-default/
  10. </Directory>
  11.  

Finally we just reload apache

  1.  
  2. sudo /etc/init.d/apache2 restart
  3.  

If you want to use .htaccess, you have two options:

  1.  

This option will show a forbidden message:

Forbidden

  1.  

empty

Migrate Google Maps from V2 to V3

Google maps v2 has been deprecated since May 19, 2010 and will stop working on May 19, 2013, so here is a little guide on how to migrate.

On V3 we don’t need an API key, but it’s useful to keep track of your API calls (25,000 free), so to get the API key, log into https://code.google.com/apis/console/, click on services and activate google maps v3, once is done click on API access on the left, and go to Simple API at the very bottom, then click on edit allow referers, and set up like *.mysite.com/* that will allow all your subdomains and folders on your site.

Now that you have your API key, is time to replace the old URL, by the new one:

  1.  
  2. <!– V2 –>
  3.  
  4. "http://maps.google.com/maps?file=api&amp;v=2&amp;key=$yourKey"
  5.  
  6. <!– V3 –>
  7.  
  8. "https://maps.googleapis.com/maps/api/js?key=$youKeu&v=3&sensor=true""text/javascript"
  9.  
  10. <!– "sensor" is required an indicates if a device (like GPS) is used to determine the user’s location –>
  11.  

First get rid of the old unload function, is not needed anymore.

  1.  
  2. /* V2 */

Also get rid of old code used to load Vector Markup Language(VML) just needed for IE, VML has been deprecated on IE9 in favor Scalable Vector Graphic (SVG)

  1.  
  2. <!DOCTYPE html>
  3. "en" xmlns:v="urn:schemas-microsoft-com:vml>
  4. <head>
  5.         <style type="">
  6.         v\:* {
  7.         behavior:url(#default#VML);
  8.         }
  9.         </style>

Now lets load the map itself.

  • First take out GBrowserIsCompatible is not supported anymore.
  • Replace GMmap2 by google.maps.Map.
  • GLatLng has been replaced by google.maps.LatLng.
  • Now take out addControl, setMapType, now all of these are passed as an object when map is created
  • For V2 we use these map types G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP on V3 they have been replace by google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID ,google.maps.MapTypeId.TERRAIN
  1.  
  2. /* V2 */‘map’/*zoomLevel*/ );
  3.         map.setMapType( G_NORMAL_MAP );
  4.         //map.setMapType( G_SATELLITE_MAP );
  5.         //map.setMapType( G_HYBRID_MAP );
  6. }
  7.  
  8. /* V3 */‘map’ ), mapOptions);
  9.  

In V3 creating custom icons is a lot easier, instead of creating a special icon object now we can just pass image as url.

  1.  
  2. /* v2 */"http://labs.google.com/ridefinder/images/mm_20_red.png""http://labs.google.com/ridefinder/images/mm_20_shadow.png"/* v3 */‘Testing Icon’,
  3.         icon:‘icon.jpg’‘shadow.jpg’/* icon and shadow can be just a string containg  the image file url, for must complex icons just pass and object with all the properties
  4.   var image = {
  5.     url: ‘images/icon.png’,
  6.     size: new google.maps.Size(20, 32),
  7.     origin: new google.maps.Point(0,0),
  8.     anchor: new google.maps.Point(0, 32)
  9.   };
  10. more info: https://developers.google.com/maps/documentation/javascript/overlays?hl=en#ComplexIcons
  11. */
  12.  
  13.  

clearOverlays has been removed from v3, so if you want remove all your markers from your map, now you have to manually keep track your markers an remove them.

  1.  
  2. /* v2 */
  3. map.clearOverlays();
  4.  
  5. /* v3 */// Global array to store marker
  6. // store a reference to the marker each time you create one
  7.  
  8. // delete all the markers on the array

To create overlay on Google maps V3 now we have to use google.maps.Polyline inseatd of GPolyline.

  1.  
  2. /* V2 *//* V3 */"#FF0000",strokeOpacity: 1.0,strokeWeight: 2});
  3. area.setMap(map);
  4.  
  5.  

On google maps v3 is a lot easier to create custom controls, now we only create a div element an insert it on Google maps.

  1.  
  2. /* V2 */
  3.  
  4. /* we used to create the custom control like */"div"‘myId’‘<a href="save.php" ><img src="icon_save.gif" /></a>’/* we used to add to the map, after it was created */
  5.  
  6. /* v3 */"div"); /* To change look, just add some style like container.style.border=” */‘myId’‘<a href="save.php" ><img src="icon_save.gif" /></a>’; /* Custom HTML code */