Sunday, May 19, 2013

CSS Tutorial for Beginners

CSS is a markup language is used to apply style to HTML documents.

There 3 ways to apply CSS to a HTML document.

The order or precedence of how CSS is applied to an HTML is a follows:

  1. The browser loads CSS from the external stylesheet.
  2. The in page style sheet is loaded and overwrites any duplicate styles from the external stylesheet
  3. Any in-line style are applied to the HTML tag overwriting the first two methods.



HTML Code

<html>
 <title>CSS for Beginners</title>
 <head>
  <link href="style.css" rel="stylesheet" type="text/css">
  <style>
   /* tag selector */
   h1 {color: red;}
  </style>
 </head>
 <body>
  <h1 style="color: blue;">CSS for Beginners</h1>
  <p id="intro" class="first">This is the first <em>paragraph</em></p>
  <p class="first">This is the second paragraph</p>
  <p>This is the third paragraph</p> 
 </body>

CSS Style Sheet

/* CSS Comment */

/* tag selector */
h1 {color: gray;}

/* class selector */
.first {font-size:150%;}

/* id selector */
#intro {font-size:270%;}

/* decendant selector */
#intro.first em {
 color: green;
 font-size:270%;
 }
CSS rules are made up of a selector, a property and a value. h1 is the selector color is the property red is the value When properties and values when used together they are called a declaration. id selector = #id class selector = .class descendant selector: #intro.first

Sunday, April 28, 2013

For Loops for Beginners - ASP, PHP and JavaScript examples

A "For Loop" executes a block of code a specific number of times or while a specified condition is true.

PHP

Sample
for (init; condition; increment)
  {
  code to be executed;
  }
    Parameters:
  • init: Mostly used to set a counter (but can be any code to be executed once at the beginning of the loop)
  • condition: Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
  • increment: Mostly used to increment a counter (but can be any code to be executed at the end of the iteration)

Note: The init and increment parameters above can be empty or have multiple expressions (separated by commas). Example The example below defines a loop that starts with i=1. The loop will continue to run as long as the variable i is less than, or equal to 5. The variable i will increase by 1 each time the loop runs:
<?php
for ($i=1; $i<=5; $i++)
  {
  echo("The number is " . $i . "<br>");
  }
?>
 
See the PHP for loop example 

ASP

<%
For i = 1 to 5
 Response.Write("The number is " & i & "<br>")
Next
%>
 
See the ASP for loop example  

JavaScript

<Script Language="JavaScript">
for (var i=1;i<=5;i++)
    {
    document.write("The number is " + i + "<br&gt");
    }
</Script>
 
 See the JavaScript for loop example  

Video

Friday, February 22, 2013

Netflix Throttling: Changing Playback Performance to Reduce Bandwidth Usage

The Problem with Netflix... Bandwidth Caps and Mobile Data Plans

  Bandwidth Caps & Data Plans

I work in IT for a living and I've recently coined the phrase, "Bandwidth is the new gasoline".  Just about every new gadget or tech related product seems to require some sort of connectivity to the internet.  Pretty soon I think it will be hard to find a consumer electronic device without some form of connectivity feature.

The entertainment industry and the business of content delivery is no exception. From online content services like Netflix and Hulu to internet connected televisions, Apple TVs and Roku boxes.  Home entertainment now requires internet connectivity too.

Your data plan is fast becoming a key indicator of how much entertainment (content) you can watch for a given period of time.

Until about 6 months ago I was using an AT&T DSL account that I used for years which had a bandwidth cap of 150 GB per month.  After adding some Dropcams and an couple of Apple TVs I began to receive warnings from AT&T about exceeding my monthly data bandwidth cap and additional fees would be applied at $20 per each additional 50GB.


Over the next couple of months I paid overage fees every month and eventually upgraded to AT&T U-verse which as a 250 GB per month bandwidth cap.

Fast forward to last week, Feb 2013, and now I have my new iPhone 5 (4G LTE) via Verizon Wireless and upon upgrading had to say goodbye to my old unlimited 3G plan.  The new data plan had data plan options in increments of 2G from 2-12GB per month and each one adding more and more the my new monthly bill.

I ended up choosing the 6GB plan and it added $40 per month to my bill, now $120.

 How to Throttle Netflix Playback

Now that I have my blazing fast LTE iPhone, and it is fast, I'm worried that watching Netflix on my iPhone will quickly burn through my 6 GB data plan.

Netflix has a potential fix for this.

From your account settings screen in Netflix:
  • Choose Manage video quality
  • Select the quality setting
    • Good Quality ( up to 0.3 GB per hour)
    • Better Quality (up to .7 GB per hour)
    • Best Quality (up to 1.0 GB or up to 2.3 GB per hour for HD)

Thursday, February 21, 2013

