1

How to create basic slides using Beamer Latex?

Posted by Joys of Programming on in Latex

With beamer, you can create slides for your presentation. Her we present a simple template for creating a presentation. Let’s name the file simple.tex.

\documentclass{beamer}
\begin {document}

\frame {
Slide 1

Content to Write
}

\frame {
Slide 2

Content to Write
}

\end{document}

Let’s see every line in detail

\documentclass{beamer}

Here we are including the package beamer into our file. Running this single line will not generate any pdf file

$ pdflatex simple.tex

Now let’s add more lines

\documentclass{beamer}
\begin {document}
\end {document}


We are now ready with a document in which some content has to be inserted.
Every slide is called a frame. So for every slide you want to create you must enter the contents in a frame as shown below

\documentclass{beamer}
\begin {document}

\frame {
Slide 1

Content to Write
}
\end{document}

Thus we have the slides with no background and style. We have content on the plain format

Tags: , ,

 
0

Beamer/LaTeX Tutorial

Posted by Joys of Programming on in dpkg, Red Hat, Ubuntu

LaTeX is commonly used to prepare documents. It is commonly used for the scientific documentation because it is very useful to create documents with lots of mathematical symbols and notations. For some time, Beamer is used by the scientific community for preparing slides for a presentation. Beamer has features to describe slides and the transition. So creating slides with Beamer is very quick.

If you want to work with LaTeX/Beamer in Linux, you have the command line utilities like pdflatex to create pdf documents from .tex documents. You can also work with application softwares like kile.

  1. Installation
  2. Creating Slides


Tags: , , ,

 
0

PHP: Extract Outgoing URLs from a Web Page

Posted by Joys of Programming on in PHP, Web

In PHP, you can download a web page using file_get_contents or curl. Once you have downloaded a web page, you can process it.

We know that the tag structure of hyperlink is as follows

<a href="http://www.joysofprogramming.com">Joys of Programming</a>

Keeping this in mind, we write the following program

<?php

function extractElementsFromWebPage($webPage, $tagName) {
  //Creating a DOMDocument Object.
  $dom = new DOMDocument;

  //Parsing the HTML from the web page
  if ($dom->loadHTML($webPage)) {
    // Extracting the specified elements from the web page
    @$elements = $dom->getElementsByTagName($tagName);
    return $elements;
  }
  return FALSE;
}

function downloadURL($URL) {
  $webPage = file_get_contents ($URL);
  return $webPage;
}

$webPage = downloadURL("http://www.mozilla.org/");
if ($webPage ) {
  $URLs = extractElementsFromWebPage($webPage, 'a');
  if ($URLs) {
    foreach ($URLs as $URL){
      // Extracting the URLs
      echo $URL->getAttribute('href'), "\n";
    }
  }
  else {
    echo "Error in parsing the webPage\n";
  }
}
else {
  echo "Error in downloading the webPage\n";
}
?>

There are certain things that need to be understood:

Firstly we are using file_get_contents to download a web page. Then we use the DOMDocument class in PHP to parse the HTML page. Check the two functions

  1. downloadURL
  2. extractElementsFromWebPage

downloadURL uses file_get_contents to download the web page and extractElementsFromWebPage uses the DOMDocument class. The function loadHTML is used to parse the HTML page and getElementsByTagName to extract the specified elements. In our case, we want to extract the HTML tag element a.

On executing the program

$ php extractURLs.php
#main
/
/about/
/community/
/projects/
/contribute/
/about/mission.html

http://www.mozilla.com/firefox/

http://www.mozilla.com/mobile/download/

...



Tags: , , ,

 
0

PHP: Extract Image URLs from a Web Page

Posted by Joys of Programming on in PHP, Web

In PHP, you can download a web page using file_get_contents or curl. Once you have downloaded a web page, you can process it. We want to extract the image URLs from a web page.

We know that the tag structure of an image url is as follows

<img src="image.gif" alt="Image Description" />

Keeping this in mind, we write the following program

<?php

function extractElementsFromWebPage($webPage, $tagName) {
  //Creating a DOMDocument Object.
  $dom = new DOMDocument;

  //Parsing the HTML from the web page
  if ($dom->loadHTML($webPage)) {
    // Extracting the specified elements from the web page
    @$elements = $dom->getElementsByTagName($tagName);
    return $elements;
  }
  return FALSE;
}

function downloadURL($URL) {
  $webPage = file_get_contents ($URL);
  return $webPage;
}

$webPage = downloadURL("http://www.mozilla.org/");
if ($webPage ) {
  $imageURLURLs = extractElementsFromWebPage($webPage, 'img');
  if ($imageURLURLs) {
    foreach ($imageURLURLs as $imageURL){
      // Extracting the URLs
      echo $imageURL->getAttribute('src'), "\n";
    }
  }
  else {
    echo "Error in parsing the webPage\n";
  }
}
else {
  echo "Error in downloading the webPage\n";
}
?>

There are certain things that need to be understood:

Firstly we are using file_get_contents to download a web page. Then we use the DOMDocument class in PHP to parse the HTML page. Check the two functions

  1. downloadURL
  2. extractElementsFromWebPage

downloadURL uses file_get_contents to download the web page and extractElementsFromWebPage uses the DOMDocument class. The function loadHTML is used to parse the HTML page and getElementsByTagName to extract the specified elements. In our case, we want to extract the HTML tag element img.

On executing the program

$ php extractImageURLs.php
/images/promos/join_promo_a.png
/images/template/screen/logo_footer.png

https://statse.webtrendslive.com/dcsis0ifv10000gg3ag82u4rf_7b1e/njs.gif?dcsuri=/nojavascript&WT.js=No&WT.tv=8.6.2



Tags: , , , ,

 
0

PHP: Extract HTML Tags/Element from a Web Page

Posted by Joys of Programming on in PHP, Web

In PHP, you can download a web page using file_get_contents or curl. Once you have downloaded a web page, you can process it. Take for example, we want to extract the image URLs from a web page.

We know that the tag structure of an image url is as follows

<img src="image.gif" alt="Image Description" />

Keeping this in mind, we write the following program

<?php

function extractElementsFromWebPage($webPage, $tagName) {
  //Creating a DOMDocument Object.
  $dom = new DOMDocument;

  //Parsing the HTML from the web page
  if ($dom->loadHTML($webPage)) {
    // Extracting the specified elements from the web page
    @$elements = $dom->getElementsByTagName($tagName);
    return $elements;
  }
  return FALSE;
}

function downloadURL($URL) {
  $webPage = file_get_contents ($URL);
  return $webPage;
}

$webPage = downloadURL("http://www.mozilla.org/");
if ($webPage ) {
  $imageURLURLs = extractElementsFromWebPage($webPage, 'img');
  if ($imageURLURLs) {
    foreach ($imageURLURLs as $imageURL){
      // Extracting the URLs
      echo $imageURL->getAttribute('src'), "\n";
    }
  }
  else {
    echo "Error in parsing the webPage\n";
  }
}
else {
  echo "Error in downloading the webPage\n";
}
?>

There are certain things that need to be understood:

Firstly we are using file_get_contents to download a web page. Then we use the DOMDocument class in PHP to parse the HTML page. Check the two functions

  1. downloadURL
  2. extractElementsFromWebPage

downloadURL uses file_get_contents to download the web page and extractElementsFromWebPage uses the DOMDocument class. The function loadHTML is used to parse the HTML page and getElementsByTagName to extract the specified elements. In our case, we want to extract the HTML tag element img.

On executing the program

$ php extractElements.php
/images/promos/join_promo_a.png
/images/template/screen/logo_footer.png

https://statse.webtrendslive.com/dcsis0ifv10000gg3ag82u4rf_7b1e/njs.gif?dcsuri=/nojavascript&WT.js=No&WT.tv=8.6.2


Tags: , , ,

 
0

PHP: Download Web Page using file_get_contents

Posted by Joys of Programming on in PHP, Web

You can use curl to download a webpage in PHP. It is also possible to download a web page using file_get_contents().

<?php

function downloadURL($URL) {
  $webpage = file_get_contents ($URL);
  return $webpage;
}

$webpage = downloadURL("http://www.mozilla.org/");
if ($webpage){
  echo $webpage;
}
else {
  echo "Error in downloading the webpage\n";
}
?>

$ php download.php
<html>
....
</body>
</html>

In the above example, we try to download the web page of Mozilla. Let’s try to download a non existing web page

<?php

function downloadURL($URL) {
  $webpage = file_get_contents ($URL);
  return $webpage;
}

$webpage = downloadURL("http://www.mozilla.org/1");
if ($webpage){
  echo $webpage;
}
else {
  echo "Error in downloading the webpage\n";
}
?>

We find the following error

$ php download.php

Warning: file_get_contents(http://www.mozilla.org/1): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in /home/prof/samuel/Documents/Dropbox/Personal/Programs/downloadWebpage.php on line 4
Error in downloading the webpage


Tags: ,

 
0

Google Chrome: Unable to Open in Mac

Posted by Joys of Programming on in Google Chrome, Mac

There can be many reasons why you can’t open Google Chrome in Mac. To diagnose this issue, try typing the following in the Terminal and run Chrome from the terminal

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
[......:ERROR:process_singleton_mac.cc(102)] Unable to obtain profile lock.

If you get the following error, you must remove the following file

$ rm ~/Library/Application\ Support/Google/Chrome/SingletonLock

And now try opening Google Chrome.


Tags: ,

Copyright © 2009-2012 Joys of Programming All rights reserved.
Desk Mess Mirrored v1.8.1 theme from BuyNowShop.com.