Archive for July, 2008

How to count files in Linux

Posted by Ivan Guan under Linux

To determine how many files there are in the current directory, put in

ls -1 | wc -l.

This uses wc to do a count of the number of lines (-l) in the output of ls -1. It doesn’t count dotfiles, but seems it will count the directory ./

To include subdirectory files, you can use ls -R | wc -l

To ignore directory ./ you can use find . -type f | wc -l

If you want to count only files and NOT include symbolic links (just an example of what else you could do), you could use ls -l | grep -v ^l | wc -l (that’s an “L” not a “1″ this time, we want a “long” listing here). grep checks for any line beginning with “l” (indicating a link), and discards that line (-v).

How to submit Google Sitemap

Posted by Ivan Guan under seo

The Sitemap Protocol allows you to inform search engines about URLs on your websites that are available for crawling. In its simplest form, a Sitemap that uses the Sitemap Protocol is an XML file that lists URLs for a site. The protocol was written to be highly scalable so it can accommodate sites of any size. It also enables webmasters to include additional information about each URL (when it was last updated; how often it changes; how important it is in relation to other URLs in the site) so that search engines can more intelligently crawl the site.

Sitemaps are particularly beneficial when users can’t reach all areas of a website through a browseable interface. (Generally, this is when users are unable to reach certain pages or regions of a site by following links). For example, any site where certain pages are only accessible via a search form would benefit from creating a Sitemap and submitting it to search engines.

Here are 4 simple steps to create sitemap online

 

  • Enter your full website URL and some optional parameters from http://www.xml-sitemaps.com/.
  • Press ‘Start’ button and wait until the site is completely crawled (the progress will be indicated)
  • You will see the generated sitemap details page, including number of pages, broken links list, XML file content and link to a compressed sitemap. Download the sitemap file using this link and put it into the “public_html/” folder of your site.
  • Go to your Google Webmaster account and add your sitemap URL.
    Please check About Sitemaps for more details.

Note Google Webmaster will require you to verify your account by either add a meta tag or upload a html file to your server.

In Windows XP, if you have mapped shared or network drives to beginning letters (i.e., F, G, H), the operating system may fail to assign a drive letter for the Micro Hard Drive. It is best to map all network drives to later drive letters (i.e., O, M, or N).

To see if the operating system is seeing the drive but attempting to assign it to a drive letter already in use, perform the following steps.

  1. Click on your Control Panel
  2. Find the Administrative Tools icon and double click
  3. Double click on Computer Management
  4. Double click on Disk Management
  5. Disk 0 is always the hard drive; so the Micro Hard Drive should appear as Disk 1 or Disk 2 depending on how many hard drives you have, and the assigned drive letter will be visible here*
  6. If you have to change the drive letter, right click on the appropriate Disk and choose Change Drive Letter and Paths
  7. Click on the Change button
  8. Assign a free Drive Letter and click OK

You will get a warning that this may cause some programs to stop running. This could happen if you have scripts directing automated actions to a specific drive letter.

The new drive letter will be assigned and will be seen as the new letter until you reboot the computer or remove the Micro Hard Drive from the port.

*Note: In the Drive Management program any external drives such as a USB Flash drive will been seen in the upper right window, but won’t be seen as a logical drive in the lower right window

 

All in one adsense plugin

Posted by Ivan Guan under Wordpress

I am using all in one adsense plugin for my wordpress. This is a fantastic plugin. However, today I just realized this plugin took 3% of adsense revenue for adding the following lines

$randd = mt_rand(1,19);

if($randd==”2″){
$client_ypn = ’1649076901′;
$channel_ypn = ’64746′;
$client = ’2941637122112958′;
$channel = ’1838017730′;
}

Though it is easy to modified, I think ethically, the author should have noted to the users before they download.

Who Uses the Joomla Title Alias Now?

Posted by Ivan Guan under Joomla

It has no official use at all in Joomla 1.0. Its basically Joomla’s appendix – something that was useful many moons ago but is now just an evolutionary hangover. Yes, you can happily leave it blank. You can also take advantage of quite a large number of components, modules, plugins and hacks that do use the Title Alias.

So Who Uses the Title Alias Now?

  1. Some Search Engine Friendly URL components such as SEF Advance, sh404SEF and Artio SEF. They allow you to use it for the URL. That way to can have a long, interesting page title with lots of odd characters (? – ! ‘ ) and filler words (and, or, the) but still have a short, keyword packed URL. This feature is actually going to become part of the core in Joomla 1.5.
  2. Some modules such as JooFox Content Titles and the Alias for Page Title Plugin (for 1.5). These allos you to use the Title Alias as an HTML Title – an SEO feature sorely lacking in Joomla.
  3. Plugins such as Titlelink. This allows you to easily link to other content items on your site.
  4. Assorted design hacks. At the last Joomla South East meeting, Steven from Intownwebdesign.com showed us a very neat trick that he used to design Schroederslater.com. Many of the pages needed a unique background image so he gave each image the title alias of the page it was going to be used on. He then used PHP and CSS to automatically load the correct titlealias.jpg on each page. Joseph LeBlanc show you how to call the title alias here.
  5. Assorted coding hacks. One example is Phil Braddock‘s hack to allow the HTML title to created from the page title – very similar to the modules in #2.

