<?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>Technical Notes</title>
	<atom:link href="http://emogic.com/notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://emogic.com/notes</link>
	<description>for everyone</description>
	<lastBuildDate>Thu, 08 Dec 2011 19:13:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Prime Numbers up to a million</title>
		<link>http://emogic.com/notes/prime-numbers-up-to-a-million/</link>
		<comments>http://emogic.com/notes/prime-numbers-up-to-a-million/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:42:42 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=31</guid>
		<description><![CDATA[http://www.emogic.com/cgi/primes/nph-primes.cgi Generates prime numbers from 2 to 1,000,000 using Eratosthenes’ prime number sieve. Why? Why not. PERL source code is available: http://www.emogic.com/cgi/primes/nph-primes.txt]]></description>
			<content:encoded><![CDATA[<div id="post-136"><a title="Primes to a million" href="http://www.emogic.com/cgi/primes/nph-primes.cgi" target="_blank">http://www.emogic.com/cgi/primes/nph-primes.cgi</a></p>
<div>
<p>Generates 			 prime numbers from 2 to 1,000,000 using Eratosthenes’ prime number sieve. Why? 			 Why not.</p>
<p>PERL <a href="http://www.somewhereincanada.com/cgi/primes/nph-primes.txt" target="_blank">source 			 code</a> is available: <a title="Primes source code PERL" href="http://www.emogic.com/cgi/primes/nph-primes.txt" target="_blank">http://www.emogic.com/cgi/primes/nph-primes.txt</a></p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/prime-numbers-up-to-a-million/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great Delphi Page</title>
		<link>http://emogic.com/notes/great-delphi-page/</link>
		<comments>http://emogic.com/notes/great-delphi-page/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:41:46 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=29</guid>
		<description><![CDATA[If you are looking for an interesting page that explains how to do some of the more difficult things in Delphi, Pipes, Sockets, etc visit Felix Colobri’s site. Not only does it provide source code to examine, his teaching background &#8230; <a href="http://emogic.com/notes/great-delphi-page/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="post-133">If you are looking for an interesting page that explains how to do some of the more difficult things in Delphi, Pipes, Sockets, etc visit Felix Colobri’s site.</p>
<div>
<p>Not only does it provide source code to examine, his teaching background makes what he says understandable.</p>
<p><a title="FelixColibri" href="http://www.felix-colibri.com/index.html" target="_blank">http://www.felix-colibri.com/index.html</a></p>
<p>Even if you don’t use Delphi, his site will give you some insight on many programming topics, no matter what language you program in.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/great-delphi-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Obfuscator and Compression</title>
		<link>http://emogic.com/notes/javascript-obfuscator-and-compression/</link>
		<comments>http://emogic.com/notes/javascript-obfuscator-and-compression/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:40:23 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=27</guid>
		<description><![CDATA[This is a very good great free JavaScript Obfuscator (makes difficult to read) / Encrypt and it also compresses your code. I use it for my JavaScript code. It saved me from writing my own. http://www.emogic.com/cgi/javascriptobfuscator/]]></description>
			<content:encoded><![CDATA[<div id="post-120">This is a very <span style="text-decoration: line-through;">good</span> great free JavaScript Obfuscator (makes difficult to read) / Encrypt  and it also compresses your code. I use it for my JavaScript code. It  saved me from writing my own.</p>
<div>
<p><a title="JavaScript Obfuscator and Compression" href="http://www.emogic.com/cgi/javascriptobfuscator/" target="_blank">http://www.emogic.com/cgi/javascriptobfuscator/</a></p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/javascript-obfuscator-and-compression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudoku Algorithm Part 2 &#8211; Removing numbers from the board</title>
		<link>http://emogic.com/notes/sudoku-algorithm-part-2-removing-numbers-from-the-board/</link>
		<comments>http://emogic.com/notes/sudoku-algorithm-part-2-removing-numbers-from-the-board/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:39:06 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=25</guid>
		<description><![CDATA[So we now have a 9 x 9 grid with numbers that fit the constraints of Sudoku rules: 1. Each row must contain the numbers 1 to 9. 2. Each column must contain the numbers 1 to 9. 3. Each &#8230; <a href="http://emogic.com/notes/sudoku-algorithm-part-2-removing-numbers-from-the-board/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So we now have a 9 x 9 grid with numbers that fit the constraints of Sudoku rules:</p>
<p>1. Each row must contain the numbers 1 to 9.</p>
<p>2. Each column must contain the numbers 1 to 9.</p>
<p>3. Each 3 x 3 local square must contain the numbers 1 to 9.</p>
<p>Now we have to remove numbers from the board. We can’t just remove any numbers. We can only remove numbers that allow us to solve the puzzle with one solution.</p>
<p>One way to accomplish this is to randomly select a number, remove it then see if we can solve the puzzle. If we can’t, replace the number and try again. If we can, try again.</p>
<p>So obviously we need to write a Sudoku solving algorithm.</p>
<p>MY algorithm uses a while loop:</p>
<p>while ( ($blanksquaresleft == 1) and ($solvable == 1) ) {keep trying to solve the Sudoku grid}</p>
<p>Obviously if there are no blank squares left in our Sudoku’s 9 x 9 grid then our Sudoku grid is solvable as we have filled it in. Return a success code.</p>
<p>The $solvable variable is set to 1 if we have at least filled in one blank square during the last loop. This at least gives us the hope that this 9 x 9 grid is solvable. If, during the last loop, we did not fill in any blank squares, this Sudoku grid is not solvable, so quit and return our failure.</p>
<p>if ( ($LpNS &gt; 0) or ($LpHS &gt; 0) ) {$solvable = 1} #still might be solvable! keep going</p>
<p>else {$solvable = 0} #our algorithm can’t solve this board! quit and return a failure code</p>
<p>The next part we need to code are the algorithms to actually fill in the blank squares.</p>
<p>To my knowledge, there are 7 basic methods to try and solve Sudoku puzzles. Naked Singles (NS), Hidden Singles (HS), Naked Pairs (NP), Hidden Pairs (HP), Intersection Removal (IR), X-Wing (XW), and Y-Wing (YW).</p>
<p>Naked Singles (NS): Naked Singles iterates through all the squares on the board, calculating the possible values in each cell based on Sudoku’s rules listed above. When we find a cell with a single possibility we fill in the Sudoku board with that value.  Then we recalculate all the possibilities based on the number we just added to the Sudoku board.</p>
<p>Hidden Singles (HS): Hidden Singles scan each row, column and 3 x 3 square for the ‘number of possibilities’ for each number ranging from one to nine. When it finds a cell containing a possibility which appears exactly once in a row, column or 3 x 3 square, we fill in the Sudoku board with that value.  Then we recalculate all the possibilities based on the number we just added to theSudoku board.</p>
<p>Naked Pairs (NP):</p>
<p>The first version of Naked Pairs searches each region for two possibility values that occur only twice in, and share two cells, which may or may not contain other possibilities. Because they occur<br />
only in these two cells, one of them must go in one cell and the other in the second. Therefore,<br />
any other values in these two cells may be eliminated.</p>
<p>The second version scans each region for two cells, each containing ONLY the same two possibilities. Because one of these values must occur in each of the two cells, they cannot occur anywhere else in that region, and may be eliminated from the lists of possibilities for every other cell in the region.</p>
<p>Hidden Pairs (HP):</p>
<p>Hidden Pairs are taken care of  by the combination of Naked Squares and Hidden Singles algorithms.</p>
<p>Intersection Removal (IR):</p>
<p>If exactly two or three possibilities exist for a single number in one row or column and they are also confined to one box, their values may be eliminated from the rest of the row or column.</p>
<p>If exactly two possibilities exist for a number in a row or column of a box, the number can be eliminated from the rest of the box.</p>
<p>X-Wing (XW):</p>
<p>Look for a single value that occurs exactly twice in two rows. If the cells containing<br />
the value line up in two columns to form a rectangle, all occurrences of the value may be<br />
removed from both columns. This also works the other way, starting with columns and eliminating<br />
from rows.</p>
<p>Y-Wing (YW)<br />
Y-wings work by eliminating possibilities from intersections of influence. Each cell exerts<br />
a range of influence on all the others cells in the same row, column, and box. Y-wing is a<br />
complex, advanced technique, so we present an example:</p>
<p>Suppose a cell has exactly two possibilities A and B. This cell AB is the pivot. Consider<br />
two cells, AC and BC, which are influenced by AB, but do not influence each other. If they<br />
each share exactly one possibility with AB and exactly one possibility with each other, then<br />
the possibility held in common between AC and BC, C, can be eliminated from every cell in<br />
the intersection of AC and BC’s ranges of influence.</p>
<p>If we finally fill in all the Sudoku squares, we return successfully and try to remove yet another square from the Sudoku board and try and solve that board.</p>
<p>My breakout condition for the Sudoku number removal loop, is set a time limit. My code is sufficiently fast that 2 seconds is plenty to get the Suduku board down to 25 visible numbers.</p>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/sudoku-algorithm-part-2-removing-numbers-from-the-board/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudoku Algorithm Part 1 &#8211; Filling the puzzle</title>
		<link>http://emogic.com/notes/sudoku-algorithm-part-1-filling-the-puzzle/</link>
		<comments>http://emogic.com/notes/sudoku-algorithm-part-1-filling-the-puzzle/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:37:12 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=23</guid>
		<description><![CDATA[Step one of creating a Sudoku puzzle is obviously filling in the whole 9 x 9 grid with numbers that fit the constraints of Sudoku rules: 1. Each row must contain the numbers 1 to 9. 2. Each column must &#8230; <a href="http://emogic.com/notes/sudoku-algorithm-part-1-filling-the-puzzle/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="post-68">Step one of creating a Sudoku puzzle is obviously filling in the  whole 9 x 9 grid with numbers that fit the constraints of Sudoku rules:</p>
<div>
<p>1. Each row must contain the numbers 1 to 9.</p>
<p>2. Each column must contain the numbers 1 to 9.</p>
<p>3. Each 3 x 3 local square must contain the numbers 1 to 9.</p>
<p>After staring at a blank page for a few hours, I decided to see how others tackled the task of creating Sudoku puzzles.</p>
<p>Some  interesting pages I found were:</p>
<p><a href="http://davidbau.com/archives/2006/09/04/sudoku_generator.html" target="_blank">http://davidbau.com/archives/2006/09/04/sudoku_generator.html</a></p>
<p><a href="http://www.sudokuonline.us/make_your_own_sudoku_puzzle.php" target="_blank">http://www.sudokuonline.us/make_your_own_sudoku_puzzle.php</a></p>
<p><a href="http://ostermiller.org/qqwing/" target="_blank">http://ostermiller.org/qqwing/</a></p>
<p><a title="http://www.codeproject.com/KB/recipes/Abhishek_Sudoku.aspx" href="http:///" target="_self">http://www.codeproject.com/KB/recipes/Abhishek_Sudoku.aspx</a></p>
<p>The last link is the one that sparked an idea for my own algorithm.  In broken English the author attempts to explain how he wrote his  program. I misinterpreted parts of his article, but it created a few  good ideas to start my own Sudoku algorithm.</p>
<p>To fill the Sudoku grid, I use what I term a 9 x 9 Potential Array.  What each cell in the Potential Array holds is a list of possible values  that could potentially work in that cell based on Sudoku rules.</p>
<p>With a blank 9 x 9 Sudoku grid, each cell in the Potential Array must be (1..9) as there are no limitations yet.</p>
<p>I then go through every cell in the Potential Array looking for a  list that only contains one number. If it contains one number, that cell  in the Sudoku Game Array MUST become that number.</p>
<p>If there are no lists in the Potential Array containing a single  number, then we find an empty cell in the Sudoku Game Array. In the  corresponding Potential Array, we choose one of the numbers in the  Potential list for that cell and place it in the Sudoku Game Array.</p>
<p>Each time we set a value in the Sudoku Game Array, we must  recalculate the Potential Array based on the values placed in the Sudoku  Game Array. For example, if there is a 7 in row 2, there can be no  other 7’s in the rest of the row. Therefore the all the Potential Array  lists for row 2 will be stripped of the number 7. The same holds true  for the cells column and the local 3 x 3 square that the cell resides  in.</p>
<p>If we find a list in the Potential Array that contains NO values,  then our attempt at filling the Sudoku board has failed, and we must  start again.</p>
<p>Using this method finds a workable Sudoku grid between 1 to ten try’s on average.</p>
<p>The next article will cover the task of removing numbers from the  Sudoku Game Array so we can have a Sudoku puzzle with only one possible  solution.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/sudoku-algorithm-part-1-filling-the-puzzle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filter on a TClientDataSet</title>
		<link>http://emogic.com/notes/filter-on-a-tclientdataset/</link>
		<comments>http://emogic.com/notes/filter-on-a-tclientdataset/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:36:12 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=21</guid>
		<description><![CDATA[Filtering on a TClientDataSet is very powerful. For the longest time I had assumed that there was no way to filter on a field that had a field name with a space in it! I would try the following: Table1.Filter:= &#8230; <a href="http://emogic.com/notes/filter-on-a-tclientdataset/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="post-63">Filtering on a TClientDataSet is very powerful.</p>
<div>
<p>For the longest time I had assumed that there was no way to filter on a field that had a field name with a space in it!</p>
<p>I would try the following:</p>
<p>Table1.Filter:= ‘My field = ‘ + #39 + ‘looking for’ + #39;</p>
<p>And Delphi would squawk that the field ‘My’ did not exist.</p>
<p>I tried to place quotes around the field name. No error occurred, but the filter did not work.</p>
<p>After a long search I came upon a poorly documented fact that square  brackets around the field name work in the TClientDataSet filter!</p>
<p>Table1.Filter := ‘[My field] =’ + #39 + ‘looking for’ + #39;<br />
Table1.Filtered := True;</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/filter-on-a-tclientdataset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bring your Application to the top of the screen in Windows</title>
		<link>http://emogic.com/notes/bring-your-application-to-the-top-of-the-screen-in-windows/</link>
		<comments>http://emogic.com/notes/bring-your-application-to-the-top-of-the-screen-in-windows/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:35:10 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=19</guid>
		<description><![CDATA[I program in Delphi for the Windows environment, but the following should work in most modern programming languages with slight modifications. Since Windows 98, the standard BringToFront() function no longer has the same power. When called, your application’s window remains &#8230; <a href="http://emogic.com/notes/bring-your-application-to-the-top-of-the-screen-in-windows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="post-58">I program in Delphi for the Windows environment, but the  following should work in most modern programming languages with slight  modifications.</p>
<div>
<p>Since Windows 98, the standard BringToFront() function no longer has  the same power. When called, your application’s window remains where in  is in the z-order, and the task button flashes.</p>
<p>I was asked to make our <a href="http://www.emogic.com/software/software/emojic/" target="_blank">Emojic Text Editor</a> have a Stay On Top feature.</p>
<p>The following event routine for a CheckBox was created:</p>
<p>procedure TMainForm.StayOnTopClick(Sender: TObject);<br />
begin<br />
Application.NormalizeTopMosts;<br />
If StayOnTop.Checked then<br />
begin<br />
SetWindowPos(MainForm.Handle, HWND_TOPMOST, 0,0,0,0, SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE);<br />
end<br />
else<br />
SetWindowPos(MainForm.Handle, HWND_NOTOPMOST, 0,0,0,0, SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE);<br />
end;</p>
<p>That worked great until my application tried to save and open it’s  own Modal Form. Then my Modal Form was locked away and inaccessible  under my Topmost window.</p>
<p>So I placed the following around every set of instructions in each of my MenuItem’s Event routines:</p>
<p>procedure TMainForm.SaveMenuItemClick(Sender: TObject);<br />
begin<br />
SetWindowPos(MainForm.Handle, HWND_NOTOPMOST, 0,0,0,0, SWP_NOACTIVATE+SWP_NOMOVE+SWP_NOSIZE);<br />
SaveFile;<br />
StayOnTopClick(self);<br />
end;</p>
<p>Basically I just turn the Stay On Top feature off until the Event is  done, then I check to see if I intend to set the Stay On Top feature  back on.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/bring-your-application-to-the-top-of-the-screen-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Security</title>
		<link>http://emogic.com/notes/internet-security/</link>
		<comments>http://emogic.com/notes/internet-security/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:33:13 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=16</guid>
		<description><![CDATA[The internet is a dangerous place. Every computer on the internet has the potential to connect, or communicate,  with every other computer on the internet. If your computer becomes infected with a Virus, Trojan or Worm your PC could be &#8230; <a href="http://emogic.com/notes/internet-security/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="post-3">The internet is a dangerous place. Every computer on the  internet has the potential to connect, or communicate,  with every other  computer on the internet.</p>
<div>
<p>If your computer becomes infected with a <a title="Virus" href="http://www.webopedia.com/DidYouKnow/Internet/2004/virus.asp" target="_blank">Virus, Trojan or Worm</a> your PC could be used to send spam, launch attacks or commit other  crimes. Your keystrokes can even be monitored remotely, thereby sending  your user names and passwords to a criminal. If you do internet banking  or hold sensitive data on your computer you should be alarmed.</p>
<p>There is no such thing as 100% safe on the internet. New security  breaches are found every day. Today’s Operating Systems and software are  so complex that total security is impossible.</p>
<p>Check some of your vulnerabilities at:</p>
<p><a href="http://www.grc.com/default.htm" target="_blank">https://www.grc.com/</a></p>
<p>Click on the ‘Shields Up’ link.</p>
<p>Then click ‘Proceed’.</p>
<p>Then click on ‘All service ports’.</p>
<p>This will tell you how well your firewall, assuming you have one,  is doing for incoming traffic.</p>
<p>Now that you are scared….</p>
<p>You can minimize your risk of infection by applying the following recommendations. The more you follow, the safer you will be.</p>
<p>1. Keep up with your Operating Systems patches. With a Microsoft OS, just ensure that Automatic Updates is turned on.</p>
<p>2. At the very least use a software firewall. <a href="http://www.zonealarm.com/" target="_blank">Zone Alarm</a> offers a free software firewall or you can purchase their more  comprehensive version. If you can’t stand the alerts generated by a  product such as Zone Alarm, turn on the Windows firewall. Make sure any  ‘exceptions’ under the exceptions tag, were put there by you. Better  yet, purchase a hardware based firewall. If you are on a budget, you can  get a home based router/firewall for $50.</p>
<p>3. Use virus software. Make sure you keep it enabled and the virus  definitions up to date. Too often I see computers riddled with viruses  and see that they have disabled their virus software. <a href="http://www.avg.com/" target="_blank">AVG</a> has both free and commercial virus software.</p>
<p>4. Do not use peer to peer networks. (BearShare, Kazaa, Napster,  BitTorrents)  Everyone loves swag. But guess what, most of the stuff you  find there is riddled with viruses and trojans. Not to mention that  most file sharing is illegal. Peer to Peer technology connects your PC   to multiple unknown sources. Any one of those sources, now knows your IP  address, knows you are there, and can launch an attack.</p>
<p>5. Download (pay for) and use software only by trusted sources. If  you download drivers, virus software, bible software, key generators,  etc from a smaller unknown source it may be loaded with a virus, worm or  trojan. The most likely platform is key generators. Hackers write key  generators then infect it with a virus. They know that greed and  stupidity will overrule honesty and caution in most cases. You are going  to get more than a free license key code for your favorite software. In  one instance, I downloaded some bible freeware which also acted as an  attack platform. In another instance I removed dozens of viruses off a  friends computer on Friday. During the weekend he installed a no-name  firewall program from a suspicious source. It was infected. He brought  it back on Monday riddled with trojans and viruses.</p>
<p>6. Know what your kids are doing on the computer at ALL times. We  were all young and stupid. Even if your kid is a prince or princess, you  still need to ensure that they do not download and install programs,  visit porn or hacking sites (a great way to get a computer virus).</p>
<p>7. Augment your virus software with <a href="http://www.lavasoft.com/" target="_blank">Adaware</a> (free version available). It picks up the things virus software might miss.</p>
<p>8. Make sure your log in user name for your Operating System (OS) has  a corresponding password. No blank passwords. It is just one more  locked door for someone to get through. Use strong passwords. Not your  dogs name, Fluffy.</p>
<p>9. Turn off ‘remote assistance’ and ‘remote desktop’ on your PC.</p>
<p>10. For small businesses, NEVER put client information on an internet  PC. We ordered books online from a small mom and pop internet books  store. Within the week someone ordered books with our credit card from  Thailand.</p>
<p>11. Use a CD or DVD bootable OS to surf the net like <a href="http://www.knoppix.org/" target="_blank">Knoppix</a>. This is not the solution for everyone, but it is one of the safest ways to surf the internet.</p>
<p>12. Turn file shares off. One more door to close.</p>
<p>This is not an exhaustive list, but they are some of the easiest and  most effective ways to prevent an intrusion. Remember, you can never  prevent an attack.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/internet-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mod_rewrite for apache</title>
		<link>http://emogic.com/notes/mod_rewrite-for-apache/</link>
		<comments>http://emogic.com/notes/mod_rewrite-for-apache/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 13:29:37 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://emogic.com/notes2/?p=10</guid>
		<description><![CDATA[I had a written some code to generate dynamic images on our website. I soon discovered that my images were not being listed in Google’s image section. The following URL generates the required image: http://www.somewhereincanada.com/barcode/barcode.php?code=001600064300&#38;mode=gif However, when I tried to &#8230; <a href="http://emogic.com/notes/mod_rewrite-for-apache/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="post-10">I had a written some code to generate dynamic images on our  website. I soon discovered that my images were not being listed in  Google’s image section.</p>
<div>
<p>The following URL generates the required image:</p>
<p><a href="http://www.somewhereincanada.com/barcode/barcode.php?code=001600064300&amp;mode=gif" target="_blank">http://www.somewhereincanada.com/barcode/barcode.php?code=001600064300&amp;mode=gif</a></p>
<p>However, when I tried to save it to my desktop it saves it as  barcode.php.png . Google will not list it in it’s image section as  ‘barcode.php?code=001600064300&amp;mode=gif’ is not a valid name for an  image file.</p>
<p>One solution was to have my script save the generated image to my  server. Then I could redirect web browser’s to the generated image by  returning the text:</p>
<p>&lt;META HTTP-EQUIV=”Refresh” CONTENT=”0; URL=/barcode/images/001600064300.gif”&gt;</p>
<p>But by doing that I am using up valuable space on our web host.</p>
<p>It would be nice if I could have the URL:</p>
<p><a href="http://www.somewhereincanada.com/barcode/images/001600064300.gif" target="_blank">http://www.somewhereincanada.com/barcode/images/001600064300.gif</a></p>
<p>call my script and dynamically generate the image.</p>
<p>This is possible by using Apache’s Module mod_rewrite.</p>
<p>By using mod_rewrite, I can cause the previous URL to call the script barcode.php</p>
<p>See:</p>
<p><a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite" target="_blank">http://www.workingwith.me.uk/articles/scripting/mod_rewrite</a></p>
<p>for more information.</p>
<p>To see mod_rewrite in action, try replacing any of the digits in the  following URL with another. Likewise try replacing .gif with .jpg or  .png</p>
<p><a href="http://www.somewhereincanada.com/barcode/images/001600064300.gif" target="_blank">http://www.somewhereincanada.com/barcode/images/001600064300.gif</a></p>
<p>Now Google will see links of this format as actual images on my site and index them.</p>
<p>To make it all work, the following was required:</p>
<p>In an .htaccess file in our /barcode/ directory is the following text:</p>
<p>&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /barcode/images/<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /barcode/barcode.php [L]<br />
&lt;/IfModule&gt;</p>
<p>The previous .htaccess file tells Apache to turn web requests for:</p>
<p>/barcode/images/001600064300.gif</p>
<p>to</p>
<p>/barcode/barcode.php</p>
<p>Note that the folder ‘/barcode/images/’ does not even exist.</p>
<p><a href="http://www.somewhereincanada.com/barcode/images/hjgksad/asd/asd/001600064300.gif" target="_blank">http://www.somewhereincanada.com/barcode/images/hjgksad/asd/asd/001600064300.gif</a></p>
<p>will generate an image also!</p>
<p>On my first attempt, I added the following code to barcode.php. It strips out the ‘001600064300? and ‘gif’ parts from</p>
<p>/barcode/images/001600064300.gif</p>
<p>found in the PHP variable $_SERVER["REQUEST_URI"]. Then took those  two values and fed them into the routines that would have normally  obtained the values from</p>
<p>?code=001600064300&amp;mode=gif</p>
<p>if ($code == ”)<br />
{<br />
$URIline = $_SERVER["REQUEST_URI"];<br />
//split uri into parts<br />
$urlparts = array();<br />
$urlparts = split(”/”, $URIline);<br />
//get last part image.jpg<br />
$imagename = array_pop($urlparts);<br />
$filenameparts = array();<br />
$filenameparts = split(”.”, $imagename);<br />
$code = $filenameparts[0];<br />
$mode = $filenameparts[1]; //file extension<br />
if ($mode == ”)<br />
{<br />
$mode=’png’;<br />
}<br />
}</p>
<p>If you are comfortable with Regular Expressions, there is a better way to accomplish this.</p>
<p>I could have used mod_rewrite to turn:</p>
<p><a href="http://www.somewhereincanada.com/barcode/images/001600064300.gif" target="_blank">http://www.somewhereincanada.com/barcode/images/001600064300.gif</a></p>
<p>directly into a call to:</p>
<p><a href="http://www.somewhereincanada.com/barcode/barcode.php?code=001600064300&amp;mode=gif" target="_blank">http://www.somewhereincanada.com/barcode/barcode.php?code=001600064300&amp;mode=gif</a></p>
<p>Then I would not have had to modify barcode.php</p>
<p>Here is how I obtained the same results by using Regular Expressions in .htaccess:</p>
<p>&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /barcode/images/<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule ([0-9]+).([a-zA-Z]+)$ /barcode/barcode.php?code=$1&amp;mode=$2 [L]<br />
&lt;/IfModule&gt;</p>
<p>Apache staff say mod_rewrite is difficult to master. So keep it simple.</p>
<p><a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" target="_blank">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a></p>
</div>
<p>Posted in <a title="View all posts in Web Stuff" rel="category tag" href="http://www.emogic.com/notes/category/webstuff">Web Stuff</a> |   <a title="Comment on mod_rewrite for apache" href="http://www.emogic.com/notes/2009/03/07/mod_rewrite-for-apache/%#respond">No Comments »</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://emogic.com/notes/mod_rewrite-for-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

