<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Sniptools &#187; Tutorials</title> <atom:link href="http://sniptools.com/tag/tutorials/feed/" rel="self" type="application/rss+xml" /><link>http://sniptools.com</link> <description>Design &#38; Technology Observations</description> <lastBuildDate>Tue, 15 May 2012 09:23:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Create/Rip MP3 files from your CD</title><link>http://sniptools.com/vault/createrip-mp3-files-from-your-cd</link> <comments>http://sniptools.com/vault/createrip-mp3-files-from-your-cd#comments</comments> <pubDate>Fri, 10 Jun 2005 00:46:57 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=106</guid> <description><![CDATA[from cd to mp3
]]></description> <content:encoded><![CDATA[<p>How to create digital music files from your CD — here's one method. Assumes Windows XP systems.</p><p><span
id="more-106"></span></p><p>Creating MP3 files is quite simple, plenty of ways of doing it. Here's one that works for me, on Windows platforms. It may look daunting thanks to all the detail on this page but it's really quite simple. Should take no more than 10 minutes to get it working.</p><h3>Getting "FreeRip"</h3><p>I use the free MP3 ripper called, quite aptly, <a
href="http://snipurl.com/freerip">FreeRip: Get it free from here</a>. When the dialog box appears to "Open" or "Save" it (the wording may be different depending on your browser) it's fine to just Open and execute it. We don't need the installation file.</p><h3>Installing "FreeRip"</h3><ol><li>Click on through the first few screens that show you license and all the usual stuff.</li><li>The first screen to pay attention to is the one that allows you to create "Desktop Icon", "Quick Launch" icon, etc. On this screen, disable whatever you don't need, but MAKE SURE you disable the  "Install the My Global Search Toolbar". <img
class="quote" src="/av/mp3.gif?348443" alt="Disable Install the My Global Search Toolbar" width="393" height="303" /></li><li>Click on through to the end. On the last screen, you may also want to uncheck "Explore FreeRip community" although leaving this on is not a major mistake.</li><li>That's it, it's done.</li></ol><h3>One-time customization of FreeRip</h3><p>FreeRip is quite easy to use, but it's nice to customize some settings the first time you use it.</p><p>Start FreeRip from your START menu, or from the desktop icon if you allowed that to be installed. It should look something like this: <img
class="quote" src="/av/mp32.gif?348443" alt="FreeRip main interface: reads CD and lists songs automatically"  width="484" height="352" /><br
/> Now, on to customizing. Click on the first menu item called "CD" and then on "Options".</p><ol><li><b>General:</b> Here, uncheck "Show 'please register' reminders". Make sure default format is 1-MP3.</li><li><b>Output Path:</b> Make sure you change the "Base Path" to the location where you would like your MP3 files stored. I've selected the typical "My Music" inside "My Documents". As follows: <img
class="quote" src="/av/mp33.gif?348443" alt="FreeRip main interface: reads CD and lists songs automatically"  width="318" height="281" /></li><li><b>Device:</b> No change.</li><li><b>Encoding:</b> Change "Min Bitrate" to 192. This is usually CD quality, 256 only creates a huge file. If you want to rip music mainly to share, 128 MB is fine too.</li><li><b>Internet:</b> No change, but make sure "3-Offline Mode" is selected.</li><li><b>Extensions:</b> Uncheck "Search bar". You don't need it.</li><li><b>Freedb:</b> Uncheck "Automatically check freedb when online", unless you know what you're doing and would like the feature.</li><li>That's it. We're done. Click on OK.</li></ol><h3>Using FreeRip</h3><p>This is all you'll do from now on. Everytime you want to rip MP3 files from a CD, simply insert the CD and click on CD –&gt; REFRESH. FreeRip will automatically list all the files. You can click on these "tracks" and change their names to whatever the song name is on the CD. Also make sure you enter the Artist and Album name, this will go into the folder that is created for this CD. Next, click on the green tick icon to select all tracks for ripping. Finally, click on the CD icon to start ripping. When done, check your MY MUSIC folder in MY DOCUMENTS, that's where the new folder should have been created.<br
/> <img
class="quote" src="/av/mp34.gif?348443" alt="FreeRip main interface: reads CD and lists songs automatically" width="484" height="352" /></p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/createrip-mp3-files-from-your-cd/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Uninstall &amp; Remove Norton Antivirus completely</title><link>http://sniptools.com/vault/uninstall-remove-norton-antivirus-completely</link> <comments>http://sniptools.com/vault/uninstall-remove-norton-antivirus-completely#comments</comments> <pubDate>Fri, 24 Sep 2004 11:49:16 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[antivirus]]></category> <category><![CDATA[AVG]]></category> <category><![CDATA[Norton]]></category> <category><![CDATA[norton antivirus 2003]]></category> <category><![CDATA[symantec]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[Windows]]></category> <category><![CDATA[windows registry]]></category> <category><![CDATA[XP]]></category><guid
isPermaLink="false">http://sniptools.com/?p=222</guid> <description><![CDATA[Want to try AVG but just cannot get rid of Norton's persistent antivirus that itself behaves like a worm? Here are some instructions that have worked. So you want to use Grisoft's AVG Free as your antivirus, but had Norton antivirus installed before, which is now proving more persistent than a flatulent release in a [...]]]></description> <content:encoded><![CDATA[<p>Want to try AVG but just cannot get rid of Norton's persistent antivirus that itself behaves like a worm? Here are some instructions that have worked.</p><h3>So you want to use <a
href="http://free.grisoft.com/doc/2/lng/us/tpl/v5">Grisoft's AVG Free</a> as your antivirus, but had Norton antivirus installed before, which is now proving more persistent than a flatulent release in a bath, with Symantec's whole <a
title="Symantec on how to uninstall Norton Antivirus" href="http://snipurl.com/hnjr">convoluted shebang</a> only compounding your woes? Well below is a simple sureshot way to get rid of Norton for good.</h3><ol><li>First, from Start –&gt; Cpanel –&gt; Add/Remove programs, remove every trace of Norton and its associated programs, which means scan through the list of installed programs for any item that says "Norton" or "Symantec" or "LiveUpdate" — for example "Symantec LiveUpdate" or "Norton AntiVirus 2003".</li><li>When you are absolutely sure that these vermins are gone, it is VITAL that you reboot the computer. When you are back into XP, delete the following folders manually — if they don't exist that's fine:<pre>
	c:\Program Files\Symantec AntiVirus
	c:\Program Files\Norton
	c:\Program Files\Symantec
	c:\Program Files\Common Files\Symantec Shared
	</pre><p> Do a SHIFT DELETE if possible, the folders don't go into your Recycle Bin in that case, so they are gone from your computer for sure.</li><li>After the above, I usually clean the Windows Registry for any entries that are lying around stray. Get a Registry Cleaner like <a
href="http://www.hoverdesk.net/dl/en/RegSeeker.zip">HoverDesk's RegSeeker (zipped download)</a> and use the "Clean the Registry" option.</li><li>Once that is done and you have SELECTED ALL and deleted the stray items, reboot again. To be sure.</li><li>Norton should be gone when your machine is back up. If not, Symantec has a brute force utility called <a
href="http://www.majorgeeks.com/download3077.html">RNAV2003 — get it here</a>, which ought to do the rest of the scavenging, but it shouldn't come to that.</li></ol> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/uninstall-remove-norton-antivirus-completely/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Netsky Removal: How to get rid of I-Worm.Netsky.A, B, C, D, E..</title><link>http://sniptools.com/vault/netsky-removal-getting-rid-of-iwormnetsky</link> <comments>http://sniptools.com/vault/netsky-removal-getting-rid-of-iwormnetsky#comments</comments> <pubDate>Tue, 10 Feb 2004 04:16:20 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[antivirus]]></category> <category><![CDATA[AVG]]></category> <category><![CDATA[Norton]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[virus]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=71</guid> <description><![CDATA[Netsky Removal getting rid of I-Worm.Netsky
]]></description> <content:encoded><![CDATA[<p>Inadvertently hit by the Netsky family, and been having troubles getting rid of it? Check this step by step removal procedure out.</p><h3>Suddenly getting *.pif attachments in your emails or a bunch of very personal and realistic sounding mails from people you don't even know? That's because the <a
title="Detailed intro to Netsky" href="http://www.viruslist.com/eng/alert.html?id=1069526&lt;br &gt;&lt;/a&gt;">Netsky</a> family has gone primetime and spawned a million and one variants: I-Worm.Netsky.A, I-Worm.Netsky.B, I-Worm.Netsky.C, I-Worm.Netsky.D, and now even I-Worm.Netsky.E.  Many people have tried updating their anti virus definitions for their respective tools, but Netsky is clever (it stores info in the Windows registry, and deletes some vital keys as well!)</h3><div
class="quote comments-wrap">Pls print these instructions as you will eventually have to close Outlook as well as the browser that you will presently use for downloads.</div><p>I use <a
href="http://www.grisoft.com/">Grisoft</a>'s wonderful <a
href="http://www.grisoft.com/us/us_dwnl_free.php">AVG</a> tool, which is great if you had it BEFORE the Netsky virus (but then I also use a combination of <a
href="http://www.spamassassin.org">Spam Assassin</a> and <a
href="http://www.clamav.net">Clamav</a>)</p><div
class="quote"><div
class="comments-wrap"><h3>IMPORTANT NOTE: DISABLING AND ENABLING SYSTEM RESTORE</h3><p>Windows Me/XP uses the System Restore feature (enabled by default) to restore the files on your computer in case they become damaged. If a virus, worm, or Trojan infects a computer, System Restore may back up the virus, worm, or Trojan on the computer as well.</p><p>Windows prevents outside programs, including antivirus programs, from modifying System Restore. Therefore, antivirus programs or tools cannot remove threats in the System Restore folder. As a result, System Restore has the potential of restoring an infected file onto your computer, even after you have cleaned the infected files from all the other locations. Also, a virus scan may detect a threat in the System Restore folder even though you have removed the threat. SO it's best to disable it and then re-enable it after the deletion process.</p><h3>HOW TO DISABLE SYSTEM RESTORE</h3><ul><li>Click Start &gt; Settings &gt; Control Panel.</li><li>Double-click the System icon.</li><li>Click on the System Restore tab and disable the System Restore:<br
/> <img
title="System Restore disable in Windows XP Control panel" src="/av/netsky1.gif?348443" alt="System Restore disable in Windows XP Control panel" /></li><li>Click Yes, when you are prompted to restart Windows.</li></ul></div></div><p>Now that you know how to disable and enable System Restore, let's get cracking.</p><h3>OPTION 1: THE <a
href="http://www.nai.com">MCAFEE</a> WAY (STINGER)</h3><p>McAfee has made a very nifty tool called Stinger available which automatically scans your computer for 39 viruses and deletes them. It's pretty simple to use, just download and execute.</p><ul><li><a
href="http://vil.nai.com/vil/stinger/">Download Stinger</a>.</li><li>Disable System Restore as described above. This will take your system into a reboot.</li><li>When the computer is back again, wun Stinger from your desktop by double-clicking it. Wait, get some coffee, etc etc. This takes time.</li><li>Reboot.</li><li>Optional but recommended if the first run above found some virii: Run Stinger again to make sure your PC is clean.</li><li>Reboot.</li><li>Re-enable System Restore from the Control Panel &gt; System &gt; System Restore (checkbox).</li></ul><p>On my machine with 120GB hard disk, 57% used, 1 GB RAM, this tool took about an hour to scan through all files. Which is probably a worthy price to pay<br
/> for the convenience of automation. Worth a shot for sure.</p><p>If and only if this doesn't work, try the next and somewhat more convoluted tool from Symantec.</p><h3>OPTION 2: THE <a
href="http://symantec.com">SYMANTEC</a> WAY</h3><p>Roll up your sleeves as this is can get a bit involving for people who don't know MS-DOS prompts or some Windows system functionality (although there are screenshots to boot below whenever possible)</p><ul><li>Download the <a
href="http://securityresponse.symantec.com/avcenter/FxNetsky.exe">FxNetsky.exe</a> file. Save the file to a convenient location, e.g.,<div
class="quote"><pre>c:\netsky_remove</pre></div></li><li>Download the file <a
href="http://64.4.206.167/wm-downloads/pub/chktrust.exe">chktrust.exe</a>. IMPORTANT: Save this file as the same location as above:<div
class="quote"><pre>c:\netsky_remove</pre></div></li><li>Now close all programs, including the browser from which you downloaded the above applications. Then, START –&gt; RUN, and type<div
class="quote"><pre>cmd</pre></div><p>This will start the MS DOS PROMPT. Here, type:</p><div
class="quote"><pre>cd c:/netsky_remove
chktrust -i FxNetsky.exe</pre></div><p>Press Enter after typing each command. If the digital signature is valid, you will see the following:</p><div
class="quote"><pre>"Do you want to install and run "FxNetsky.exe"
signed on 3/1/2004 10:33 PM and distributed by:
Symantec Corporation?"</pre></div></li><li>If you are on a network or if you have a full-time connection to the Internet, disconnect the computer from the network and the Internet.</li><li>Disable System Restore.</li><li>Double-click the <code>FxNetsky.exe</code> in your <code>c:\netsky_remove</code> folder to start the removal tool.</li><li>Click Start to begin the process, and then allow the tool to run. Sit back and enjoy the ride. This takes time.</li><li>When the tool has finished running, you will see a message indicating whether W32.Netsky@mm infected the computer. In the case of a removal of the worm, the program displays the following results:<div
class="quote"><pre>Total number of scanned files
Number of deleted files
Number of repaired files
Number of terminated viral processes
Number of fixed registry entries</pre></div></li><li>Reboot the computer.</li><li>If virii were found, then run the removal tool again to ensure that the system is clean.</li><li>If you had disabled System Restore, then re-enable it.</li></ul><p>Let me know if this doesn't work as desired!</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/netsky-removal-getting-rid-of-iwormnetsky/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>Generating JPG/GIF/PNG thumbnails in PHP using imagegif, imagejpeg, imagepng</title><link>http://sniptools.com/vault/generating-jpggifpng-thumbnails-in-php-using-imagegif-imagejpeg-imagepng</link> <comments>http://sniptools.com/vault/generating-jpggifpng-thumbnails-in-php-using-imagegif-imagejpeg-imagepng#comments</comments> <pubDate>Sun, 07 Sep 2003 01:49:49 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=40</guid> <description><![CDATA[Generating JPG/GIF/PNG thumbnails in PHP using imagegif, imagejpeg, imagepng
]]></description> <content:encoded><![CDATA[<p>Don't you just adore the simplicity of PHP? It is a cake walk to create thumbnails in PHP, without any plugins like imagemagick or NetPBM, and it is super fast too. Here's the simple code.</p><p><span
id="more-40"></span></p><h3>Don't you just adore the simplicity of <a
href="http://www.php.net" title="Link to PHP">PHP</a>! It is a cake walk to create thumbnails in PHP, without any plugins like <a
href="/vault/dynamic-thumbnailing-with-imagemagick-in-php.htm">imagemagick</a> or <a
href="http://netpbm.sourceforge.net/">NetPBM</a>, and it is super fast too. Here's the simple code.</h3><p>The following code takes a "source image" from a "source path" and makes a thumbnail out of it, placing the thumbnailed image into a "thumb path." It is fairly straightforward so I won't waste time explaining stuff. Post a comment below if you have any questions or problems.</p><p>- <span
style="color:#f00">Elements that you'll probably have to edit are highlighted in red</span><br
/> – <span
style="color:#080">Comments are in green</span></p><p>Make sure the path for thumbnails is writeable, the imagejpeg function takes care of writing by itself, you don't need to fwrite etc.</p><div
class="code"> &lt;?</p><p>$sourcePath  = '<span
style="color:#f00">images/</span>'; <span
style="color:#080">// Path of original image</span><br
/> $sourceUrl   = '<span
style="color:#f00">http://<b>domain.com</b>/images/</span>';<br
/> $sourceName  = '<span
style="color:#f00">test.jpg</span>'; <span
style="color:#080">// Name of original image</span><br
/> $thumbPath   = $sourcePath . '<span
style="color:#f00">thumbs/</span>'; <span
style="color:#080">// Writeable thumb path</span><br
/> $thumbUrl    = $sourceUrl . '<span
style="color:#f00">thumbs/</span>';<br
/> $thumbName   = "<span
style="color:#f00">test_thumb.jpg</span>"; <span
style="color:#080">// Tip: Name dynamically</span><br
/> $thumbWidth  = <span
style="color:#f00">60</span>; <span
style="color:#080">// Intended dimension of thumb</span></p><p><span
style="color:#080">// Beyond this point is simply code. </span><br
/> $sourceImage   = <a
href="http://www.php.net/manual/en/function.imagecreatefromjpeg.php">imagecreatefromjpeg</a>("$sourcePath/$sourceName");<br
/> $sourceWidth   = <a
href="http://www.php.net/manual/en/function.imagesx.php">imagesx</a>($sourceImage);<br
/> $sourceHeight  = <a
href="http://www.php.net/manual/en/function.imagesy.php">imagesy</a>($sourceImage);</p><p>$targetImage   = <a
href="http://www.php.net/manual/en/function.imagecreate.php">imagecreate</a>($thumbWidth,$thumbWidth);<br
/> <a
href="http://www.php.net/manual/en/function.imagecopyresized.php">imagecopyresized</a>($targetImage,$sourceImage,0,0,0,0,$thumbWidth,<br
/> $thumbWidth,imagesx($sourceImage),imagesy($sourceImage));<br
/> <a
href="http://www.php.net/manual/en/function.imagejpeg.php">imagejpeg</a>($targetImage, "$thumbPath/$thumbName");</p><p><span
style="color:#080">// By now, the thumbnail is copied into the $thumbpath<br
/> // as the file name specified in $thumbName, so display</span><br
/> echo "&lt;img src='$thumbUrl$thumbName' alt=''&gt;";</p><p>?&gt;</p></div><p>This above example is for JPEG format. Replace all occurences of "<code>jpeg</code>" in the above code with "<code>gif</code>" and you're good to go for GIF files! Similarly, you can edit the "<code>jpeg</code>" to "<code>png</code>" and you're good to go. For instance, replace "<code>imagejpeg</code>" with "<code>imagegif</code>" or "<code>imagepng</code>".</p><p>Eventually, you can also cobble together some code to figure out the file type of a <code>$sourceImage</code> dynamically (from a directory on the server for instance) and apply the appropriate functions. This is just an example to give you an idea!</p><p>Just FYI, my setup on the server is as follows:</p><ol><li>Root HTTP folder: <code>/home/domain/public_html/</code></li><li>Images folder: <code>/home/domain/public_html/images/</code> <br
/>This becomes our <code>$sourcePath</code> because this is where the original image comes from.</li><li>Thumbs folder: <code>/home/domain/public_html/images/thumbs/</code> (this folder is CHMODed 744, and is our <code>$thumbPath</code>)</li></ol> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/generating-jpggifpng-thumbnails-in-php-using-imagegif-imagejpeg-imagepng/feed/</wfw:commentRss> <slash:comments>26</slash:comments> </item> <item><title>Catching keyboard events using Javascript</title><link>http://sniptools.com/vault/catching-keyboard-events-using-javascript</link> <comments>http://sniptools.com/vault/catching-keyboard-events-using-javascript#comments</comments> <pubDate>Tue, 27 May 2003 21:30:23 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=25</guid> <description><![CDATA[Catching keyboard events using Javascript
]]></description> <content:encoded><![CDATA[<p>A cross-browser script to catch keyboard events in Javascript with some links for further research if you are interested.</p><p><span
id="more-25"></span></p><p>It is possible to catch key presses in a browser using Javascript. Click below for a cross-browser script to catch keyboard events. Clicking in the first text area and press any keys on  your keyboard (as if to enter text). The second textarea serves as a real-time log and shows you info about what key you pressed.</p><div
class="centerbox"><span
style="width:330px; padding:8px; background:#efefef"><a
href="/jskeys">Catching keyboard events in Javascript</a></span></div><p>For a simpler example, also see <a
href="http://www.faqts.com/knowledge_base/view.phtml/aid/11802">http://www.faqts.com/knowledge_base/view.phtml/aid/11802</a></p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/catching-keyboard-events-using-javascript/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Calculating date differences</title><link>http://sniptools.com/vault/calculating-date-differences</link> <comments>http://sniptools.com/vault/calculating-date-differences#comments</comments> <pubDate>Tue, 27 May 2003 19:47:56 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=24</guid> <description><![CDATA[Calculating date differences
]]></description> <content:encoded><![CDATA[<p>You have two dates (either in your code or in your database columns). How do you calculate the difference between them — in years, months, weeks etc?<br
/> This is one of the most common questions on FAQ sites, and the logic in general is quite simple.</p><p><span
id="more-24"></span></p><p>You have two dates (either in your code or in your database columns). How do you calculate the difference between them — in years,<br
/> months, weeks etc?</p><p>This is one of the most common questions on FAQ sites, and the logic in general is quite simple. Most programming languages give you the ability to get "epoch times" (number of seconds/millioseconds from Jan 1, 1970) from a date. Once you have these for both the dates, you get the difference in number of seconds. Then you can simply divide this number by the number of seconds in each day (60*60*24) to get the number of days between the two dates, and so on.</p><p>Please note however that as a rule of thumb, if you intend to perform these calculations on values from database columns, you should consider calculating within the database itself as that may be the fastest and most efficient way of doing it. Below are some examples (or pointers) for popular databases and PHP. The PHP logic should be applicable to many programming languages unless they already provide handy in-built functions.</p><div
class="code"> <b><br
/> MYSQL:<br
/> </b><br
/> <br
/>    o Take a look at the following functions:<br
/> <br
/>    o PERIOD_DIFF<br
/> <br
/>    o DATE_ADD<br
/> <br
/>    o DATE_SUB<br
/> <br
/>    o From:<br
/> <br
/>    <a
href="http://www.mysql.com/doc/en/Date_and_time_functions.html">http://www.mysql.com/doc/en/Date_and_time_functions.html</a></p><p><b>POSTGRESQL:<br
/> </b><br
/>    o No functions provided, you can use + and — operators.<br
/> <br
/>    o More detailed info about this –<br
/> <br
/>    <a
href="http://techdocs.postgresql.org/techdocs/faqdatesintervals.php">http://techdocs.postgresql.org/techdocs/faqdatesintervals.php</a></p><p><b>SQL SERVER:</b><br
/> <br
/>    o Code sample:<br
/> <br
/>    ldDate1=CTOD(12/01/2002)<br
/> <br
/>    ldDate2=CTOD(02/15/2003) ? (YEAR(ldDate2)+MONTH(ldDate2)/;<br
/> <br
/>    12-YEAR(ldDate1)-MONTH(ldDate1)/12)*12</p><p><b>ORACLE:<br
/> </b><br
/>    o An interesting article on INTERVALs: <a
href="http://snipurl.com/171l">http://snipurl.com/171l</a><br
/> <br
/>    o A readymade procedure: <a
href="http://snipurl.com/171m">http://snipurl.com/171m</a></p><p><b>MS EXCEL:<br
/> </b><br
/>    o <a
href="http://support.microsoft.com/?kbid=214134">http://support.microsoft.com/?kbid=214134</a></p><p><b><br
/>MSACCESS:<br
/> </b><br
/>    o DATEDIFF</p><p><b></b></p><p><b>PHP:<br
/> </b></p><p>&lt;?</p><p>$dateDiff = <span
style="color: #f60">mktime</span>(12,0,0,04,20,2003) — <span
style="color: #f60">mktime</span>(11,0,0,04,20,2003);<br
/> <br
/><span
style="color: #f60">echo</span> 'Difference in seconds: ' . $dateDiff . '&lt;br /&gt;';<br
/> <br
/><span
style="color: #f60">echo</span> '&lt;br /&gt;Years Difference   = '. <span
style="color: #f60">floor</span>($dateDiff/365/60/60/24);<span
style="color: #f60"><br
/>echo</span> '&lt;br /&gt;Months Difference  = '. <span
style="color: #f60">floor</span>($dateDiff/60/60/24/7/4);<span
style="color: #f60"><br
/>echo</span> '&lt;br /&gt;Weeks Difference   = '. <span
style="color: #f60">floor</span>($dateDiff/60/60/24/7);<br
/> <br
/><span
style="color: #f60">echo</span> '&lt;br /&gt;Days Difference    = '. <span
style="color: #f60">floor</span>($dateDiff/60/60/24);<br
/> <br
/><span
style="color: #f60">echo</span> '&lt;br /&gt;Hours Difference   = '. <span
style="color: #f60">floor</span>($dateDiff/60/60);<br
/> <br
/><span
style="color: #f60">echo</span> '&lt;br /&gt;Minutes Difference = '. <span
style="color: #f60">floor</span>($dateDiff/60);</p><p>?&gt;</p><p><b>NOTES</b></p><p>1. The two dates are inside the mktime functions in the first line. Just<br
/> <br
/>for your reference, format of mktime function is as follows:</p><p>    mktime(HOURS, MINUTES, SECONDS, MONTH, DAY, YEAR)</p><p>2. Months difference may not be totally accurate as my code above<br
/> <br
/>approximates 4 weeks in a month (think of February etc). However, it<br
/> <br
/>should suffice for all practical purposes, try it.</p><p>3. For all the differences, if you want precise numbers instead of<br
/> <br
/>rounded integers, please remove the "floor()" functions on the<br
/> <br
/>calculations.  In general though, rounded numbers are what you are<br
/> <br
/>perhaps looking for.<br
/></div> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/calculating-date-differences/feed/</wfw:commentRss> <slash:comments>27</slash:comments> </item> <item><title>Calculating distances from latitude and longitude (PHP)</title><link>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php</link> <comments>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php#comments</comments> <pubDate>Tue, 27 May 2003 18:25:56 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=23</guid> <description><![CDATA[Calculating distances from latitude and longitude (PHP)
]]></description> <content:encoded><![CDATA[<p>Enter latitude and longitude of two places, and find out the distance between them.  Some handy PHP code.</p><p><span
id="more-23"></span><br
/> Enter latitude and longitude of two places, and find out the distance between them. <a
href="/latitudeLongitude.php">Click here</a> to see the working code and to download it.</p> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/calculating-distances-from-latitude-and-longitude-php/feed/</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Dynamic Thumbnailing with Imagemagick in PHP</title><link>http://sniptools.com/vault/dynamic-thumbnailing-with-imagemagick-in-php</link> <comments>http://sniptools.com/vault/dynamic-thumbnailing-with-imagemagick-in-php#comments</comments> <pubDate>Tue, 27 May 2003 18:21:21 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[imagemagick]]></category> <category><![CDATA[imaging]]></category> <category><![CDATA[PEAR]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=22</guid> <description><![CDATA[Dynamic Thumbnailing with Imagemagick in PHP
]]></description> <content:encoded><![CDATA[<p>Here is some sample code that allows you to create a thumbnail automatically (assuming ImageMagick is already installed and functional) (based on the <a
href="http://pear.sourceforge.net/en/packages.imagick.php">imagick</a> PEAR module).</p><h2></h2><h2>Code for dynamic thumbnails using PHP</h2><blockquote><pre>&lt;?php
<span style="color: #ff9900;">
<span style="color: #008000;">// Specify your file details</span></span>
$current_file = 'image.jpg';
$max_width = '150';
<span style="color: #ff9900;">
<span style="color: #008000;">// Get the current info on the file</span></span>
$current_size = getimagesize($current_file);
$current_img_width = $current_size[0];
$current_img_height = $current_size[1];
$image_base = explode('.', $current_file);
<span style="color: #ff9900;"><span style="color: #008000;">
</span><span style="color: #008000;">// This part gets the new thumbnail name</span></span>
$image_basename = $image_base[0];
$image_ext = $image_base[1];
$thumb_name = $image_basename.'-th.'.$image_ext;
<span style="color: #ff9900;"><span style="color: #008000;">
// Determine if the image actually needs to be resized
// and if it does, get the new height for it</span>
</span>if ($current_img_width &gt; $max_width)
{
  $too_big_diff_ratio = $current_img_width/$max_width;
  $new_img_width = $max_width;
  $new_img_height = round($current_img_height/$too_big_diff_ratio);
  <span style="color: #008000;">// Convert the file</span>
  $make_magick = system("convert -geometry $new_img_width x $new_img_height $current_file $thumb_name", $retval);
  <span style="color: #008000;">// Did it work?</span>
  if (!($retval)) {
    echo 'Thumbnail created: &lt;img src="' .$thumb_name .'"&gt;';
  }
  else {
    echo 'Error: Please try again.';
  }
}
else
{
  echo 'No need to resize.';
}</pre><p>?&gt;</p></blockquote> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/dynamic-thumbnailing-with-imagemagick-in-php/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>Using ImageMagick with PHP</title><link>http://sniptools.com/vault/using-imagemagick-with-php</link> <comments>http://sniptools.com/vault/using-imagemagick-with-php#comments</comments> <pubDate>Tue, 27 May 2003 18:19:25 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=21</guid> <description><![CDATA[Using ImageMagick with PHP
]]></description> <content:encoded><![CDATA[<p>There is a PHP module for Imagemagick, <a
href="http://pear.sourceforge.net/en/packages.imagick.php">called imagick</a>, sort of like the one for GD.</p><p>Following is some simple code that has worked for me:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">extension_loaded</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'imagick'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #990000;">dl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'imagick.so'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> imagick_create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
imagick_set_attribute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;quality&quot;</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;magick&quot;</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
imagick_set_attribute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;size&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;98x20&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
imagick_read<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;xc:#cccccc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
imagick_annotate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;primitive&quot;</span>     <span style="color: #339933;">=&gt;</span>  <span style="color: #0000ff;">&quot;text 10,14 hello&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;pointsize&quot;</span>     <span style="color: #339933;">=&gt;</span>  <span style="color: #cc66cc;">16</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;antialias&quot;</span>     <span style="color: #339933;">=&gt;</span>  <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;stroke&quot;</span>        <span style="color: #339933;">=&gt;</span>  <span style="color: #0000ff;">&quot;#000000&quot;</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;font&quot;</span>          <span style="color: #339933;">=&gt;</span>  <span style="color: #0000ff;">&quot;arial.ttf&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> imagick_copy_rotate <span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">270</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: image/png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
imagick_dump<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/using-imagemagick-with-php/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Sablotron XSLT , PHP, Apache on Windows (and a basic  XSLT tutorial)</title><link>http://sniptools.com/vault/sablotron-xslt-php-apache-on-windows-and-a-basic-xslt-tutorial</link> <comments>http://sniptools.com/vault/sablotron-xslt-php-apache-on-windows-and-a-basic-xslt-tutorial#comments</comments> <pubDate>Tue, 27 May 2003 18:06:24 +0000</pubDate> <dc:creator>Shanx</dc:creator> <category><![CDATA[Miscellaneous]]></category> <category><![CDATA[Tutorials]]></category><guid
isPermaLink="false">http://sniptools.com/cms/?p=20</guid> <description><![CDATA[Sablotron XSLT , PHP, Apache on Windows (and a basic  XSLT tutorial)
]]></description> <content:encoded><![CDATA[<p>It is actually quite simple to get it working, but not adequately documented on the PHP website. Get straightforward, bullet point instructions here (installs PHP as a module which is in fact faster than running it as CGI).</p><p><span
id="more-20"></span></p><p>It is actually quite simple to get it working, but not adequately documented on the PHP website. Get straightforward, bullet point instructions here (installs PHP as a module which is in fact faster than running it as CGI).</p><ol><li>Get the latest PHP package from <a
href="http://qa.php.net/">http://qa.php.net/</a> and unzip it. It will automatically create a folder named <span
class="pre">PHP_version</span>. (<em>P.S. Novice users may want to skip this entirely and download PHP, MYSQL etc bundled as<br
/> <a
href="http://www.apachefriends.org/en/xampp-windows.html">XAMPP</a> from Apachefriends.org.</em>)</li><li>Please follow the instructions in the README to install<br
/> Apache as a module (faster than running as CGI). This should include –</p><ol><li
class="alpha">Copying the latest PHP files into your <span
class="pre">C:\PHP</span> or wherever you have your PHP installed,</li><li
class="alpha">Putting your <span
class="pre">PHP.INI</span> file in the right place, mine is in <span
class="pre">C:\WINDOWS</span> (you must have only one valid INI file),</li><li
class="alpha">Copying the <span
class="pre">php4ts.dll</span> file from your downloaded <span
class="pre">PHP_version </span>folder into <span
class="pre">C:\WINDOWS\SYSTEM32</span></li></ol></li><li>Copy all the <span
class="pre">*.dll</span> files from your downloaded<br
/> <span
class="pre">PHP_version\DLL</span> folder into the <span
class="pre">C:\WINDOWS\SYSTEM32</span>.<br
/> This will include the latest <span
class="pre">expat.dll</span> and the<br
/> <span
class="pre">sablot.dll</span>.</li><li>Copy the <span
class="pre">php_xslt.dll</span> from your downloaded <span
class="pre">PHP_version\EXTENSIONS</span> folder into the <span
class="pre">C:\WINDOWS\SYSTEM32</span>.</li><li>Now, open your <span
class="pre">PHP.INI</span> and uncomment the<br
/> <span
class="pre">php_xslt.dll</span> extension.</p><ol
style="margin-left: 0px"><li
class="li0"> <span
style="color:#009900"><br
/> # Remove the semi-colon ";" at the beginning <br
/> # of the line to uncomment the PHP_XSLT extension</span><br
/> OLD LINE –&gt; <span
style="color: red">;</span>extension=php_xslt.dll<br
/> <br
/>NEW LINE –&gt;   extension=php_xslt.dll</li></ol></li><li>Just for reference, my <span
class="pre">HTTPD.CONF</span> file for Apache<br
/> has the PHP module working as follows:</p><ol
style="margin-left: 0px"><li
class="li0"> <span
style="color:#009900"># P.S. The LoadModule should be php4apache<span
style="color: #FF0000">2</span>.dll<br
/> if you use Apache 2</span><br
/> ScriptAlias /php/ "c:/php/" <br
/> LoadModule php4_module c:/php/sapi/<span
style="color:#ff0000">php4apache.dll</span><br
/> <br
/> AddType application/x-httpd-php .php</li></ol></li><li>Restart Apache, and hopefully time to say Bingo! If you have problems, please <a
href="#postcomment">let<br
/> me know</a>.</li></ol><p> <br
/><h1>Testing your PHP XSLT installation:</h1><p>Following is a zip file containing some examples for you to<br
/> test out your XSLT installation. Unzip it into your <span
class="pre">htdocs</span><br
/> folder, it will create a subfolder called <span
class="pre">xsltest</span>.<br
/> Please read the README.TXT file inside this ZIP file for more.</p><div
style="text-align:center"> <a
href="/xsltest.zip?348443" style="text-decoration:none"><img
alt="" src="/av/zip.gif?348443" style="vertical-align: middle; border: 0px" width="15" height="16" /><br
/>   Download zipped code samples</a></div><h1>Important notes to make sure XSLT works with PHP module of Apache:</h1><ol><li>If running PHP as a module gives you problems, make sure you copy the<br
/> <span
class="pre">php4ts.dll</span> file from your downloaded <span
class="pre">PHP_version<br
/> </span>folder into <span
class="pre">C:\WINDOWS\SYSTEM32</span>. This is<br
/> most often the cause of errors.</li><li>Make sure you don't have many copies of the same DLLs lurking around<br
/> in various folders. This is often the problem. Specifically, for instance,<br
/> the same DLLs should not exist in <span
class="pre">C:\WINDOWS\SYSTEM</span> and the <span
class="pre">C:\WINDOWS\SYSTEM32</span><br
/> folders.</li><li>If you are using really ancient versions of PHP (i.e., version less<br
/> than 4.1.xx) then <a
href="http://shanx.com/php/xsl/getXsl.htm">this page<br
/> may be useful</a> to you as well.</li></ol><div
class="quote comments-wrap">If you are reading this, you may also want to check out this <a
href="http://www.zend.com/pecl/tutorials/xslt.php">Zend Tutorial about PECL extension for XSLT processing</a>.</div> ]]></content:encoded> <wfw:commentRss>http://sniptools.com/vault/sablotron-xslt-php-apache-on-windows-and-a-basic-xslt-tutorial/feed/</wfw:commentRss> <slash:comments>137</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 4/14 queries in 0.004 seconds using disk: basic
Object Caching 1187/1211 objects using disk: basic

Served from: sniptools.com @ 2012-05-21 19:31:47 -->
