adding Adsense to a Coppermine Photo Gallery

May 10th, 2011 No comments

Edit the file /album/themes/classic/template.html (or /album/themes/your-chosen-theme/template.html)
and between {ADMIN_MENU} and {GALLERY} insert the following table configured with your adsense code of course.
In Adsense choose Adsense banner type 728×90


{ADMIN_MENU}

<table width="100%" border="0" align="center" cellpadding="25" cellspacing="0">
<tr>
<td align="center" valign="top">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6999999999";
/* above should be your adsense client number of course*/
google_ad_slot = "7771777345";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
</table>
{GALLERY}

Categories: adsense Tags:

Self-grepping text file (Perl Script)

May 9th, 2011 No comments

This very simple Perl file greps the text which occurs after the __DATA__ marker
The perl code and the text can be edited at anytime by entering the parameter.
Having the script and text together makes it portable.
Adapt the script to your own requirements.

#!/usr/bin/perl
# Description : grep own text
# Version 1.1

if ($#ARGV >= 0){$keyw = $ARGV[0];}
else { print "enter keyword (or -v to edit):"; $keyw=; }
chomp $keyw;

if ($keyw=~/-v/i){system ("gvim $0"); exit;} # edit this file

@info=<DATA>; # read text into array

for $line (@info)
{
print grep /$keyw/i,$line;
}
__DATA__
Arts & Design Category
Art galleries & Museums

* International Galleries and Museums
* US Galleries and Museums
etc etc

Categories: perl Tags:

Wonderful bindkey : assign anything to any key

February 11th, 2011 No comments

I have been working on a laptop a lot recently but it was bugging me that I didn’t have the * key on its own key as you do on a full size keyboard. I realized that I wasn’t using the function keys F1 to F12 at the shell level but didn’t know how to configure. Now my situation is a little complicated as I’m using zsh on cygwin on a Windows 7 PC.

Now I’m used to using bindkey to launch widgets eg control-O to duplicate previous word on the command line , and control-L the hyper-useful suspend current command line entry to allow execution of a single command ie do a quick ls or change a permission etc.
here they are:-

bindkey -M viins ‘^O’ copy-prev-shell-word # copy previous shell word

bindkey ‘^L’ push-line # push current command into a buffer,
These use built-in widgets however the really clever amongst can develop their own.

Anyway I just wanted to reprogram the function keys to output another character or string. I posted a question into the zsh newsgroup and quickly got a reply. I needed the -s option

What you have to do, type the following at your prompt yes actually type Control-V followed by F7

> bindkey -s “^vF7″ “ls -l” # replace the ls -l with whatever you like

Now heres the rub, what you actually see generated is (will vary from system to system)
bindkey -s “^[[18~” ‘ls -l’

this is what you must copy and paste into your shell startup file

This is actually simple enough for me to type these from the CLI for a short-term use. Boy am I going to enjoy using bindkey!

Categories: Cygwin, shell tips Tags:

Activate Windows 7 Recent Documents

January 3rd, 2011 2 comments

Years ago Microsoft announced that Windows would be Data Driven rather than Application Driven. In your Start Menu you could see a list of recent documents worked on images, spreadsheets,databases. You just had to click on one of them to re-open it. Strangely hardly anyone used it, and Microsoft, as is their wont, forgot about it as well. It was however extremely useful, here is how to reenable it in Windows 7.

Right click the Start/Win button, select Properties
Click the Start Menu tab (it should be select as default)
Click the Customize button
Scroll down and check the Recent Items check box
Click Ok
Click Apply
Click Ok
You should now have a “Recent” option in the start menu.

Creating and Using a VIM Scratch File

September 22nd, 2010 No comments

” put following in your _vimrc

” store for useful text, reusable stuff, code sections
map <f4> :tabe c:/aax/store.txt<CR>
imap <f4> :tabe c:/aax/store.txt<CR>

Hit the F4 key to open store.txt  in a separate tab.  I’ve currently  got a few snippets of Perl I need frequently , a few telephone numbers etc. I find it very useful. The VIM maps above are not rocket science and you will see how to vary them for your own requirements.

Categories: vim Tags:

Regexp to split XML Tags into one tag per line

September 20th, 2010 No comments

I was working with an XML file which was all jumbled onto one line. I wanted to split the XML tags out to make them human readable.

This is the Regexp I used puts a carriage return between all >< but not ></

%s#><\([^/]\)#>\r<\1#g

This neatly separates the tags into one tag per line. Note the use of regex memory .

Categories: regexp Tags:

Locking/Protecting Tabs in Firefox

September 18th, 2010 No comments

You have probably known the frustration of accidentally closing a tab you really need eg one where you have been patiently completing a form.  Fortunately there is a Firefox add on Tabberwocky which allows to lock and or protect a tab. I’m not sure of the difference yet but I think one of them means that the tab will reopen the next time you close/open Firefox.

Categories: windows Tips Tags:

Common Programmer Mistakes

August 26th, 2010 No comments

I for my sins code in PHP,Perl,ColdFusion using database MySQL and also write JavaScript, XML and battle with CSS and Ajax etc. Often I’m working on these projects in parallel which gets kind of stressful. Anyway I let my standards slip recently and made the following mistakes and suffered for it.

  • Not immediately taking my own backup of the files I was working so I could rollback at any time and as importantly prove whether my changes had or had not caused a regression or bug
  • Leaving test files lying about, so I later got confused as to which was the actual version
  • In Perl coded the catastrophic error $restart=0 if $cnt=1; (should be if $cnt==1)
  • Also in Perl had some problems due to not systematically initializing variables in a subroutine
  • To my credit have started to use  git for version control
Categories: Coding Tips Tags: ,

VIM 7.3 Released

August 22nd, 2010 No comments

Vim 7.3 is a stability release integrating hundreds of patches. It does contain however some new enhancements.

The most notable additions since 7.2:
- Persistent undo and undo for reload
- Blowfish encryption, encryption of the swap file
- Conceal text
- Lua interface
- Python 3 interface

Persistent undo is probably the feature which most interests me. This allows you to undo changes you made last time you edited a file; a feature which must be used with some care obviously!. It works by saving the changes in a temporary file. A file is created for each file you modify, to avoid cluttering up your directories you can configure vim to use a special directory.

Download the latest VIM here vim.org/download.php

Windows Users can go directly to this link ftp://ftp.vim.org/pub/vim/pc/gvim73.exe which is the simplest way to upgrade. By the way REMEMBER to backup your .vimrc file!!!

Recently I’ve been using the Cream version http://sourceforge.net/projects/cream/files/Vim which maintains an up-to-date single click install version of VIM with all patches it is already at version 7.3.3. And just to confirm this is the version without Cream.

Categories: vim Tags:

How to Tell How long Since a PC has Been Restarted

July 13th, 2010 No comments

From A Dos Window

net statistics workstation

Categories: Uncategorized Tags: