Sep
28

Simple jquery confirmation link

JavaScript          Trackback

If you want simple confirmation for link (usually for delete link in your applications) here is simple code you can use:

$('.confirm').click(function() {
return confirm("Are you sure?");
});

Everything you have to do after adding this piece of code is to add “confirm” class to link you want confirm before proceeding.


Sep
20

Get the index of the current element, jquery getEq

JavaScript          Trackback

If you want to grab index of some element you can use this function:

$.fn.getEq = function() { return ($(this).parent().children()).index(this); }

You can call it like this:

$("#someelementid").getEq();


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)


top