HowTo: Restore action to open instead of search on drive click ( Windows XP )

I presume this applies only to Windows XP but you can also test on Vista.

Sometimes, for example if you try to change the default icon on a drive in windows ( by the way icon’s for drives can’t be changed like that ) you select a new icon and apply it. You will notice that the default action when clicking on a drive in windows becomes Search ( Find ) instead of Open. That is really annoing isn’t it ?

Well here’s the solution for you :

type regsvr32 /i shell32 in the command prompt ( start / run / cmd ).

It’ll get fixed in no time :)

Comments (1)

HowTo: Start Task Manager in a Remote Desktop Session

Ctrl + Alt + delete on local session will give you the option to open the task manager, but what about if you are remoting into another server ? If you press Ctrl + Alt + Delete in a remote session it will pop up the Task Manager for your local station.

Ctrl + Shift + Esc opens Task Manager in a Remote Session

Leave a Comment

HowTo: manually install .deb packages:

This process only installs the downloaded .

deb package. If the package has dependencies, you may need to install them as well.

First, download your .

deb package via wget or whichever method you prefer. Then on the terminal type dpkg -i packagename.
deb
(replacing packagename with the name of the package).

That’s it ;)

Leave a Comment

HowTo: Create Picture Thumbnails with PHP and GD

Hi, first of all I’d like to wish you all a Happy New Year. Hope you enjoyed your holidays, because I know most of us are now behind the desks again, working.

Now, here’s a nice PHP plugin you can use to generate thumbnails in PHP. It’s called phpThumb and you can get it from phpthumb.sourceforge.net.

First of all take note that this plugin uses the GD or ImageMagick library so be sure you have at least one of them installed on your server/host. I’m using GD and it works just fine. ImageMagick has some extra features that I didn’t need, so be sure to check the official site for more details.

How To use phpThumb:

Copy the contents of the plugin somwhere in your site’s directory ( eg. /lib/phpThumb/ )

Rename the phpThumb.config.php.default to phpThumb.config.php. I didn’t modify this config at all but you might take a look inside it if you’d like to setup various parameters.

Having that done you can easily generate thumbnails like this:

<img src=”lib/phpthumb/phpThumb.php?src=nameofthefile.jpg&w=150&h=50&zc=1″  alt =”someText” />

w stands for width of course and h stands for height. zc means zoomCrop.

The plugin has a lot of other options and tweaks to play with, check’em out here.

Enjoy

Leave a Comment

URL rewriting with .htaccess

If you’re looking for this, you know why you need it. But just in case you’ve stumbled upon this and are curious, URL rewriting is useful for several reasons:

1. Accessibility: most people will rather remember a path that looks like http://www.example.com/products/shoes/12/ than http://www.example.com/index.php?category=products&type=shoes&productid=12

2. Security: granted, this is security through obscurity, but at the very least it will hide from most users the server-side technology used (PHP, ASP, etc) and the passed variable names

3. SEO compliance: Web crawlers work by following links and caching the content found; however, they don’t parse anything beyond the filename, so generally index.php?category=products, index.php?category=pages and index.php are seen as a single address, index.php. On the other hand, /products/, /pages/ and / are seen as 3 separate folders, and your content will thus be indexed correctly.

So, you’re thinking “Yes, that would be nice” (or alternatively, “Yeah yeah,get to the point already”). What do you need?

Well, first of all, your pages have to be hosted on an Apache server. Since over 50% of the servers in the world run on Apache, that shouldn’t be a problem.

Secondly, it should have mod_rewrite activated. This is a bit trickier; most hosts have it on by default, but you should probably check with your host.

Finally, a good grasp of regular expressions helps, but isn’t mandatory.

So,  for basic URL rewriting, create a new file containing the following:

RewriteEngine On
RewriteRule ^$ index.php
RewriteRule ^([a-z0-9]+)(/)?$ index.php?page=$1 [NC]

This assumes, of course, that your paging is driven by  a variable called page :)

Save this file as .htaccess

Please note that .htaccess is the actual extension of the file, the filename being blank. If you save it as, for instance, .htaccess.txt, it will not work.

Here, the first line activates mod_rewrite. The second line redirects all incoming requests to index.php. Finally, the last one takes any input, followed by a slash or not, case-insensitive, and redirects it to index.php?page=[the input]

You should however be careful with this, as a user with malicious intent might exploit this. Thus, in your code, you should sanitize all the inputs, or, in case you only have a few “main” pages (such as About, Tutorials, Links and Downloads, for instance) you could modify the last rule thus:

RewriteRule ^(about|tutorials|links|downloads)(/)?$ index.php?page=$1 [NC]

This can be further modified, adding whatever RegEx you need. So, you use our first example, you can write

RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/([0-9]+)(/)?$ index.php?category=$1&type=$2&productid=$3 [NC]

I hope you found this useful :)

Update: For RegEx goodness, have a look at this article Mike Malone has posted: The absolute bare minimum every programmer should know about regular expressions

Leave a Comment

Adobe After Effects subtitle script

So suppose you have a nice AE project, but for some reason you also want the dialogue captioned/subtitled. There are (at least) two easy ways to do this:

1. The obvious/boring one: Create a new text layer, style/position it, enter the text for the first bit, add opacity changes or trim the layer to display the text, repeat for every single piece of dialogue, die of old age before you get to render.

2. The script way:) (ie, the one this post is about)

Now, to do this, you’ll need to do the following:

a. Copy the script provided  at the end of this post, and save it under a sensible name (such as Subtitles.jsx)

b. Create a TXT file with all the subtitles. Each one should go on its own line; in case you want several lines to be visible at the same time, you can separate them with the pipe character ( | )

