Simple tricks for Windows Programming automation using batch files

I thought I might mention a few of the simple tricks I use when I am developing…

Keyboard assigned Shortcuts

I often need to restart apache very regularly, ie: every other minute.

This is a real bore when I have to find either a GUI or and command prompt. So I set up shortcuts in windows..

I create batch files to do what ever I want, create a shortcut to the batch file and then assign key strokes to them.

ie:

CTRL+SHIFT+F9 => start apache service

CTRL+SHIFT+F10 => stop apache service

Then all I need to do is keep an eye on the Apache Monitor.

NOTE: You must put the shortcuts in a folder in your Start menu… otherwise they will never run when you hit the assigned keys.

While it seems simple, I have noticed how few people truly automate the tasks they perform again and again and again….

Do it.
This alone saves me hours every week when I have my head in code.

 

Automating a task with Batch file and viewing the results

Use set /p varName=”ask for data” then use the variable to call the correct thing.

You can also use this to stop the box from closing, so you can see the results, put this at the end: set /P Done=”Press return to close.”

Here is an example for an ant build:

@echo off
set /P TARGET=”Please enter Target(clean,compile,build,run,javadoc):”
CMD /C ant %TARGET%
echo ——————————————-
set /P Done=”Press return to close.”
:End

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

How Microsoft caused apache & php_mysql.dll to fail…using VISTA (dwmApi.dll)

The Background

Last week I discovered I had quite a few viruses etc.. on my laptop. So I needed to reformat the hard-drive and re-install WindowsXP before I started my new job.

Now before I did all this, I made sure I had a complete back-up of everything off the machine. NB: this is my main development machine… it is a very nice HP laptop.

Before I did this, I had a very nice fully working development environment, i.e.: Cygwin, IDEs, Java VM (1.4/1.5/1.6), mySQL, all my tools, compilers, disassemblers, apache 2, php 5, remote access etc…

So WHY…. did PHP5 refuse to work when I re-installed it today….?!!!

Well, sit back and I will tell you a story of detective work and a serious mistake that seems to have got through to cause me and others, a huge problem.

The Story

I needed to re-install a php environment today, so I could test the environment I am recommending to my current client.

So I copied everything back on my machine, ran a quick command line PHP test (which worked) and tried to start apache…. and it FAILED… with:
PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\\_dev\\php5\\ext\\php_mysql.dll’

the bug

Considering it had worked on the command line, I thought this was a little strange. But config issues are normal, so… it needed a little work. I am quite used to this, having done it far too many time over too many years.

Over the next FOUR hours… I re-installed apache twice, PHP twice, rebooted a few times and re-ran the configuration at least four times.
NONE OF IT WORKED…

I still had php alone working fine, but php through apache failing… with a message that simply made no sense.

So now I started to get frustrated and went hunting on google..

The Chase

After a while, I found a few forum threads that talked about using Dependency Walker to see what php_mysql.dll actually needed, and why it should be failing.. So I downloaded the software and checked it out.

Dependency Walker immediately reported a failure in the dependencies. DwmAPI.dll.

Ok, that seems a little odd…

So, off I went back to google to see what I could find out.

It turns out that DwmAPI.dll is a Desktop Windows Manager API… and after a load more research I found out… for Windows VISTA…!!!!

Now I was pissed.

The Fury

Some idiot had compiled a dependency to the wrong operating system into one of my tools.

At least I now had a culprit… all I had to do was track down the criminal.

AND GUESS WHAT…. it was Internet Explorer 7.

dwmapi dll not installed

Look at the tree… DwmAPI.dll is a dependency of IEFRAME.dll, which I recently gained, when I decided to bite the bullet and install IE7.

What a £$%&ing mistake that was…

So now I was even more pissed off.

I had spent hours debugging to find an error that should never have existed from the people who created the operating system I depended on.

At least I should be able to fix it.

The Fix

Well, on that point I can at least put one happy note forward.

IE7 uninstalled in 5 minutes… I rebooted… I started apache… I checked the error log files and….. IT WORKED…!

fixed error log

And just to prove a point…
Here is the Dependency Walker result after I had un-installed IE7.

fixed dep walker

 

And the moral of this story…..

IE7, PHP, Apache and the word NOT features quite heavily.

… you work it out. :->

 

But… this has been enough of a serious headache to make me think about ditching windows for a *nix machine. Either OSx or Linux.

Considering I have been a windows(less than fanatical) user for quite a while, mainly due to client pressure… it is ironic that the systems I use to develop and now being pushed off machines that keep me using their software…

To Microsoft:
VERY POOR SHOW…
You have created a bug that makes the primary web development environment crash. And you have done it with your browser.. something the same web developers really need to install for testing.
I AM VERY DISAPPOINTED.
Were I a more paranoid type… I would be suggesting this was deliberate.
FIX IT. NOW.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Eclipse Update URLs

I have been using eclipse for long enough to have often run into the problem of locating the update URL for any specific project and more importantly for the required bits needed to run that extension. So here are all the update URLs I know of:

* Graphical Editing Framework (GEF)
UPDATE URL: http://download.eclipse.org/tools/gef/update-site/releases/

* Eclipse Modeling Framework (EMF)
UPDATE URL: http://download.eclipse.org/tools/emf/updates/

* Java EMF Model (JEM)—from the Visual Editor Project (VEP)
UPDATE URL: http://download.eclipse.org/tools/ve/updates/1.0/

* Web Tools Platform (WTP)
UPDATE URL: http://download.eclipse.org/webtools/updates/