Google Analytics & Adsense Apps for iPad and iPhone (iOS)

Google Analytics & Adsense Apps for iPad and iPhone (iOS)

I've recently found quite a few iOS apps for Google Analytics.  Some just automate the login process and rehash the same web based user interface but others actually go the extra mile and make it easy to look at the data quickly and in ways that just make more sense for people of rely on this data to make business decisions on a day-to-day basis.

I will cover some of the ones I've been using lately share with you my favorites.


iPad Apps


iPhone Apps


Monday, February 11, 2013

SEO: How Often Should You Submit XML Sitemaps to Google or Bing

How often you should submit XML sitemaps to Google and Bing?

Let's explore this together using a real world site that gets about a million page views a month and see what happens!

If you are a webmaster and you're not using both the Google and Bing webmaster portal sites to gain awareness as to how they are seeing your site, start now.  While they won't share all their secrets, they do share some key data to help you improve your site and should in theory result in more organic (free) traffic.

2/11/2013 Before


Sitemaps Stats

I have a site where new content is constantly being added by users and old content is deleted after 90 days.  At the time of this writing there are approximately 38,000 pages on the site and by the end of today probably 39,000 pages. Unfortunately, only 15,771 of the 38K have been indexed by Google.

Since I have so much new content on daily basis I thought I should be letting Google and Bing know by sending them updated XML sitemaps every 2-3 days.  I've been doing this over the past 6 months and am beginning to believe that this practice is hurting my organic search results.  I think my statistics show that immediately after submitting a new sitemap my organic search engine traffic seems to drop and then slowly comes back after a couple of days.

Beginning the Test

Two days ago, 2/9/2013, I had submitted an updated sitemap with 38,093 pages and have decided not to submit another update for at least two weeks or maybe even a month depending on how many pages Google says they are indexing and much organic traffic is coming in.


The screenshot below is the before shot and displays the organic traffic beginning Jan 1, 2013 and ending on Feb 10th.

See the pattern?

  • 1/1: 58 clicks
  • 1/5:  69 clicks (high)
  • 1/8: 39 clicks (low)
  • 1/18: 95 clicks (high)
  • 1/20: 67 clicks (low)
  • 1/27: 105 clicks (high)
  • 1/28: 74 clicks (low)
  • 2/6: 89 clicks (high)
  • 2/7: 77 (low)
  • 2/10: 90 clicks (up)
  • 2/11: 108 clicks(up)

This site has had a long history of SEO related issues like duplicate content and dynamic pages that were erroring out for various reasons.  Slowly but surely I've been learning all I can about SEO including watching every Matt Cutts Google Webmaster video and spending a lot of time on the SEO MOZ site and watching their Whiteboard Friday video series and then applying this knowledge to my site.
 
You can see since January 1st, I was able to double my organic traffic which shows that all the SEO efforts that I've been working on for the last 6 months are starting to pay off.

As of late, the term, SEO seems to be taking on a negative connotation.  When I say SEO, I'm really just saying that I'm improving the site and users experience on the site by applying best practices.

Check back on my blog for an update on this blog around 3/11/2013 where I will show some statistics on the before and after affects of my SEO sitemap experiment.

2/14/2013 (End of Week 1)

At the end of week 1 without resubmitting the XML sitemap Google finally shows indexing more than 15K of the 38K pages.  Another 1,000+ pages were added to Google's index this week.  That's great!

2/16/2013

Another 4K pages have been included in Google's Index.




 

3/7/2013

Another 1K pages have been included in Google's Index.



Bing Webmaster Tools (Pages Indexed as of 2/25/2013)

Bing Webmaster Tools is also showing an increase in pages indexed.  The longer I withhold resubmission of an updated sitemap the more pages seem to be indexed but it is taking quite a long time to index. 
 
On 2/25/2013 had a recorded high of 122 organic clicks and then I deleted approximately 1000 records from the content database. I did not submit a new sitemap but as a result of this action, the following day's organic traffic seemed to suffer.  I would attribute this to Google and Bing detecting an increase in 404 and 410 response codes from web pages that had been deleted. Also, the Bing webmaster tools now shows only 21% of my pages as indexed, down 1% from the previous day.

Wednesday, October 3, 2012

What is the maximum script timeout setting for ASP on IIS?

I was scripting in old school ASP version 3.0 on IIS6 this week and had a script that needed a long time to run and kept timing out.

So I asked the question... What is the maximum script timeout setting for ASP on IIS?

After a lot of digging, I found out the answer.

The maximum value for ScriptTimeout is 2^32-1, or 2147483647. If you try to set it to 2147483648 or higher, you will get the following error:

Microsoft VBScript runtime (0x800A0006)
Overflow: 'server.scripttimeout'


Normally you would script it out like this.