Today I wanted to remove the left sidebar of my another blog to free up some space. In stead of editing sidebar.php, I found a much simper way of doing it.

Just modify the width of your content in css and change #sidebar { display:none;}, the left bar will just disappear.

It looks like you cannot customize the default content ordering in Joomla.  What you can do is to edit the “Menu Item” linked to the category or section and set “Order By” parameter on the right.

If you choose the option to be “ordering”, then the content will be sorted according to the order set in admin panel.

How this is done?

Embedding a module inside a content page is a Joomla “feature”. You do not need the DirectPHP plugin to enable this.

Ssnobben has rightfully pointed out you need to use something like “{loadmodule mod_fpslideshow}”. So below are the complete steps to achieve this.

Note that the steps below applies to Joomla 1.0.x only. For Joomla 1.5.x, please refer to How to include modules in Content item (for Joomla 1.5.x).

Step 1: Create a new module position

First, we need to create a new module position where this module will be placed.

  1. From the “Site” menu, select “Template Manager” then “Module Positions” as shown below:
  2. Add a new module position “user201″. You could give it any name. I named it “user201″ in this example.
  3. Click “Save” to save the new module position.

Step 2: Create the content page

We will now create a content page for containing the module.

  1. Go to Content Manager and create a new article (static or dynamic).
  2. In the article, enter the following:
  3. This is a test to include a module inside a content item.
    
    {mosloadposition user201}
    
  4. Note that the module name after mosloadposition has to match the module position you have created in Step 1.

Step 3: Set up the module

In this step, we need to do some setting so that the module will appear in the module position.

  1. Let’s first create a module for testing purpose. Go to “Modules – Site Modules”. Look for the module “Main Menu”. Check the box besides the title, and choose “Copy” from the menu.
  2. You will see a new module called “Copy of Main Menu” appearing below the original “Main Meu”.
  3. Click on “Copy of Main Menu”.
    • Set “Show Title” to “No”
    • Select “user201″ for Position
    • Set “Published” to “Yes”
  4. Go to “Page / Items” on the right-hand side and make sure “All” is selected:
  5. That’s it! Save the module. We’re all set!

Step 4: Let’s test it

Now load the article. Did you see the “Main Menu” appearing inside that article similar to the following?

Note: If you wish to put this as the front page, go to Menu Item Manager – Main Menu, create a menu item linked to this content page, then move it to the first item. The content page with the embedded module (for example, it could be a slideshow module) will become the front page.

Source: php-gtk2

Joomla works great with templates, but sometimes you install a new template and you have to check were the new modules positions are.

There are two way to see were each position is:

One is using the code index.php?tp=1 right after your domain URL
For example http://www.sgmoneymatters.com/index.php?tp=1

The second one is by using the function of Joomla in your administor panel that says:

Site -> Preview -> Inline with Positions

You then get a screen with all the Module positions layed out as a screen overlay with the Module numbers and names.

Once you have the positons figured out, you can start placing the modules on the positions you want them to be, moving them around until they fit your needs…

htaccess resources

Posted by Ivan Guan under Webmaster

This is on the List of resource list threads, along with other kinds of useful stuff

5 htaccess Tricks Every Webmaster Should Know

Comprehensive guide to . htaccess – intro

Ultimate htaccess Examples | evolt.org

the jackol’s den » htaccess Cheatsheet – Mikhail Esteves

Stupid htaccess Tricks – Perishable Press

htaccess Magic

Wise-Women: Tutorial: Using the . htaccess File

Fun with . htaccess

Apache Tutorial: . htaccess files

Clockwatchers – . htaccess Tutorial – Introduction

Daring Fireball: Using . htaccess Redirection to Standardize Web …

Hardening HTAccess , Part One

Vortexmind: free your mind » Apache . htaccess tweaking tutorial

Preventing Image Bandwidth Theft With . htaccess (thesitewizard.com)

. htaccess Tutorial – Part 1

Tools

The first link is a really spiffy web-based .htaccess generator. Using it is a great way to learn more–if you make a subdirectory in your public_html directory, you can use it with a .htaccess file to see what happens with the generator’s assorted options.

Reminder: each .htacess file works governs only its own directory and subdirectories below that, until superseded by another, and, like any file with a specific name, only one can exist per directory/subdirectory.

htaccess Generator

. htaccess Tools