Thursday, September 25, 2014

Adding MIME Types for Fonts in EC2 using Python



By Default EC2 does not include mime types for fonts except svg in  /etc/mime.types

So need to add them to the system

Below code example tells you how to do that in python

import mimetypes
..
mimetypes.init()
mimetypes.add_type('font/ttf', '.ttf')
mimetypes.add_type('font/opentype', '.otf')
mimetypes.add_type('application/font-woff', '.woff')
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')

For more Information please visit https://docs.python.org/2/library/mimetypes.html

Thursday, September 11, 2014

CSV format from MySQL View



With the latest Technologies and Tools available its very easy to export data select from database to CSV format.

But most of them are not able to to configure as you want.

Here is a sample for MySql for Student Data from client_marks_view View


set @given_from:='2014-01-01';
set @given_to:='2014-06-01';

SELECT CONCAT(' Students Marks Summary for the period ',`given_from`(), ' - ',`given_to`()) AS `Students Marks Summary`
UNION ALL
SELECT '' AS ``
UNION ALL
SELECT CONCAT('"Student Name','",','"Total Attendance','",','"Total Marks','"') AS `CONCAT('"Student','",','"Resource Name','",','"Total Attendance','",','"Total Marks')`
UNION ALL
(SELECT CONCAT('"',ifnull(`a`.`studnet_name`,''),'","',ifnull(`a`.`total_attendance`,' '),'","$',round(ifnull(`a`.`total_marks`,0),2),'",') AS `CONCAT('"',
IFNULL(a.student_name, ""),
'","',
IFNULL(a.total_attendance," "),
'","',
IFNULL(a.total_marks, "")
ROUN` from `student_marks_view` `a`) ;


How to create a direct view from that

CREATE OR REPLACE VIEW students_view
AS

   SELECT CONCAT(' Student Marks Summary for the period ',`given_from`(), ' - ',`given_to`()), ',,,,,,'
     UNION ALL
   SELECT "", "" FROM DUAL
     UNION ALL
   SELECT CONCAT('"Student Name','",','"Total Attendance','",','"Total Marks'),'",,,,,,'
     UNION ALL
 
   (SELECT CONCAT('"',
IFNULL(a.student_name, ""),
'","',
IFNULL(a.total_attendance," "),
'","$',
ROUND(IFNULL(a.total_marks, 0),2),
'",'), ',,,,,,' 

FROM student_marks_view  AS a )

Wednesday, September 3, 2014

Basic Web Testing with Selenium WebDriver With Ruby 2.0.0



1. Install Node and Ruby on windows

D:\Selinium Tests\1>ruby -v
ruby 2.0.0p481 (2014-05-08) [x64-mingw32]

2. Install Selinium Web Driver 
gem install selenium-webdriver

If no web driver installed you will get bellow error on windows
C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- selenium-webdriver (LoadError)
        from C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from 1.rb:2:in `<main>'


3. Install Chrome & IEDriverServer Driver
Copy the chromedriver.exe to  C:/Ruby200-x64/bin or any classpath location
Copy the IEDriverServer.exe to   C:/Ruby200-x64/bin or any classpath location

4. Install HTTP server locally and create a folder name ruby under htdocs
5. Copy All the *.rb and *.html files to above folder in (4)
6. Execute each ruby file as 
>ruby xxx.rb

Download the example file from Examples