Tuesday, March 25, 2014

Cloud Buzz: IaaS, PaaS, SaaS

I am going to try and provide simple analogies that will hopefully help you make sense of the terminologies associated with Cloud technologies and make them ‘stick’.
The Cloud my friends, is nothing but the Internet. Different vendors  set up the Infrastructure, Platform and Software and make them available to us from remote locations over the Internet so that we as consumers do not have to go through the process of installing all these on our own machines. All we need to do is


Cloud Buzz: IaaS, PaaS, SaaS

  • Hook up to the Internet
  • Start using the vendor specific services (for some of the services, one might need to register, log on etc etc.)
  • Think Gmail !

Cloud Model

Generally speaking, the Cloud model is based upon 3 different layers/stacks
  • Infrastructure As A Service (IaaS) – Deals with hardware/basic infrastructure
  • Platform As A Service (PaaS) – Facilitates tooling support required for development and deployment of ‘cloud’ based applications
  • Software As A Service (SaaS) – A ready-to-consume’application’ available on-demand
cloudcomputestackimage1

My very own definition of the Cloud (not perfect.. but I tried !)

“The Cloud is composed of computing layers which are ‘inter dependent’ modules which support the notion of delivering software as an on-demand service (SaaS) which is propelled by rapid development+deployment services rendered by the PaaS layer which in turn feeds upon the IaaS layer to provide the basic infrastructure services such as virtualization, servers, network, storage, scalability etc”

Dissecting the Cloud

Infrastructure As A Service (IaaS)

Think of IaaS as Your Laptop/Desktop!
It has the following components
  • Storage (hard disk)
  • Networking capabilities (network card)
  • Operating System (Windows, Linux, MacOSX… whatever)
A laptop provides basic ‘computing infrastructure’ to its consumer. IaaS setup operates on similar lines:
  • Provides ‘resources’ as an on-demand service
  • What kind of resources? Servers, storage, network and underlying operating system
  • IaaS is meant for multiple users who leverage a single piece of hardware.
  • Just like you can enhance the computing capacity of your laptop/desktop (by adding more RAM, additional physical storage etc) an IaaS setup can also be scaled to meet the demands of the consumers.
  • Companies want to concentrate more on their core business and services rather than go through the hassles of setting up huge data centers and maintain them! IaaS to the rescue. . . . 

Examples

I have to mention Amazon EC2 !

Platform As A Service (PaaS)

What do you need in order to ‘develop’ applications using your laptop/desktop? e.g. Java EE web applications
You need a basic ‘platform’ to be able to perform your activities
  • IDE (Eclipse, NetBeans etc)
  • Java EE runtime i.e. a Java EE Application Server
  • A Database for persistence (Oracle DB etc)
This is not an exhaustive list, but I hope you get the idea. Now the important analogy – PaaS itself is not very different from this
A PaaS vendor/provider
  • Delivers ‘software creation/deployment platform’ over the web
  • Provides a homogeneous environment and tools to support the entire software development cycle from development to testing, hosting as well as maintaining applications
  • Abstracts the underlying complexities from the end user by exposing interactive web interfaces and even CLI tools
  • Based on Multi-Tenant architecture wherein multiple users make use of the platform concurrently with each user having a unique working environment of his own

Examples

Software As A Service (SaaS)

Well up until now, you got a super cool computing machine (your infrastructure), you are armed with the latest development tools (your platform). What do you do? Build and deliver awesome software ! What else?
So you have made that dream web app. Now you want to be rich? Of course…. What would you do in order to deliver your awesome web application from your laptop to consumers over the Internet?
  • Sign up fora domain
  • Configure your web/front end servers
  • Publish you app!
  • You need to be careful about up time and availability of you application though.
  • Check on your machine, servers etc