* PHP IDE
UPDATE URL: http://download.eclipse.org/tools/php/updates/

* PHP Development Tool (PDT)
UPDATE URL: http://downloads.zend.com/pdt

* Aptana HTML, CSS, Javascript(APTANA)
http://update.aptana.com/update/3.2/

* PHPEclipse
http://phpeclipse.sourceforge.net/update/nightly (unstable)
http://phpeclipse.sourceforge.net/update/releases

PDT(PHP Development Tools)
http://download.eclipse.org/tools/pdt/updates/

JSEclipse
http://download.macromedia.com/pub/labs/jseclipse/autoinstall/

 

[note: xml?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

GIT on Windows XP (winXP)

I am still experimenting with this… but…

You can get GIT running by simply downloading and running the cgywin installer.

Run the installer in standard configuration, and obviously include GIT… but also make sure to include VIM, as this is required to edit the comments. (PERL is required, but should be in the default installed packages. Make sure it is.)

Finally, you need to fix the whitespace issue caused by the difference between UNIX and WINDOWS carriage-return/line-feed. If you edit a file in a windows tool, it will leave an extra line-feed that triggers the error. The fix for this comes Capi’s Corner

Edit .git/hooks/pre-commit and comment the following lines(c. line 58).

if (/\s$/) { bad_line("trailing whitespace", $_); }

You should now be able to commit properly.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Why Git

I suppose the first thing you should do is watch the videos.

Here is Linus Torvalds explains GIT philosophy to googleTech:

And Randal Schwartz with more details about using GIT

You should now know enough to realise why GIT….

If you are still in egypt… de nile… then here are some thinking points.

these are coming as soon as I organise my thinking….

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Finding a working PHP eBay API…

If you are trying to understand the eBay communication APIs, then you have commited yourself to a BIG leaning curve.

As I have walked the walk already(I worked for eBay), I hope my experiences can help those who follow me up this monumental path..

All eBay programming APIs are designed to talk to the exposed eBay services. These services are constantly evolving. As they evolve, older versions become obsolete.

These older version are usually supported for about 14 months after a new version is created, however, they will eventually fall off the supported list and start to cause API call failure.

So to make sure you can design applications that talk correctly to the eBay services, you need an uptodate API.

FYI: you will need to keep your API up-to-date as well duing the lifetime of your application. As the APIs are really a communication layer, you should be ok calling them directly, rather than implementing your own abstraction layer on top.

So far we have managed to find one fully functional PHP API.
You can get this from IN TRADE SYS at this url:
http://www.intradesys.com/index.php?id=ebay_at_for_php&L=1.

These guys seem to be totally up to date with the current version of the eBay services platform. They also provide a few samples and some basic documentation…

Definetely Recomended if you are looking to develope eBay applications with PHP.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

MediaWiki Info

This is a list of all the important pages I have found in my hunt for development and programming information about mediawiki:

http://meta.wikimedia.org/wiki/Category:MediaWiki_Development - a good list of basic info.

Leading to:

http://www.mediawiki.org/wiki/Manual:Database_access
basics of database access inside mediaWiki extensions.

http://www.mediawiki.org/wiki/Image:Mediawiki-database-schema.png
Main Database Schema in large format png image

http://meta.wikimedia.org/wiki/Documentation:Security
Security documentation, uptodate as of version 1.8.1

http://www.mediawiki.org/wiki/Extending_wiki_markup
How to write a markup extension.

http://meta.wikimedia.org/wiki/MediaWiki_architecture

http://meta.wikimedia.org/wiki/Help:Template

http://meta.wikimedia.org/wiki/Help:Parser_function

http://meta.wikimedia.org/wiki/Help:Variable

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Using Gmail

I have started to use GMail in a serious way over the last few weeks and I must say I am quite impressed. Instead of spending 30 minutes every day doing the spam hunt thing, I am now only killing a couple a day.

I love the conversation thing. Where a reply to a message is added to the previous messages… but I keep losing touch with my conversations. So I have a wish list addition for GMail…

please
please
please
Can we have a flag to put any unread conversations right at the top of the list, as my ongoing conversations are the most important emails.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Mediawiki Hooks

Programming a mediaWiki extension relies on using the Hooking system to edit and update the mediawiki objects to the state you desire. So the first problem is finding the right hooks. I have found 3 ways to do this…

Using the documentation
There is a document called hooks.txt in the docs directory. Read it.

Finding undocumented hooks
At the bottom of hooks.txt are 2 lines that explain this. Simply put, you call a php script.
php ./maintenance/findhooks.php
This finds all the hooks that are missing from the hooks.txt documentation.

Find out the variables being passed to your hook called function
From you mediawiki base directory call: [grep -i -n -r "wfRunHooks" *] this will show all calls to wfRunHooks and allows you to see the line number in the calling file as well as what is being passed to your hook call. This is very useful as the documentation is sparse on the passed variables.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Hello World

I have been told that it is time I started to write my thoughts down. I think the person who made the suggestion (you know who you are) had my best interests at heart, but mostly it was just to stop me plaguing those around me all the time.

I was trained as a Marine Biologist but got into computers instead, which I have been doing for about 15 years. I also have interests in many fields including psychology, philosophy and most sciences. My major research hobby is the functioning of the human brain, but I intend to keep that to a minimum, as here I would like to let loose my ideas, knowledge and finding about anything technical, mostly computers and programming.

Please leave me your thoughts, as a conversation should asways be a 2 way thing.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon
Byting the hand that feeds you…