Responsive Google AdSense

Just add this Responsive Google AdSense snippet code to your website page to make your Google ads responsive to any devices if Google’s native responsive code does not work for you.


 
 
 
    /* Calculate the width of available ad space */
    ad = document.getElementById('google-ads-1');
 
    if (ad.getBoundingClientRect().width) {
        adWidth = ad.getBoundingClientRect().width; // for modern browsers 
    } else {
        adWidth = ad.offsetWidth; // for old IE 
    }
 
    /* Replace ca-pub-XXX with your AdSense Publisher ID */ 
    google_ad_client = "ca-pub-XXX";
 
    /* Replace 1234567890 with the AdSense Ad Slot ID */ 
    google_ad_slot = "1234567890";
  
    /* Do not change anything after this line */
    if ( adWidth >= 728 )
      google_ad_size = ["728", "90"];  /* Leaderboard 728x90 */
    else if ( adWidth >= 468 )
      google_ad_size = ["468", "60"];  /* Banner (468 x 60) */
    else if ( adWidth >= 336 )
      google_ad_size = ["336", "280"]; /* Large Rectangle (336 x 280) */
    else if ( adWidth >= 300 )
      google_ad_size = ["300", "250"]; /* Medium Rectangle (300 x 250) */
    else if ( adWidth >= 250 )
      google_ad_size = ["250", "250"]; /* Square (250 x 250) */
    else if ( adWidth >= 200 )
      google_ad_size = ["200", "200"]; /* Small Square (200 x 200) */
    else if ( adWidth >= 180 )
      google_ad_size = ["180", "150"]; /* Small Rectangle (180 x 150) */
    else
      google_ad_size = ["125", "125"]; /* Button (125 x 125) */
 
    document.write (
     ''
    );
  
    (adsbygoogle = window.adsbygoogle || []).push({});
 

 
//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

 
Source: Snippet by Digital Inspiration

Python: How to debug Python code using “pdb” module

One of the most important feature when you are making a code is “debugging”, whether you are new or even pro, you might need this feature. And how to do it when you are programming in Python without any IDE? you might use Terminal or Command Line in Windows to do so. This video is about How to do it in Windows, anyway it works in Unix environment. I found this video is helpful, hopefully also for you.

If you prefer to read the documentation, you can read it here (http://docs.python.org/2.7/library/pdb.html)

How to make a Ubuntu bootable USB stick in OSX Maverick

Yesterday I had a little problem with my Ubuntu linux notebook. It was just because I installed Gnome 3.10 in my Ubuntu 13.10 and made it crash badly. I tried to reinstall my old notebook via bootable DVD, unfortunately the DVD-Rom did not work as I expected. So I tried to figure out how to solve it using USB stick. Another issue was that how to make it bootable using OSX Maverick notebook and I found this article.

The steps are exactly as similar as in the article, but I faced a little issue when it comes to convert .iso file to .img. Instead of execute it using hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso , I didt it this way hdiutil convert ~/path/to/ubuntu.iso -format UDRW -o ~/path/to/target.img .

So, to summary, these are the steps I did to make a Ubuntu bootable USB stick in OSX Maverick:

  1. First of all, download the Ubuntu desktop iso file,
  2. Open the Terminal using Spotlight to be easier (cmd + space and type terminal, enter)
  3. Using Terminal, locate the .iso file on your notebook and run this command,
    hdiutil convert ~/path/to/ubuntu.iso -format UDRW -o ~/path/to/target.img

    , as mentioned in the article, OS X tends to add .dmg to the .img file. That’s just fine, just remove the .dmg trailing.

  4. Insert your USB stick (at least 2 GB free space),
  5. Still in the Terminal, run diskutil list to get current list of devices attached to the notebook. Then determine the device node assigned to your USB stick, e.g /dev/disk1
  6. Unmount (not Eject) the USB by running diskutil unmountDisk /dev/disk1 . Note, replace number 1 in /dev/disk1 with whatever it assigned to USB when you do previous step.
  7. Do make bootable USB by executing this command,
    sudo dd if=/path/to/ubuntu.img of=/dev/rdisk1 bs=1m
  8. If the process is finished, eject the stick using diskutil eject /dev/disk1 and remove it.
  9. Done and use it as bootable USB stick when you start the notebook you want to install Ubuntu.

That’s all the steps I’ve done and the bootable USB stick is working properl.

Source: http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx

How to center multiple figures in LaTex

Hi Guys,

Below you can find  a block of code to center your  figures in Latex.

In this example, two figures are used.

documentclass{article}
usepackage{subfigure}
usepackage{graphicx}

begin{document}

begin{figure}[ht]
begin{center}
subfigure[Caption for Figure 1]{
label{fig:first}
includegraphics[width=0.25textwidth]{./images/Figure1.eps}
}
subfigure[Caption for Figure 1]{
label{fig:second}
includegraphics[width=0.25textwidth]{./images/Figure2.eps}
}
end{center}
caption{(a) Figure 1, (b) Figure 2 }
label{fig:subfigures}
end{figure}

end{document}

Preview:Example_subfigures

Hope this is useful.

Reference

http://nixtricks.wordpress.com/2009/11/09/latex-multiple-figures-under-the-same-caption-using-subfigure/

 

Links: Java and XML Tutorials

(Tuts for myself). Here are some article links about XML and how to parse it in Java using XPath. They might be useful.

Hg Init: a Mercurial tutorial

Hg Init: a Mercurial tutorial

Mercurial is a modern, open source, distributed version control system, and a compelling upgrade from older systems like Subversion. In this user-friendly, six-part tutorial, Joel Spolsky teaches you the key concepts. Also, Fog Creek offers free monthly webinars that go over the basics of Mercurial.

Liveblog: Weekly Pocket Collections, Up to December 15th

This weekly pocket collections would like to share some articles through liveblog way. Let’s start now.

TUTORIALS:

  1. Fullscreen Pageflip Layout
  2. Decorative CSS Gallery – Part 2
  3. How to make an animated thumbnail
  4. Responsive Column Layouts 42

NEWS:

  1. Singly Launches “App Fabric” Platform For Developers To Speed Up Integrations With Dozens Of Services
  2. Adobe Brings Retina Display Support To Photoshop And Illustrator CS6 As A Free Update For All Users

Weekly pocket collection, December 8th

Hi readers!

I’ve been using pocket apps for several weeks now. And I got plenty of articles that I have saved on it from daily basis browsing since then. I thought it would be nice if I could share it with you. Well, here they are, my first “Weekly Pocket Collection, December 8th”.

  1. Gamma Gallery from tympanus
  2. Heading Set Styling with CSS
  3. WPMU’s Best in WordPress: November 5th – 11th
  4. 7 Fantastic Presentations from WordCamp and BuddyCamp Vancouver 2012
  5. Stop WordPress Content Thieves From Stealing Your Content – And Your Bandwidth
  6. Responsive CSS Timeline with 3D Effect
  7. 40+ essential WordPress plugins
  8. Tips and Plugins to Make a Multi-Author Blog More Manageable
  9. Z-Index And The CSS Stack: Which Element Displays First?
  10. 50 Totally Free Lessons in Graphic Design Theory
  11. Resources that matter
  12. Code smells in CSS
  13. How to Create Retina Graphics for your Web Designs
  14. IE10 CSS Hacks
  15. CSS Architecture
  16. How Fluid Grids Work in Responsive Web Design
  17. Typespiration – // treating typography with respect
  18. Design Patterns for Creating Exceptional User Interfaces on the Web

Hmm… I think that’s enough for now, have a happy reading mates! 🙂