SaaS makes this a breeze (for a consumer and a developer.
  • Consuming on demand services over the Internet – as an end user
  • No hassles of installing software on your systems, servers – get online.. that’s it!
  • Forget about patching and upgrading your software – that is a major relief!
  • Delivering software solutions over the Internet – from a developer perspective
  • Builds on the services delivered by the IaaS layers and sometimes the PaaS layer (depending upon whether or not the software is actually developed on the cloud)
  • SaaS vendors come up with Web APIs for other applications and systems to be able to integrate seamlessly — think REST APIs

Examples

Let me make this easy on myself…. Salesforce . . . One of the biggest players in the SaaS arena. Enough said!
Alright then. I hope you have a reasonable idea of what the Cloud is…. This by no means was supposed to be a whitepaper on Cloud Computing or something. Just enough for you to get an idea and start digging deeper!

HTML, CSS, PSD and More: 18 Free Design Resources from February/March 2014

We are back with another round of HTML, CSS and PSD templates as well as some UI interfaces. Frequent readers know that we collect the best new entries to the scene on a regular basis. So, keep yourself updated with the freshest templates available. Whether you take the following pieces as an inspiration or plainly use them for your next project is completely up to you. They will certainly prove useful in both ways.
One important information before you read on: All the following elements are freely usable, though some will require a registration to download.

Section #1: HTML/CSS Templates

Calm: Flat Grid Portfolio Template

Calm HTML template
Created by: W3layouts
Remarkable: Flat design, grid layout style.

Motion: Flat Responsive Personal Portfolio Template

motion HTML template
Created by: W3layouts
Remarkable: Good color scheme, responsive design

Leo Images: Clean HTML Template for Photography Websites

Leo Images HTML template
Created by: W3layouts
Remarkable: Minimal design

Steam: Flat Responsive Music Web Template

Steam HTML template
Created by: W3layouts
Remarkable: Built with HTML5 and CSS3, fully responsive, multiple page templates

ZGenesis: Responsive HTML5 Theme

ZGenesis HTML template
Created by: zerothemedotcom
Remarkable: Cross browser, responsive layout, multiple pages

ZValencia: Responsive Theme Created with HTML5

ZValencia HTML template
Created by: zerothemedotcom
Remarkable: Multiple page templates, Cross browser, 2 layout options

Section #2: PSD Templates

Multipurpose Flat Table: InDesign Flat Pricing Table

Multipurpose Flat Indesign table
Created by: Erick Ragas
Remarkable: Flat design, print ready

Portfolio Theme: PSD Flat Grid Template

Portfolio PSD theme
Created by: sm-artists
Remarkable: Flat design, multiple pages

Oceanarium: PSD Landing Page

Oceanarium PSD template
Created by: Dalechuck Inna
Remarkable: One page template, flat iOS-like design

Dribbblr for iPad: Concept Template for an iPad App (PSD)

PSD Dribbblr for iPad
Created by: Alex Botic
Remarkable: One page template, carefully ordered layers

Dark Analytics Dashboard: Flat PSD Admin Panel for Analytics Apps

Dark Analytics dashboard PSD
Created by: Davide Pacilio
Remarkable: One page template, carefully ordered layers

iOS Splash: Template to Create Splash Screens for iOS Devices

Multipurpose PSD template
Created by: David Lillo
Remarkable: Easily usable file

Flat Multipurpose Template: PSD Landing Page with a Simple Style

Flat-Multipurpose-Template
Created by: Agile Infoways
Remarkable: Minimal design, one page template

Bar Graph Template: 2 Templates for Statistical Data Showcases

Bar Graph PSD template
Created by: FreebiesGallery
Remarkable: 2 color themes, carefully ordered layers

Section #3: UI Interfaces

Flat UI Widgets: Simple Data Widgets for Social Apps

Flat UI widgets
Created by: Mihnea Zamfir
Remarkable: Flat design, carefully ordered layers

Wireframe & UI Kit: Complete UI That Serves as a Wireframe

Wireframe & UI kit
Created by: Chris Rowe Jr
Remarkable: Visual cues (more than boxes with labels)

Robotic UI: Music Interface Template in Flat Futuristic Style

Robotic UI
Created by: Sonle
Remarkable: Several elements for desktop sites development

Aurora: iOS7 Alternate Concept (PSD)

Aurora iOS7 template
Created by: Vasil Enev
Remarkable: Oval icons in iOS7 style

Monday, March 24, 2014

Case filed against Modi, Amit Shah over 'Har Har' slogan

Lucknow: A case has been filed in a Varanasi court against BJP's prime ministerial candidate Narendra Modi, party general secretary Amit Shah and city mayor Ram Gopal Mohale over a slogan hailing Modi.

The case was filed by a lawyer in the court of the chief judicial magistrate (CJM) and alleges the "Har har Modi, ghar ghar Modi" slogan, which likens Modi to Lord Shiva, hurt his religious sentiments.

Petitioner Manoj Dubey said this slogan was coined to garner electoral gains during the Lok Sabha election in which the Gujarat chief minister is a contestant from Varanasi.

"I had petitioned the Election Commission also on the matter but no action was taken. I have now decided to take the matter to the court," Dubey told IANS Tuesday.

The court has sought a detailed report from the police over the issue.

The Bharatiya Janta Party had come under fire for using the slogan.

The party later distanced itself from the controversial slogan.

The party has now coined a new slogan -- "Dil dil Modi, ghar ghar Modi, kan kan Modi" (every heart, house and particle has Modi) for the local campaign of the party in Varanasi.

The next hearing of the case has been fixed for April 3.

Syria's Aleppo bears brunt of fight over fragmented Syria

ALEPPO, Syria (Reuters) - Aleppo is central to President Bashar al-Assad's goal of rescuing a viable state from the ruins of Syria; hence the grim message from his forces to its residents, that one equals five.

"We told them every shell (they fire) equals five barrel bombs," said Amar, a local policeman in the city, who argued that any civilians hit by the highly destructive improvised weapons deserved it for tolerating "terrorists".

"They didn't believe us and they continued launching shells, so the army responded with a pounding of barrel bombs."

Almost two years after rebels grabbed half of Syria's biggest city, they are on the defensive, with government forces advancing on three sides.

If Assad can retake Aleppo, he would be back in control of Syria's three largest cities, a bulwark for the Mediterranean provinces of Latakia and Tartous which form the heartland of his minority Alawite sect.

With the rest of the country split between autonomous Kurdish areas in the northeast and a range of Sunni Islamist rebel groups in the east, Syria's fragmentation could become irreversible.

The battle for Aleppo ebbs and flows - the rebels regained some high ground at the weekend - but Assad's forces struck back on Monday, dropping barrel bombs from helicopters on several rebel-held districts in the east.

The military ramped up its offensive in December, pummeling civilian areas with scores of barrel bombs, made from oil drums packed with explosives and shrapnel that cause massive and indiscriminate destruction.

In six weeks, they killed more than 700 people, mostly civilians, and forced tens of thousands more from their homes.

Khadija and her six children fled their home in the eastern district of Al-Sukkari when it was struck by a barrel bomb in late January.

They passed through the "death crossing" - a 100-metre stretch of sniper territory between Aleppo's eastern and western halves - hoping for a better life on the other side.

"When we reached the government side, the soldiers viciously beat us with a stick," she said.

Denied a residency permit to live in government-held territory, they sleep wherever they find shelter, moving every few days to evade security forces.

"COLLECTIVE PUNISHMENT"

New York-based Human Rights Watch said on Monday that satellite images showed 340 sites hit in opposition-controlled Aleppo between early November and late February. The damage appeared "strongly consistent with the detonation of highly explosive unguided bombs."

Western powers have condemned the use of barrel bombs as a war crime, but they continue to fall nearly every day in Aleppo and other parts of Syria where more than 140,000 people have died in three years of war.

The bombardment has uprooted thousands of people, some of whom fled to neighbouring Turkey while others, like Khadija, moved to government-controlled areas of Aleppo, where they have been forced to camp on the street and in parks and schools.

Abeer, an Aleppo-based researcher with the Jesuit Refugee Service, said Assad's forces were even bombing government-held districts once controlled by rebels as part of what she called a government "policy of collective punishment".

"They continue to strike neighbourhoods with barrel bombs to punish their residents for embracing the opposition fighters when they entered," she told Reuters.

Some of those forced to flee live on the streets, often with only a flimsy tarpaulin for shelter. Others have sought cover in school buildings, packed into classrooms by the dozen even as pupils attend lessons, stirring social tension in a city once reknown for its religious and political diversity.

"Aleppo is enduring a dreadful type of social fragmentation because of the hatred between its residents, and the increased number of displaced people has deepened this fragmentation," Abeer said.

Abdel Jabar and his family escaped a barrel bomb attack in January, but have since lived as outcasts in a public garden on the other side of the city.

Security forces forbade them from living with relatives in a government-held district, he said. "The authorities impose residency restrictions on us as if we are strangers in our own country."

Iconion: Converts Icon Fonts To Icon Files

Icon fonts are quickly becoming a web design trend and there is a good reason for that. Instead of working with a load of files in different resolutions or large sprites to be controlled by CSS, we simply embed a special font. Creating icons with icon fonts gives designers the ability to manipulate the icons with CSS, and it can improve load times by up to 15%, and because they're vector in nature, they're infinitely scalable, while still being smaller in size than an image sprite.



But what if you need to use these icons in a desktop or mobile application? Or create a website favicon or multi-colored icon?
The only answer is old-fashioned image icons in png or ico format. Iconion allows you to convert any icon font into fantastic-looking png icons by adding color, shadow, background, gradient, stroke and many other fancy elements.


What you can do with Iconion?

With Iconion you can select icons from Font Awesome, Entypo, Linecons, Typeicons and any other symbol fonts you like. You can select any size, without having to worry about the size, 8px or 1024px, the images will be of the same crisp quality. Add style: Icon color, Icon shadow and Icon long shadow, Gradient, Stroke, Icon rotate, Background, Background color, Background gradient, Background shadow, Background border, Rotate. Or just apply one of awesome pre-made templates.
Your final result can be save as png, bmp, jpeg or ico files.


How to use Iconion

Iconion have an interface divided into 3 sections. The left part of the screen lets you select icons from the popular Typeicons, Linecons, Font Awesome and Entypo. But the developer promise to launch a future version that will allow users to work with any symbol font.



The right part which is the style section, allows you to select a style for your icons. There are a lot of fancy styles to choose from. Also, you can easily customize icon and background color, border, size, shadow, gradient and many other parameters. All the pre-made styles can be changed to your liking from an editor below the styles window.

Now, the middle part which is the "Preview & Save" section allows you to control the look of your icon by changing the "Icon" or "Background" properties in their respective tabs. After you are done with the editing, icons can be saved as images after a click on Save Icon button.


Licenses

Iconion offers two licenses. One entitles you to use Iconion for free for non-commercial purposes. And the other one requires you to have a commercial license if you are going to use Iconion in a profit-oriented project.

PDF Generation in Rails

The ability to download data in pdf format is a common requirement that you will encounter when building web applications. There are different ways that this can be achieved in Rails. We are going to look at the two major ways used to generate pdf documents: with Ruby using a DSL for defining and styling the documents, or by using a library that will convert your HTML to PDF.
There are three popular gems we’ll focus on today:
  • Prawn (which uses the DSL method)
  • PDFKit (which uses a generator)
  • Wicked PDF (also, uses a generator).

HTML to PDF or Ruby Generation?

The answer to this usually depends on preference and project requirements. HTML to PDF can be faster, especially if you already have a view that displays the content you want in your PDF. In this case, you won’t have to write that much more code to generate a PDF file. However, this method can make it harder to control the layout of the document, especially when dealing with multi-page documents. Content will tend to be cut off and split between pages. It’s true that, with some CSS styling, you can have some control over the page breaks. However, for more complicated PDF documents that span several pages and contain variable length content, headers and footers, it will be difficult to control how each page is rendered. In these cases, it might make more sense to use Prawn.
Using a library like Prawn, you have to do all the content styling and positioning on your own using Prawn’s DSL. The advantage here is more control over how things are displayed and where pages break.
We are going to generate a PDF file for the webpage shown below which contains some static text, an image and a table of some database records.
pdf_webpage_image

Prawn

To use Prawn, include the gem in your Gemfile and run bundle install
1
gem 'prawn'
Register the PDF mime type in the config/initializers/mime_types.rb file.
1
Mime::Type.register "application/pdf", :pdf
Now we need to set up the controller action to respond to requests for PDF format.
For my Products controller, I have an index action which I’m going to modify as shown.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class ProductsController < ApplicationController
  def index
    @products = Product.all
    respond_to do |format|
      format.html
      format.pdf do
        pdf = Prawn::Document.new
        send_data pdf.render, filename: 'report.pdf', type: 'application/pdf'
      end
    end
  end
end
The above will generate a PDF file with no content when .pdf is appended to the end of the particular url. In my case http://localhost:3000/products.pdf.
To separate out the pdf generation code from the controller, I created an app/pdfs directory and added a new class in the file app/pdfs/report_pdf.rb.
I changed the controller code to use the new class.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class ProductsController < ApplicationController
  def index
    @products = Product.all
    respond_to do |format|
      format.html
      format.pdf do
        pdf = ReportPdf.new(@products)
        send_data pdf.render, filename: 'report.pdf', type: 'application/pdf'
      end
    end
  end
end
The code below shows how to generate a PDF of the webpage shown above. I have commented it to show what I’m doing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class ReportPdf < Prawn::Document
  def initialize(products)
    super()
    @products = products
    header
    text_content
    table_content
  end
  def header
    #This inserts an image in the pdf file and sets the size of the image
    image "#{Rails.root}/app/assets/images/header.png", width: 530, height: 150
  end
  def text_content
    # The cursor for inserting content starts on the top left of the page. Here we move it down a little to create more space between the text and the image inserted above
    y_position = cursor - 50
    # The bounding_box takes the x and y coordinates for positioning its content and some options to style it
    bounding_box([0, y_position], :width => 270, :height => 300) do
      text "Lorem ipsum", size: 15, style: :bold
      text "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum semper placerat. Aenean mattis fringilla risus ut fermentum. Fusce posuere dictum venenatis. Aliquam id tincidunt ante, eu pretium eros. Sed eget risus a nisl aliquet scelerisque sit amet id nisi. Praesent porta molestie ipsum, ac commodo erat hendrerit nec. Nullam interdum ipsum a quam euismod, at consequat libero bibendum. Nam at nulla fermentum, congue lectus ut, pulvinar nisl. Curabitur consectetur quis libero id laoreet. Fusce dictum metus et orci pretium, vel imperdiet est viverra. Morbi vitae libero in tortor mattis commodo. Ut sodales libero erat, at gravida enim rhoncus ut."
    end
    bounding_box([300, y_position], :width => 270, :height => 300) do
      text "Duis vel", size: 15, style: :bold
      text "Duis vel tortor elementum, ultrices tortor vel, accumsan dui. Nullam in dolor rutrum, gravida turpis eu, vestibulum lectus. Pellentesque aliquet dignissim justo ut fringilla. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut venenatis massa non eros venenatis aliquet. Suspendisse potenti. Mauris sed tincidunt mauris, et vulputate risus. Aliquam eget nibh at erat dignissim aliquam non et risus. Fusce mattis neque id diam pulvinar, fermentum luctus enim porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos."
    end
  end
  def table_content
    # This makes a call to product_rows and gets back an array of data that will populate the columns and rows of a table
    # I then included some styling to include a header and make its text bold. I made the row background colors alternate between grey and white
    # Then I set the table column widths
    table product_rows do
      row(0).font_style = :bold
      self.header = true
      self.row_colors = ['DDDDDD', 'FFFFFF']
      self.column_widths = [40, 300, 200]
    end
  end
  def product_rows
    [['#', 'Name', 'Price']] +
      @products.map do |product|
      [product.id, product.name, product.price]
    end
  end
end
For more about the PDF formatting rules available, check out the Prawn manual.

PDFKit

For PDFKit, first include the gem in your Gemfile
1
gem 'pdfkit'
and run bundle install
You can generate PDF documents by pointing to a html file or website as shown below.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# PDFKit.new takes the HTML and any options for wkhtmltopdf
# run `wkhtmltopdf --extended-help` for a full list of options
kit = PDFKit.new(html, :page_size => 'Letter')
kit.stylesheets << '/path/to/css/file'
# Get an inline PDF
pdf = kit.to_pdf
# Save the PDF to a file
file = kit.to_file('/path/to/save/pdf')
# PDFKit.new can optionally accept a URL or a File.
# Stylesheets can not be added when source is provided as a URL of File.
kit = PDFKit.new('http://google.com')
kit = PDFKit.new(File.new('/path/to/html'))
# Add any kind of option through meta tags
PDFKit.new(')
PDFKit.new(')
PDFKit.new(')
You could also use a middleware solution that allows users to generate PDFs of any page on the website by appending .pdf to the end of the URL. That is what we are going to use here.
To add the middleware, include the following in the /config/application.rb file (This is for Rails version 3 and above).
1
2
3
4
5
6
7
8
module RailsPdf
  class Application < Rails::Application
      config.middleware.use PDFKit::Middleware
      .
      .
      .
  end
end
Restart the server, navigate to a page, and add .pdf to the end of the URL. You will get a PDF version of the webpage.
It’s also possible to use a link to download the page as a PDF file. In haml:
1
= link_to 'Download Report', products_path(format: 'pdf')
To exclude the link in the pdf file, add an id or class name to the tag and set a display property for it in CSS.
1
2
3
4
5
@media print {
  .pdf_exclude {
        display: none;
  }
}

Some Things To Note

I

If wkhtmltopdf is not installed on your system, then you will get a similar error as shown below
1
2
3
PDFKit::NoExecutableError in ProductsController#index
No wkhtmltopdf executable found at >> Please install wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF
For instructions on how to install wkhtmltopdf check out this wiki page.
Another option for installing the wkhtmltopdf binaries is through the gem wkhtmltopdf-binary. Add it to your Gemfile and run bundle install
1
gem 'wkhtmltopdf-binary'

II

If content is getting cut off where you don’t want it to, for example a table being split into two pages, you can specify a page break before the table is rendered so that it appears on its own page.
1
2
3
4
5
6
@media print {
  .page-break {
    display: block;
    page-break-before: always;
  }
}

III

wkhtmltopdf doesn’t play well with relative URLs of any external files (images, stylesheets, javascript) that you might be using. If you use the regular tags like stylesheet_link_tag and try to generate a document, wkhtmltopdf will hang when loading the assets. Using absolute paths (either file paths or urls including the domain) for assets solves this problem.
Another possible solution is to use inline styles. For example instead of the stylesheet_link_tag tag you could use:
1
2
3

IV

For any content that appears on the webpage but you don’t want displayed in the pdf document (e.g. the ‘Download PDF’ link in the above example), just mark it up and hide it with CSS.
1
2
3
4
5
@media print {
    .hide_in_pdf {
        display:none;
    }
}

Wicked PDF

To use Wicked PDF, first install wkhtmltopdf. Alternatively, you could use the wkhtmltopdf-binary gem by including it in your Gemfile.
Add the wicked_pdf to your Gemfile and run bundle install.
1
gem 'wicked_pdf'
Register the PDF mime type in config/initializers/mime_types.rb
1
Mime::Type.register "application/pdf", :pdf
Like PDFKit, Wicked PDF comes with a middleware that allows users to get a PDF view of any page on your site by appending .pdf to the URL. This is achieved by adding config.middleware.use WickedPdf::Middleware to the /config/application.rb file. I won’t be using the middleware here. Instead, I will create template and layout files for the PDF, and modify my controller action to handle PDF-format requests.
I modified the ProductsController as shown. Here, I am specifying the name of the PDF file and the layout used to generate it. For more information on the available options you can use, look at the README file.
1
2
3
4
5
6
7
8
9
10
11
class ProductsController < ApplicationController
  def index
    @products = Product.all
    respond_to do |format|
      format.html
      format.pdf do
        render :pdf => "report", :layout => 'pdf.html.haml'
      end
    end
  end
end
Here is the layout file app/views/layouts/pdf.html.haml.
1
2
3
4
5
6
7
8
9
!!!
%html
  %head
  %title RailsWickedPdf
    = wicked_pdf_stylesheet_link_tag    "application", :media => "all"
    = wicked_pdf_javascript_include_tag "application"
    = csrf_meta_tags
  %body
    = yield
And the template file app/views/products/index.pdf.haml.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.container
  .row
    = wicked_pdf_image_tag('header.png')
  .row
    .col-xs-6
      %h3
        Lorem ipsum
      %p
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum semper placerat. Aenean mattis fringilla risus ut fermentum. Fusce posuere dictum venenatis. Aliquam id tincidunt ante, eu pretium eros. Sed eget risus a nisl aliquet scelerisque sit amet id nisi. Praesent porta molestie ipsum, ac commodo erat hendrerit nec. Nullam interdum ipsum a quam euismod, at consequat libero bibendum. Nam at nulla fermentum, congue lectus ut, pulvinar nisl. Curabitur consectetur quis libero id laoreet. Fusce dictum metus et orci pretium, vel imperdiet est viverra. Morbi vitae libero in tortor mattis commodo. Ut sodales libero erat, at gravida enim rhoncus ut.
    .col-xs-6
      %h3
        Duis vel
      %p
        Duis vel tortor elementum, ultrices tortor vel, accumsan dui. Nullam in dolor rutrum, gravida turpis eu, vestibulum lectus. Pellentesque aliquet dignissim justo ut fringilla. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut venenatis massa non eros venenatis aliquet. Suspendisse potenti. Mauris sed tincidunt mauris, et vulputate risus. Aliquam eget nibh at erat dignissim aliquam non et risus. Fusce mattis neque id diam pulvinar, fermentum luctus enim porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
  .row
    %table.table.table-striped
      %thead
        %th #
        %th Product
        %th Price
      %tbody
        - @products.each do |product|
          %tr
            %td
              = product.id
            %td
              = product.name
            %td
              = product.price
You’ll notice in the above two files, I’m using the following Wicked helpers.
1
2
3
wicked_pdf_stylesheet_link_tag
wicked_pdf_javascript_include_tag
wicked_pdf_image_tag
These are necessary if you are using external files. wkhtmltopdf is run outside of the Rails application, therefore any file you link to must be included with an absolute address.
Using the regular stylesheet_link_tag and javascript_include_tag tags will cause the application to hang when a PDF is requested. Also, the image will not be rendered if the regular img tag is used.

Conclusion

We have looked at three different approaches to PDF generation. Deciding on which to use depends on a variety of factors, including your prefered language (HTML or DSL), ease of accomplishing a task with one library over the other, complexity of the format of the PDF document, among other considerations. I hope this article helps you make that decision.

Tuesday, March 4, 2014

India votes in longest Lok Sabha polls from April 7 to May 12, counting on May 16

The Election Commission on Wednesday announced the schedule for the 2014 Lok Sabha elections saying they will be held in nine phases from April 7, 2014 to May 12, 2014.

Chief election commissioner VS Sampath announced the dates in a press conference. The two election commissioners HS Brahma and SNA Zaidi were also present.

The counting of votes to be held on May 16 and will be over in a day, Sampath told reporters.

The first date of poll shall be on April 7, 2014 which will be held in two states and six parliamentary constituencies will be covered. The second phase of poll on April 9 will cover seven constituencies in five states. The third phase on April 10 to cover 92 constituencies in 14 states and the fourth day of poll on April 12 to cover three states and five constituencies.

The fifth will be on April 17 which will cover 13 states and UTs and 122 constituencies and sixth phase will be on April 24, covering 12 states and 117 constituencies

The seventh phase will be held on April 30 to cover nine states and 89 constituencies, eighth phase on May 7 will cover seven states and 64 constituencies and the last and ninth phase on will be on May 12 and cover 3 states and 41 constituencies.

He said that the model code of conduct has come into immediate effect. It prevents the government from making any decisions that can be seen as influencing voters. It also prohibits political parties from making unsubstantiated allegations against opponents.

He said that the total number of electorate this year stands at 81.4 crore and has increased by 10 crore as compared to the last parliamentary elections in 2009.

The chief election commissioner also said there has been a 12% increase in the number of polling stations in the country with 9,30,000 stations this year. There were 8.3 lakh stations in the last elections.

Andhra Pradesh, including the regions comprising Telangana, Odisha and Sikkim will go to polls to elect new assemblies.

Election commissioner Brahma said that all Naxal-hit areas will be covered in a single day across India.

The decision to announce the dates to elect 543 members to Lok Sabha was taken after a series of meeting by Sampath on Tuesday and firming up of the security plan.

In a first for general elections, voters will also be able to reject all candidates with None Of The Above (NOTA) buttons on 1.5 million electronic voting machines (EVMs).

The EC will also experiment with verifiable paper trail system with EVMs in about 10,000 polling booths.

The general elections for the 16th Lok Sabha will see the ruling UPA, with 232 members in Lok Sabha, face a spirited challenge from the Bharatiya Janata Party-led National Democratic Alliance (NDA). The NDA has 132 members in the present House.

The BJP drew the battle lines early by declaring Gujarat chief minister Narendra Modi as its prime ministerial candidate in September last year.

The Congress has resisted internal clamour to name party vice-president Rahul Gandhi as its PM candidate.

The summer elections will also see the national debut of the Aam Aadmi Party under Arvind Kejriwal, who has already declared a 40-day whirlwind election tour of the country.

The Left-backed Third Front -- of 11 parties -- is also trying to become a formidable force.

The term of the current Lok Sabha expires June 1 and a new House has to be constituted by May 31.

The general elections in 2009 were held in five phases from April 16 to May 13. Votes were counted on May 16.

"I appeal to all stakeholders, parties and candidates to uphold democratic traditions of nation," Sampath said.

9 चरणों में होंगे चुनाव, 16 मई को वोटों की गिनती

चुनाव आयोग ने 16वीं लोकसभा के लिए तारीखों का ऐलान कर दिया है। चुनाव कुल 9 चरणों होंगे। पहले चरण में वोट 7 अप्रैल को डाले जाएंगे और काउंटिंग 16 मई को होगी। मुख्य चुनाव आयुक्त ने कहा, लोकसभा के साथ 3 राज्यों में विधानसभा चुनाव भी होंगे। ये राज्य हैं आंध्र प्रदेश, ओडिशा और सिक्कम। चुनाव की तारीखों की घोषणा के साथ ही आदर्श आचार संहिता लागू हो गई है।

दिल्ली में आयोजित प्रेस कॉन्फ्रेंस में मुख्य चुनाव आयुक्त ने कहा कि इस बार निष्पक्ष और भयमुक्त चुनाव कराने के लिए आयोग ने कुल 9 चरणों में चुनाव कराने का फैसला लिया है। पहले चरण में 7 अप्रैल को वोट डाले जाएंगे। दूसरे चरण में वोट 9 अप्रैल को, तीसरे चरण में 10 अप्रैल, चौथे चरण में 12 अप्रैल, पांचवें चरण में 17 अप्रैल, छठे चरण में 24 अप्रैल, सातवें चरण में 30 अप्रैल, आठवें चरण में 7 मई और 12 मई को नौवें और आखिरी चरण के लिए वोट डाले जाएंगे। वोटों की गिनती 16 मई को होगी।

9 मार्च तक वोटर लिस्ट में नाम दर्ज कराने का मौका
इस मौके पर संपत ने कहा कि जिन लोगों के नाम वोटर लिस्ट में नहीं हैं उन्हें नाम दर्ज कराने के लिए एक और मौका मिलेगा। संपत ने कहा कि 9 मार्च तक नए वोटरों को वोटर लिस्ट में नाम दर्ज कराने का मौका दिया जाएगा। उन्होंने कहा कि इसके लिए देश भर में करीब 9 लाख कैम्प लगाए जाएंगे।

इस बार 10 करोड़ नए वोटर
मुख्य चुनाव आयुक्त ने कहा कि इस बार करीब 81.4 करोड़ वोटर वोट डालेंगे। पिछले चुनाव से करीब 10 करोड़ वोटर ज्यादा हैं।

लोकसभा चुनावों में पहली बार नोटा का विकल्प
लोकसभा चुनावों के लिए पहली बार नोटा विकल्प भी है। गौरतलब है कि पिछले दिनों 5 राज्यों में हुए विधानसभा चुनावों के दौरान पहली बार नोटा विकल्प रखा गया था।

चुनाव खर्च पर खास नजर
संपत ने कहा कि चुनाव खर्च पर चुनाव आयोग की खास नजर रहेगी। उम्मीदवारों के खर्च पर नजर के लिए पहले से ज्यादा पर्यवेक्षक बहाल किए जाएंगे।

सबको ध्यान में रखकर तारीखों का ऐलान मुख्य चुनाव आयुक्त वी.एस.संपत ने तारीखों का ऐलान करते हुए कहा कि पिछले 4 फरवरी को सभी दलों के साथ हुई बैठक में चुनाव से जुड़े सभी पहलुओं पर ध्यान दिया गया था। सभी पार्टियों की बातों को ध्यान में रखकर तारीखों का ऐलान किया गया है। उन्होंने तारीखों का ऐलान करते वक्त मॉनसून, त्योहारों परीक्षाओं सहित सभी बातों का ध्यान रखा गया है।

गौरतलब है कि 2009 में लोकसभा के चुनाव 16 अप्रैल से 13 मई के बीच 5 चरणों में हुए थे, यानी यह पहली बार होगा, जब देश में 9 चरणों में लोकसभा चुनाव होंगे।

कब कहां पड़ेंगे वोट

आंध्र प्रदेश: 30 अप्रैल, 7 मई
अरुणाचल प्रदेश: 9 अप्रैल
असम:12, 17 और 24 अप्रैल
बिहार: 10, 17, 24, 30 अप्रैल, मई 7 और 12 मई
छत्तीसगढ़: 10, 17 और 24 अप्रैल
गोवा: 17 अप्रैल
गुजरात: 30 अप्रैल
हरियाणा: 10 अप्रैल
हिमाचल प्रदेश: 7 मई
जम्मू-कश्मीर: 10, 17, 24, 30 अप्रैल और 7 मई
झारखंड: 10, 17 और 24 अप्रैल
कर्नाटक: 17 अप्रैल
केरल: 10 अप्रैल
मध्य प्रदेश: 10, 17 और 24 अप्रैल
महाराष्ट्र: 10, 17 और 24 अप्रैल
मणिपुर: 9 और 17 अप्रैल
मेघालय: 9 अप्रैल
मिजोरम: 9 अप्रैल
नगालैंड: 9 अप्रैल
ओडिशा: 10 और 17 अप्रैल
पंजाब: 30 अप्रैल
राजस्थान: 17 और 24 अप्रैल
सिक्कम: 12 अप्रैल
तमिलनाडु: 24 अप्रैल
त्रिपुरा: 7 और 12 अप्रैल
उत्तर प्रदेश: 10, 17, 24 और 30 अप्रैल, मई 7 और 12
उत्तराखांड : 7 मई
पश्चिम बंगाल: 17, 24, 30 अप्रैल, 7 और 12 मई
अंडमान और निकोबार: 10 अप्रैल
चंडीगढ़: 12 अप्रैल
दादर और नागर हवेली: 12 अप्रैल
दमन और दीव: 30 अप्रैल
लक्षद्वीप: 10 अप्रैल
पुड्डुचेरी: 24 अप्रैल