Firefox: Location bar behavior

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Browsers, Software | No comments yet.

When you are typing in the location bar, you can have the suggestions come from your History, Bookmarks, Both or none.

To update this, Goto Tools->Options.

In the popup menu, select the privacy tab.

At the bottom there is the Location bar section. Select the “When using the location bar, suggest:

History and Bookmarks  
History
Bookmarks
Nothing

Tags: ,

CSS: Background properties

digg del.icio.us TRACK TOP
By Eric Downing | Filed in CSS, html, Utilities | No comments yet.

These are the individual background properties in CSS.

background-color
background-image
background-repeat
background-attachement
background-position

The background-color property specifies the color of the element. This can be useful to specify if someone has turned images off and you want a non-default view of your content. You can use a hex value (#RRGGBB), a shortcut hex value (#RGB) or a named color (red, green,blue).

background-color: #fffffff;

The background-image specifies an image to place in the background of an element. Remember that the image should be supported by as many browsers as possible. This means using jpeg, pngs or gifs, not tifs or proprietary image formats.

background-image: url(images/someimage.gif)

The background-repeat property specifies how an image should display within an element. You can have it repeat across (repeat-x), repeat downwards (repeat-y) or not repeat (no-repeat).

background-repeat: repeat-x;

The background-attachmemnt attribute is used to specify if an image should scroll (scroll) with the page, be fixed (fixed) to the page or inherit position from a parent element (inherit).

background-attachment: fixed;

The background-position attribute is used to specify the starting position of an image. This can be useful if you are using a sprite to speed up loading times. The background-position attribute can take a Xpx Ypx argument, an X% Y% argument, named arguments(left top, right bottom,…) or inherit from the parent.

background-position: 50% 50%;

Here is an example of the use of these:

 body {
   background-color: #ffffff;
   background-image: url(images/someimage.gif);
   background-repeat: no-repeat;
   background-attachment: fixed ;
   background-position: left top ;
}

You can also use a short cut method to the background property.

 .imagebox {
  background: #ffffff url(images/someimage.gif) no-repeat fixed right top;
}

Tags: , ,

Notepad++: Changing shortcut keys

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Editors, Utilities | No comments yet.

I was tracking a log file the other day and had to reload the file from disk regularly so I wanted to find out how to make a shortcut key to the Reload from disk menu entry on the File menu. Using the Settings->Shortcut Mapper to update the shortcuts for a given menu entry, I chose the Ctrl-R sequence but you are welcome to find an unmapped key sequence that works for you.

Viewing many different video formats on Windows

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Utilities, Windows | No comments yet.

So I lost my hard drive and went to play some of the videos that I have saved on the system and could no longer play them in Windows Media Player. I needed to download a set of video codecs to play my .vob files. I am using the K-Lite Codec Pack.

Featured Software

VIDEO CODECS
FFDShow MPEG-4
DivX 8
Koepi’s XviD Codec
DScaler MPEG Filters
Ogg Codecs
Xvid Video Codec
Nic’s XviD Codec
Ligos Indeo Codec
AUDIO CODECS
MPEG Layer-3 Codec
AC3 Filter
AC-3 ACM Codec
CoreVorbis Decoder
LAME DirectShow Filter
LAME MP3 Encoder
Monkey’s Audio
Vorbis Ogg ACM Codec

This allows me to view the files in other video apps as well.

Tags: ,

CSS: Correct order to style links

digg del.icio.us TRACK TOP
By Eric Downing | Filed in CSS | No comments yet.

This is the correct order to place the styles in your Cascading Style Sheet(CSS) markup to style links.
The order does matter as out of order markup can lead to lost properties.

a:link {}
a:visited {}
a:focus {}
a:hover {}
a:active {}

Tags:

Perl: Open and read file line by line

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Perl, Programming, Scripting, Utilities | No comments yet.

I regularly have to process Comma Seperated Value or CSV files, usually for user lists. So the following perl code is a framework for processing a file line by line.

#!/usr/bin/perl
use strict;
my $line;

open(FILEIN, "filename.txt");

while(<FILEIN>)
{
  chomp();
  $line = $_;
  # Process $line for data
  # Example seperating line by commas: 
  my ($username,$firstname,$lastname,$email) = split(/,/,$line);
}

close(FILEIN);

Tags: ,

Perl: Hashes

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Perl, Scripting, Utilities | No comments yet.

Here are some basics about Perl hashes that can be helpful to be used when an you need to associate a label with some value such as for names and telephone numbers or account numbers with amounts owed.

Create a hash variable.

my %hashvar;

Create a hash reference

my $refhash = {};

Add a value to a hash variable.

$hashvar{'somekey'} = 'someval';

Add a value to a hash reference.

$hashref->{'somekey'} = 'someotherval';

Access a value in a hash.

print $hashvar{'somekey'};

Access a value in a hash reference.

print $hashref->{'somekey}';

Access all Keys in a hash variable.
foreach my $k (keys(%hashvar))
{
print $hashvar{$k};
}

Access all Keys in a hash reference.

foreach my $k (keys(%$hashref))
{
  print $k . "n";
}

Access all Keys and values in a hash.

while (my ($key,$value) = each %hashvar)
{
  print "Key: " . $key . " has value:" . $value . "n";
}

Access all Keys and values in a hash.

while (my ($key,$value) = each %$refhash)
{
  print "Key: " . $key . " has value:" . $value . "n";
}

Assigning multiple values to a hash

%hasvar = (
  'test2' => 'myval',
  'test3' => 'myval3'
);

Note: This will clear the existing hash.

Delete a value from a hash

delete $hashvar{'key1'};

Delete a value from a hash reference.

delete $hashref->{'key1'};

Tags: , , ,

Perl: Arrays

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Perl, Programming, Scripting | No comments yet.

I use perl arrays in some of my programs, and just started to look at the regular things that I do with these arrays and thought it would be useful to keep a list of frequently used items.

Create a variable specified as an array.

my @vararray

Add an item to the beginning of an array

unshift (@vararray, "File2");

Add an item to the end of an array

push (@vararray, "File1");

Remove an item from the beginning of an array

my $var = shift(@array);

Remove an item from the end of an array

pop(@array)

Clear an array

@vararray = ();

Address an item in an array

print $vararray[0] ; 

Get the size of an array

my $arraysize = @array;

Remove an item based on the index

delete @vararray[1];

Iterate over an array

foreach my $var (@vararay)
{
  print "$var n";
}
 
# or 
my $size = @vararray;
my $i;
for ($i = 0 ; $i < @size; $i++)
{
  print "$vararray[$i]n";
}

Tags: , ,

Linux System utilization tools

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Linux, Scripting, Shell, Utilities | One comment

I was asked about system utilization on Linux systems. I found thesystatset of tools which consist of: sar, sadf, mpstat, iostat, nfsiostat, cifsiostat, pidstat and sa tools.

I will talk about the iostat tool in this article and follow up about some of the other tools.

On Ubuntu or debian systems you can install this toolset with:

sudo apt-get install sysstat

Then you will have access to the iostat command. The command output from executing with no options is below:

# iostat
Linux 2.6.32-33-generic (sumo)  09/01/2011      _i686_  (2 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.11    0.00    0.47    0.01    0.00   99.41

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               0.54         1.85         8.91    1611385    7740024

This displays the avg-cpu utilization and a device usage list with basic utilization.
Some options you can use are

Option Explanation
-c Display CPU utilization only
-d Display Device utilization only
-k Display information in kilobytes
-m Display information in megabytes
-t Display time for each report
-x Display extended statistics

One more way to use the iostat tool is to specify an interval and count to the command

iostat -d -x 10 5

This will display the output 5 more times with 10 seconds between each run.

Tags: , ,

VI: Paste code without formatting

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Editors, Software, Utilities, vi | No comments yet.

I happened to be creating a script and found myself trying to copy and past some functions between them. Well my functions
had some comments and this caused the paste operation into vi to add comments to every line after the first comment.

So this:

sub somefunc {
  # input args
  my $var1 = shift;
  my $var2 = shift;

  if ($var1 < $var2)
  {
    return $var1;
  }
  else
  {
    return $var2;
  }
}

Became this:

sub somefunc {
  # input args
  #my $var1 = shift;
  #my $var2 = shift;
  #
  #if ($var1 < $var2)
  #{
  #  return $var1;
  #}
  #else
  #{
  #  return $var2;
  #}
  #}

This made all my formatting go awry as well, and there were about 4 different functions I was about to cut and past. So I looked into how to make vi accept the text as is without adding formatting. The answer is the paste and nopaste mode.

To enter the mode to allow pasting without formatting:

:set paste

To return to regular mode:

:set nopaste

There are also ways to bind a key to more quickly enter and exit this mode if you are pasting on a regular basis.
That will be in another article.

Tags: ,