Mar
31

Convert Excel date format to MySQL date format

SQL          Trackback

If you are trying to upload CSV file into your MySQL database, and that file contains date field, you’ll have to convert it first because MySQL will not recognise Excel date format (for English(US) it is m/d/yyyy h:m).
All You have to do is:

  1. Open your xls (or csv) file in MS Excel,
  2. Highlight cells containg date,
  3. Right click and select “Format Cells…”,
  4. Select “Custom” category,
  5. Enter “yyyy-mm-dd hh:mm:ss” in Type filed

After you save file as CSV, you should have your date fields formatted for MySQL use.


Mar
16

Preview PDF in PHP

PHP          Trackback

If you want to create preview image of some pdf you have on your site, all you need is web server that has installed Imagick. If you are lucky enough to have that you can use this code:

<?
$preview = new imagick('somepdf.pdf[0]'); /* read first page of PDF */
setImageFormat('jpeg'); /* set preview format to jpeg */
header('Content-Type: image/jpeg'); /* display preview */
echo $preview;
?>


Oct
21

Multiple Instances of Portable Firefox

Tutorials          Trackback

In my everyday work I’m using Portable Firefox which I’m carrying around on my usb stick. Nice thing with Firefox is that it allows you to have multiple profiles. I have regular Firefox installed on my machine and I’m using it for regular browsing (so I don’t need web developing extensions). Problem was that I couldn’t run Firefox Portable and regular Firefox at the same time. But I found solution and here it is. All you have to do is:

  1. Find a file named FirefoxPortable.ini (located in FirefoxPortable\Other\Source)
  2. Copy that file to your FirefoxPortable folder (one that has FirefoxPortable.exe in it)
  3. Edit that FirefoxPortable.ini file, change AllowMultipleInstances to true

and that’s it. You can now run multiple instances of Firefox (either Portable or regular one)


Aug
08

Detect enter key pressed

JavaScript          Trackback

Do you want to detect if somebody pressed enter on your form (maybe to prevent form submitting when someone press enter key). Here is jquery code that can help you to detect enter key being pressed:

$('input').keyup(function(e) {
	if(e.keyCode == 13) {
		alert('Enter key was pressed.');
	}
});

If you want to disable Enter key submitting youw form you can use something like this:

$("form").bind("keypress", function(e) {
	if (e.keyCode == 13) return false;
});


Jul
18

CSS Browser Hack, different browsers, different styles

CSS          Trackback

I am totally against any CSS hacks, but sometimes if you need quick result, and you need everything to work and look exactly the same in both Firefox and IE you just have to use them. Here is simple CSS hack that you can use to apply different styles depending on browser your visitor is using.

div.test {
	background:blue;	/* Firefox, Opera */
	#background:green;	/* IE7 */
	_background:red;	/* IE6 */
}

First background style is compatible with all browsers (and Firefox and Opera will use this one, and stop there)
Second one (#background) will be ignored by Firefox, and you will see it in IE7, but IE7 will ignore
Third one (_background) and you will see this one just in IE6…

See this demo:
Demo
What color is a background on your screen?
css-different-browsers-different-styles


top