<%
    Server.ScriptTimeout = 180
%>

Now with the maximum value, it looks like this.
 <%
    Server.ScriptTimeout = 2147483647
%>

The real solution was that my database was not performing at its best.  So needed to create additional indexes on more fields which increased the speed of the script.

 Hope this helps somebody out.

Happy coding!

Thursday, September 6, 2012

Microsoft Excel Error When Using VBScript on Windows 7

I have a VBScript from a previous blog post that exported your Outlook calendar item to a csv file.  I tried it on a new Windows 7 PC and it failed displaying the error "Microsoft Excel cannot access the file 'C:\25DCA170' (random file name).

If you are reading this then you are probably in the same boat.

If you are working with SQL server then this might help you.  I had found a blog article that gave me some hope at:
http://blogs.msdn.com/b/sqlserverfaq/archive/2010/04/30/unable-to-open-excel-files-using-a-cscript-in-sql-server-jobs.aspx

The stated resolution requires your to create "Desktop" folders in two locations depending on your system.

For me, I guess it was a pretty simple fix.  Previously, I had to save the file output to the c drive (C:\file.xls).  With Windows 7 our corporate configuration has the home drive pointing to our "H" drive (H:\).  With Windows 7 and UAC, you have to change the script to write to the home drive H: instead the root of the hard drive C:\.  This worked for me.

Please feel free to leave feedback with your experiences.

- Rick

Saturday, December 3, 2011

iTunes - How to fix TV Shows that won't delete.

Recently, I noticed that I had a couple of free TV shows that I downloaded in iTunes and they kept downloading over and over which then would sync to my iPad.  No matter what I did iTunes would not let me delete them and I was getting very frustrated.  I looked all over the web and could not seem to find a good answer so I figured it out myself.

Here is how you fix it manually.

First, let me tell you that this is on a Windows 7 PC. However, I'm certain the fix is very similar on any computer.  Look at this solution and apply the configuration settings to your setup.

Find out where iTunes is storing your media files.  In my case, a Windows 7 PC had them here.
 
C:\Users\Rick Cable\Music\iTunes\iTunes Media

Next, find the downloads folder

C:\Users\Rick Cable\Music\iTunes\iTunes Media\Downloads

You should see a folder for each download and in my case, each TV Show, and a file named "list.plist".

Since I had already cleaned my files out, I downloaded a free episode of Knights of Mayhem so I can show you real data from the list.plist file.


Here are the contents of the list.plist file.  To fix, delete the temporary folder that was created for the download then open the list.plist file and delete all lines between the <dict> and </dict> tags and then save the file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>items</key>
    <array>
        <dict>
            <key>category</key>
            <string>itms</string>
            <key>downloadID</key>
            <string>J16N_V_160003334639723</string>
            <key>dsid</key>
            <integer>299476307</integer>
            <key>id</key>
            <integer>475364041</integer>
            <key>name</key>
            <string>Behind the Scenes / Knights of Mayhem, Season 1 / Knights of Mayhem</string>
        </dict>
    </array>
</dict>
</plist>
That's it.... hope this article helped.

Thursday, November 17, 2011

Retaining Leading Zeros When Mail Merging from Excel to Word

Problem:

I had created an Excel spreadsheet that was being used as a data source for a Microsoft Word mail merge but the Excel document had a field that used field formatting to add leading zeros to the numbers but the numbers were not being imported in to the mail merge document with the leading zeros.

Today's Challenge?

Retaining leading zeros on a numeric field when using Microsoft Word Mail Merge with an Excel source document.


The Solution


In Microsoft Word...

Change the mail merge field to read...

{ Mergefield ZipCode \# "00000" }

Change "ZipCode" to whatever numeric field you are trying to import / merge.

Tuesday, November 8, 2011

Loop Through and Update Records in SQL Server

I had a challenge yesterday that I would normally solve using some Visual Basic code but had to do it in pure SQL on a SQL 2005 server.

THE CHALLENGE:
Loop through all the records in a table and then update the table based on some logic or condition.

THE SOLUTION:

Using a SQL Cursor, I was able to loop through all the records in a table and then run an SQL update command for certain records that matched a particular criteria.


Here is the code:

DECLARE @myEmpID int

DECLARE MyCursor CURSOR FOR

SELECT DISTINCT  EmployeeID FROM Employees WHERE Company=64


OPEN myCursor


--Read the initial emploee id value from the cursor

FETCH NEXT FROM myCursor

INTO @myEmpID


WHILE @@FETCH_STATUS = 0

BEGIN
--Update goes here UPDATE Employees SET [Status] = 'T' WHERE EmployeeID = @myEmpID AND Company=54 FETCH NEXT FROM MyCursor INTO @myEmpID
END
CLOSE MyCursor