c. Create / style / position a new text layer in your composition. With the layer selected, add markers (NumPad * ) every time a line should be shown / hidden

d. Run the script

e. Select the text file

That’s all there is to it :)

Below, a super quick-n-dirty preview of the result:

Subtitle script demonstration from !Rocky on Vimeo.

Also, I know this isn’t exactly IT related, nor the most optimised script ever, but it might be useful to someone :)

{
	//	Subtitle generator by !Rocky
	//	modified by Colin Harman ( http://colinharman.com/ ) to work on a Mac
	//
	//	Save this code as
	//	"subtitles.jsx"
	//
	//	Create a text file with your subtitles.
	//	Each line of text is one on-screen line.
	//	To have several lines on-screen at the same time,
	//	simply separate them with a pipe ( | ) character.
	//	eg "Character 1 talks|Character 2 interrupts"
	//
	//	Create a new text layer in your comp, adjust its position,
	//	make sure the text's centered, so it looks nice
	//	Add markers (Numpad *) where each subtitle line must be shown/hidden.
	//	With the text layer selected, run the script, and select the subtitles file.
	//	Enjoy!

	function makeSubs() {
		var layer = app.project.activeItem.selectedLayers[0];

		if (layer.property("sourceText") != null) {
			var textFile = fileGetDialog("Select a text file to open.", "");
			if (textFile != null) {
				var textLines = new Array();
				textFile.open("r", "TEXT", "????");

				while (!textFile.eof)
					textLines[textLines.length] = textFile.readln();

				textFile.close();

				var sourceText = layer.property("sourceText");
				var markers = layer.property("marker");

				for (var i = sourceText.numKeys; i >= 1; i--)
					sourceText.removeKey(i);

				var line = 0;
				var subTime, subText;
				for (var i = 1; i <= markers.numKeys; i++) {
					subTime = markers.keyTime(i);
					sourceText.setValueAtTime(0, " ");

					if ((i % 2) == 0) {
						subText = " ";
					}
					else {
						subText = textLines[line].replace("|", "\x0d\x0a");
						line++;
					}
					sourceText.setValueAtTime(subTime, new TextDocument(subText));
				}
			}
		}
	}
	makeSubs();
}

Comments (1)

Javascript Website Preloader

Here’s a nice java based website preloader I found recently. I needed it for a project and I think this might be useful to others too. Credits for this go to USINGIT.COM.

So here’s how you should use it :

Copy the following lines in to the header of the webpage:

<SCRIPT LANGUAGE=”JavaScript”>

<!– Begin
function clearPreloadPage() { //DOM
if (document.getElementById){
document.getElementById(‘prepage’).style.visibility=’hidden’;
}else{
if (document.layers){ //NS4
document.prepage.visibility = ‘hidden’;
}
else { //IE4
document.all.prepage.style.visibility = ‘hidden’;
}
}
}
// End –>
</SCRIPT>

Now add this to you body tag:

<BODY onLoad=”clearPreloadPage();”>

Then, in the body of the actual website, add the following that will display a loading message until the content of yout page is fully loaded.

<div id=”prepage” style=”position:absolute; font-family:arial; font-size:16; left:0px;top:0px; background-image:url(images/mainBg.gif); background-repeat:repeat; height:100%; width:100%;”>
<div style=”padding-top:350px; text-align:center;”><img src=”images/loading.gif” height=”20″ width=”20″ /><span style=”font-size:19px; color:#000000; height:”> Se Incarca…</span></div>

You can customise the first div and add your own background or whatever you want but keep its id = “prepage” and the position:absolute; left:0px;top:0px; elements in its style. Then, in the second div, place whatever text or animated gif you’d like to be displayed until the page is loaded.

Leave a Comment

HowTo: bcc all recieved or sent mail from your postfix server

Postfix has the option to bcc all sent or recieved emails for a specific domain.

You can bcc all recieved mails for a specific by inserting the following in to /etc/postfix/main.cf :

recipient_bcc_map = pcre:/etc/postfix/bcc_recipient

then edit the file /etc/postfix/bcc_recipient and add your domain like this :

/(.*)@(example.com)/  backup@example.com

then at the console type postmap /etc/postfix/bcc_recipient to load the bcc recipients database. This will create the file /etc/postfix/bcc_recipient.pcre which is the database for bcc recipients.

Run postfix reload to insert the new options in postfix’s config. Now all the e-mails for example.com will be automatically bcc-ed to backup@example.com

______________

If you want to bcc al sent e-mails from a specific domain do the following :

Insert the following into /etc/postfix/main.cf :

sender_bcc_map = pcre:/etc/postfix/bcc_sender

then edit the file /etc/postfix/bcc_sender and add your domain like this :

/(.*)@(example.com)/  backup@example.com

then at the console type postmap /etc/postfix/bcc_sender to load the bcc senderdatabase. This will create the file /etc/postfix/bcc_sender.pcre which is the database for bcc senders.

Run postfix reload to insert the new options in postfix’s config. Now every e-mail sent from example.com will get bcc-ed to backup@example.com

Leave a Comment

HowTo : install the mail command under Debian

The mail command under Debian distros is a part of the mailutils package.

Simply use :

apt-get install mailutils

and you’re  done !

Leave a Comment

Howto: Increase apt-get’s cache limit

Dynamic MMap ran out of room

getting the above error means that your apt cache is out of space. This is solved simply by editing

/etc/apt/apt.conf or /etc/apt/apt.conf.d/70debconf and adding the following line :

APT::Cache-Limit “10000000″; ( this is equal to 10m, set it to whatever you want or need )

That’s it but remember that by increasing the cache you might end up with a full drive so run:

apt-get clean

once in a while.

Leave a Comment

Web Brands