<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4573350696846475792</id><updated>2012-01-14T09:05:44.424-08:00</updated><category term='linux'/><category term='snippets'/><category term='sql group by'/><category term='gravatar'/><category term='Wordpress'/><category term='mysql'/><category term='group by'/><category term='security'/><category term='theme'/><category term='Paco de Lucia'/><category term='stylesheet'/><category term='spaihttp://www.blogger.com/img/blank.gifn'/><category term='hash'/><category term='Perl'/><category term='lifehacker'/><category term='youtube'/><category term='prime numbers'/><category term='duplicates'/><category term='seo'/><category term='firefox'/><category term='Drupal'/><category term='pivot table'/><category term='euler project'/><category term='excel'/><category term='css'/><category term='sql'/><category term='data analysis'/><category term='unix'/><category term='html'/><category term='graphic link'/><category term='MD5'/><category term='cron'/><category term='start-ups'/><category term='ms-access'/><category term='password'/><category term='google'/><title type='text'>MarkFightsCode</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-5717267981239683743</id><published>2011-12-27T04:30:00.000-08:00</published><updated>2012-01-05T08:18:34.808-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='start-ups'/><category scheme='http://www.blogger.com/atom/ns#' term='seo'/><category scheme='http://www.blogger.com/atom/ns#' term='spaihttp://www.blogger.com/img/blank.gifn'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>A start in SEO.</title><content type='html'>A long time since I posted here. I have to admit my attention has been grabbed by the necesity of finding things to do that may secure me future contracts.&lt;br /&gt;My latest project has been &lt;a href="http://www.spainupnews.com/"&gt;UpSpainNews&lt;/a&gt; which is a directory of start-ups from Spain. One thing puzzled me about this site - why was my website not in the first few pages of  Google search? It is (so far as I know) the only web directory specifically on Spanish start-ups in the English language. Of course you can come across some of those entries if they are listed in Crunchbase or in AngelLists, but my listing is fairly unique. Yet Google doesn't recognise this if you search for "Spanish start-ups".&lt;br /&gt;So the last week or two I've been looking into the murky world of SEO. The first thing I realised I didn't do, was to put relevant meta-tags on my web-site. I've now entered a line in my html code as follows:&lt;br /&gt;&lt;blockquote&gt;&lt;pre id="line1"&gt;&amp;lt;&lt;span class="start-tag"&gt;meta&lt;/span&gt;&lt;span class="attribute-name"&gt; name&lt;/span&gt;=&lt;span class="attribute-value"&gt;"description" &lt;/span&gt;&lt;span class="attribute-name"&gt;content&lt;/span&gt;=&lt;span class="attribute-value"&gt;"A directory of Spanish start-ups, the best way to read up on those start-ups in English" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;With luck, the Google robots will pick this description up in the next week or two. It means that when my page is listed on a google search, the description will be shown as above ie "A directory of Spanish start-ups, the best way to read up on those start-ups in English". Instead of the current text which is "&lt;span class="st"&gt;About this site · Directory of Startups · Company  entries; General Up news; Contact. Startup of the week. Screenshot.  Adtriboo - source talent! Internet jobs" and is obviously a mish-mash from the site text.&lt;br /&gt;That in itself won't put me on page 1. I also have to get more backlinks to the site, and (perhaps more importantly) get articles published on other sites that link back. I have made a start by donating articles to &lt;a href="http://www.eu-startups.com/"&gt;EUStartUps.com&lt;/a&gt; and &lt;/span&gt;&lt;a href="http://www.eu-startups.com/"&gt;&lt;span class="st"&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="st"&gt;hope to continue along this line.&lt;br /&gt;I hope to edit this article in a week or two with better news on my Google page ranking.&lt;br /&gt;&lt;br /&gt;EDIT 5 Jan. The google bots have updated their records, and my site now makes it onto Page 2 for the search &lt;span style="color: rgb(153, 0, 0);"&gt;"Spanish startups"&lt;/span&gt;. Also, I come in top of Page 1 when I search on &lt;span style="color: rgb(153, 0, 0);"&gt;"Spanish startups directory"&lt;/span&gt;. :)  In order keep this good position, I will now try to build up links on high ranking sites, and perhaps continue to write articles for other sites that link to my site. I've made a start with this entry &lt;a href="http://www.eu-startups.com/2012/01/5-spanish-start-ups-to-look-out-for-in-2012/"&gt;Spanish start-ups to look out for in 2012&lt;/a&gt;. Happy reading!&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-5717267981239683743?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/5717267981239683743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2011/12/start-in-seo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/5717267981239683743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/5717267981239683743'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2011/12/start-in-seo.html' title='A start in SEO.'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-6497849077323030202</id><published>2011-05-07T08:44:00.000-07:00</published><updated>2011-05-07T09:03:38.869-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal'/><category scheme='http://www.blogger.com/atom/ns#' term='cron'/><title type='text'>Running cron jobs for Drupal on a shared host.</title><content type='html'>Ok, this isn't normally the hardest thing in the world to set up, but as I didn't have shell access I didn't get around to doing this (and ran the cron jobs manually).&lt;br /&gt;In fact, setting up automatic cron jobs via Cpanel is quite easy (and you can read more about this - &lt;a href="http://drupal.org/node/369267"&gt;here&lt;/a&gt;&lt;br /&gt;On Cpanel, in the "Advanced Section" you can click on cronjobs. There are fields you can enter to determine how often the cron job is run. For example, if you enter 15 in the Minute box, the job can be run at 15 minutes past the hour. The top box allows common settings eg once a week, or once a hour, so you don't need to enter criteria directly into every box. The most important task though is to enter your command line correctly. If you have lynx enabled on your Linux server, you may wish to use that, but the wget command is probably more common on nix boxes. So for my job at www.mygreatsite.com I put in the following command:&lt;br /&gt;&lt;blockquote&gt;&lt;code id="command_htmlsafe_3"&gt;wget -O - -q -t 1 http://www.mygreatsite.com/cron.php&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/blockquote&gt;The -t 1 switch merely states try again once upon failure.&lt;br /&gt;Anyway after pressing the "Add Cron job" button, that's all that needs to be done. The crontab program will perform your regular updates from now until the program is modified, or the server blows up!&lt;br /&gt;If only other IT tasks were so easy to set up and then leave alone.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-6497849077323030202?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/6497849077323030202/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2011/05/running-cron-jobs-for-drupal-on-shared.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/6497849077323030202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/6497849077323030202'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2011/05/running-cron-jobs-for-drupal-on-shared.html' title='Running cron jobs for Drupal on a shared host.'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-1936008671702199819</id><published>2010-12-27T04:37:00.000-08:00</published><updated>2010-12-27T04:47:29.907-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pivot table'/><category scheme='http://www.blogger.com/atom/ns#' term='sql group by'/><category scheme='http://www.blogger.com/atom/ns#' term='data analysis'/><category scheme='http://www.blogger.com/atom/ns#' term='excel'/><title type='text'>How to replicate a "GROUP BY" clause in Excel</title><content type='html'>As a Data analyst, I often use the “group by” clause in sql to aggregate records against a key field. For instance, to bring back records where a field has greater than 10 entries I’d use a statement like “select city, count(*) from city_sales group by city having count(*) &gt; 10”&lt;br /&gt;However I’m currently in a role where I can’t use a database :( So, can Excel do the business? Well yes, pivot tables can provide a workaround. It’s a bit more involved than using a decent database (and obviously you’d need that database if you’re dealing with hundreds of thousands of rows) but at least it’s an option.&lt;br /&gt;Here’s a short example. Supposing I have various sales records for different cities (see data below). I’ve just listed a few records, but there could be 100s or 1000s of records. Supposing I wanted to see the total sales figure, for those cities with greater than 3 sales?&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ymeKZIyQhz8/TRiJPZ5n9_I/AAAAAAAAABU/F5KQy_yYs7I/s1600/piv1.bmp"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 200px; height: 120px;" src="http://3.bp.blogspot.com/_ymeKZIyQhz8/TRiJPZ5n9_I/AAAAAAAAABU/F5KQy_yYs7I/s200/piv1.bmp" alt="" id="BLOGGER_PHOTO_ID_5555341038105130994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What I’d do is create a couple of pivot tables. The first one involves putting the city in the row label, and then putting the inv_num field in the data values area. Note that I have to change the “Value field settings” here to show the count (and not the sum). It’s then easy enough to change the sort by to a descending sort on the count of inv_num.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ymeKZIyQhz8/TRiKNTIMihI/AAAAAAAAABk/J53YshmVx3o/s1600/piv2.bmp"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 320px; height: 192px;" src="http://4.bp.blogspot.com/_ymeKZIyQhz8/TRiKNTIMihI/AAAAAAAAABk/J53YshmVx3o/s320/piv2.bmp" alt="" id="BLOGGER_PHOTO_ID_5555342101439089170" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I now create a similar pivot table, but this time I put the Amount field  into the Data Value, and this time keep the formula as “Sum of”.&lt;br /&gt;&lt;br /&gt;It’s now a simple matter to copy the relevant data, and then use VLOOKUP to bring back the sum of sales for those cities you’ve brought back.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_ymeKZIyQhz8/TRiJucH732I/AAAAAAAAABc/SoYTiQGteqU/s1600/piv3.bmp"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 320px; height: 192px;" src="http://3.bp.blogspot.com/_ymeKZIyQhz8/TRiJucH732I/AAAAAAAAABc/SoYTiQGteqU/s320/piv3.bmp" alt="" id="BLOGGER_PHOTO_ID_5555341571277971298" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Remember I can also put a field in the Report filter (equivalent to a Where clause in sql) so I could (for example) select only cities from a specified area.&lt;br /&gt;I still prefer sql by far for this type of calculation, but if Excel is your only tool, at least we have this option of the pivot tables.&lt;br /&gt;Hope this is of use to someone out there!&lt;br /&gt;Mark&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-1936008671702199819?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/1936008671702199819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2010/12/how-to-replicate-group-by-clause-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1936008671702199819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1936008671702199819'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2010/12/how-to-replicate-group-by-clause-in.html' title='How to replicate a &quot;GROUP BY&quot; clause in Excel'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_ymeKZIyQhz8/TRiJPZ5n9_I/AAAAAAAAABU/F5KQy_yYs7I/s72-c/piv1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-2568954452738839338</id><published>2010-10-24T04:04:00.000-07:00</published><updated>2010-10-24T04:15:15.428-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Wordpress'/><category scheme='http://www.blogger.com/atom/ns#' term='stylesheet'/><category scheme='http://www.blogger.com/atom/ns#' term='theme'/><title type='text'>Getting Wordpress to use stylesheet on new theme</title><content type='html'>Sometimes you miss the b***** obvious. I'd started making a theme from scratch in Wordpress, put the correct reference to the link in the header file, and made sure the css file was correctly named and in the correct theme folder. But no matter how many times I reloaded the page, the css rules were not imported.&lt;br /&gt;It turns out I hadn't called the header php page from index.php . I should have put this &amp;lt;?php get_header(); &amp;gt;  in the index.php file. All that time wasted due to a simple oversight! It is an occupational hazard when programming, but it's  so frustrating. :(&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-2568954452738839338?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/2568954452738839338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2010/10/getting-wordpress-to-use-stylesheet-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/2568954452738839338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/2568954452738839338'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2010/10/getting-wordpress-to-use-stylesheet-on.html' title='Getting Wordpress to use stylesheet on new theme'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-4550301087202116982</id><published>2010-10-09T01:48:00.000-07:00</published><updated>2010-10-09T02:16:40.747-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Wordpress'/><category scheme='http://www.blogger.com/atom/ns#' term='graphic link'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>How to use a graphic to link elsewhere in WordPress</title><content type='html'>I wanted to change a graphic image into a clickable link, on a Wordpress site (&lt;a href="http://www.losarbitroscuentan.com/"&gt;La Liga referee statistics&lt;/a&gt; )I've been developing and hosting for a Spanish colleague.&lt;br /&gt; &lt;br /&gt;The first step was to enter the code for the text link on the page&lt;br /&gt; &lt;blockquote&gt;&amp;lt;a href="http://www.losarbitroscuentan.com/index.php?page_id=8790" title="Los Arbitros Cuentan - Primera - Click!" id="test-logo"&gt;Primera Division&amp;lt;/a&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;You can see that the &lt;span style="font-weight:bold;"&gt;id&lt;/span&gt; is specified as "test-logo" The page_id (so you go to the correct link) is obtained within Wordpress editor, looking at the pages and pressing right-click, to copy the link location, and then pasting into Notepad - or merely view the URL in your browser.&lt;br /&gt;&lt;br /&gt;Now to allocate that link-text to a graphic, we change the relevant css file. This is normally the style.css but this may change. Also, if you are using a theme, you will need the edit the css file in that theme's folder.&lt;br /&gt;&lt;br /&gt;#test-logo {&lt;br /&gt;     background-image:url(/wp-content/uploads/2010/10/graphicname.jpg);&lt;br /&gt;     display:block;&lt;br /&gt;     height:37px;&lt;br /&gt;     width:190px;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;So far so good, and clicking on the image will take you to your desired screen. Well, each time you save changes to a css file you should reload the webpage, so it replaces the css info in the cache with the updated data. &lt;br /&gt;Looks promising, but the only problem now is we have both text and graphic conflicting with each other!&lt;br /&gt;There is an awesome technique we can use in css/html  - "text-indent" to take the text completely off the screen ie to hide the text&lt;br /&gt;&lt;br /&gt;#test-logo {&lt;br /&gt;     background-image:url(/wp-content/uploads/2010/10/graphicname.jpg);&lt;br /&gt;     display:block;&lt;br /&gt;     height:37px;&lt;br /&gt;     text-indent:-9999px;&lt;br /&gt;     width:190px;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Pretty cool hey? Many thanks to &lt;a href="http://xavisys.com/css-trick-turning-a-background-image-into-a-clickable-link/"&gt;this technical site&lt;/a&gt; for pointing me in the right direction to accomplish this!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-4550301087202116982?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/4550301087202116982/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2010/10/how-to-use-graphic-to-link-elsewhere-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4550301087202116982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4550301087202116982'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2010/10/how-to-use-graphic-to-link-elsewhere-in.html' title='How to use a graphic to link elsewhere in WordPress'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-1727021713795564208</id><published>2010-09-14T03:44:00.000-07:00</published><updated>2010-09-14T03:47:26.989-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Wordpress'/><category scheme='http://www.blogger.com/atom/ns#' term='Drupal'/><title type='text'>Back in town.</title><content type='html'>I've been busy. Moved house (now live in central London). And set up these two websites for a Spanish friend &lt;a href="http://www.anellasl.com/"&gt;Blinds in Spain&lt;/a&gt; and &lt;a href="http://www.losarbitroscuentan.com/"&gt;Referee stats in La Liga&lt;/a&gt;  First one was put together in Drupal and the second one in WordPress.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-1727021713795564208?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/1727021713795564208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2010/09/back-in-town.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1727021713795564208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1727021713795564208'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2010/09/back-in-town.html' title='Back in town.'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-3106463039834809596</id><published>2010-04-17T06:53:00.000-07:00</published><updated>2010-04-17T07:08:32.750-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='ms-access'/><category scheme='http://www.blogger.com/atom/ns#' term='group by'/><title type='text'>Writing a count distinct query in MS Access</title><content type='html'>I had to do this recently in my new job, and was annoyed to find that Access doesn't support the code &lt;blockquote&gt;select columnA, count (distinct columnB) from table group by columnA&lt;/blockquote&gt;&lt;br /&gt;I did a bit of googling around, but wasn't too happy with the workarounds given. Some discussion, with possible solutions are given here:&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/1412442/ms-access-how-can-i-count-distinct-value-using-access-query"&gt;discussion on stackoverflow&lt;/a&gt;&lt;br /&gt;Well to cut a long story short, I devised my own workaround:&lt;br /&gt;&lt;blockquote&gt;select Job,sum(pp) as number_distinct_fruits&lt;br /&gt;&lt;br /&gt;from&lt;br /&gt;&lt;br /&gt;    (select Job, Fruit, 1 as pp&lt;br /&gt;&lt;br /&gt;    from  Jobtable group by Job, Fruit) t&lt;br /&gt;&lt;br /&gt;group by Job&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This was based on data like the following&lt;br /&gt;JobA  Apple&lt;br /&gt;&lt;br /&gt;JobA  Apple&lt;br /&gt;&lt;br /&gt;JobB  Apple&lt;br /&gt; &lt;br /&gt;JobB  Pear&lt;br /&gt;&lt;br /&gt;JobB  Plum&lt;br /&gt;&lt;br /&gt;JobC  Apple&lt;br /&gt;&lt;br /&gt;JobC  Plum&lt;br /&gt; &lt;br /&gt;JobC  Plum&lt;br /&gt; &lt;br /&gt;JobD  Plum&lt;br /&gt; &lt;br /&gt;JobD  Banana&lt;br /&gt; &lt;br /&gt;JobD  Plum&lt;br /&gt; &lt;br /&gt;JobD  Cherry&lt;br /&gt;&lt;br /&gt;The results came out as expected:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Job      Number_distinct_fruits&lt;br /&gt;====     ======================&lt;br /&gt;&lt;br /&gt;JobA     1&lt;br /&gt;&lt;br /&gt;JobB     3&lt;br /&gt;&lt;br /&gt;JobC     2&lt;br /&gt;&lt;br /&gt;JobD     3&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This worked ok on my test data, but there are two things to watch out for. Firstly, the code will produce a grouped record for nul/blank entries in the Fruit field. If you don't want this as part of your count, insert a Where clause (Where Fruit is not null) in the inner select. I also found that the Access editor kept chamging the parenthesis for square brackets, so you may have to keep editing this when opening the query. Even so, it's quite an effective workaround I feel.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-3106463039834809596?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/3106463039834809596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2010/04/writing-count-distinct-query-in-ms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/3106463039834809596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/3106463039834809596'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2010/04/writing-count-distinct-query-in-ms.html' title='Writing a count distinct query in MS Access'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-4145672865460595511</id><published>2009-11-21T02:46:00.000-08:00</published><updated>2009-11-21T03:23:53.435-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><title type='text'>Using Perl and Mysql to create a webpage</title><content type='html'>The normal way to produce a website that accesses data from a Mysql database is via the scripting language PHP. I wondered if it were possible to use Perl instead, and found that with the use of a couple of modules, it's not so hard to get started. (Here's a &lt;a href="http://www.bin-co.com/perl/tutorial/modules.php"&gt;brief introduction&lt;/a&gt; to using modules with web programming.&lt;br /&gt;Here's the Perl I wrote (I called the file empnew.cgi). I made sure the program was executable, and placed the file in a directory on my web server (make sure your path points to this directory):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt; use CGI;&lt;br /&gt; use HTML::Template;&lt;br /&gt;use DBI;&lt;br /&gt;use strict;&lt;br /&gt;&lt;br /&gt;my $dsn = 'dbi:mysql:one:localhost:3306:mysql_socket=/opt/lampp/var/mysql/mysqld.sock';&lt;br /&gt;# the database here is called 'one'&lt;br /&gt;&lt;br /&gt;my $CGI = CGI-&gt;new();&lt;br /&gt;my $user = 'root';&lt;br /&gt;my $pass = 'passwordx';&lt;br /&gt;&lt;br /&gt;my $dbh = DBI-&gt;connect($dsn, $user, $pass)&lt;br /&gt;or die "Can’t connect to the DB: $DBI::errstr\n";&lt;br /&gt;&lt;br /&gt;my $sth = $dbh-&gt;prepare("select empno, ename, job, sal from emp order by ename");&lt;br /&gt;$sth-&gt;execute;&lt;br /&gt;&lt;br /&gt;# Prepare a data structure for HTML::Template&lt;br /&gt;my $rows;&lt;br /&gt;push @{$rows}, $_ while $_ = $sth-&gt;fetchrow_hashref();&lt;br /&gt;&lt;br /&gt; #&lt;br /&gt; # initiate the template and substitute the values:&lt;br /&gt;&lt;br /&gt; my $template = HTML::Template-&gt;new(filename =&gt; 'empnew.tmpl',&lt;br /&gt;     die_on_bad_params =&gt; 0, );&lt;br /&gt; # call param to fill in the loop with the loop data by reference.&lt;br /&gt; $template-&gt;param(ROWS =&gt; $rows);&lt;br /&gt;&lt;br /&gt;print $CGI-&gt;header();&lt;br /&gt; # print the template&lt;br /&gt; print $template-&gt;output();&lt;br /&gt;&lt;br /&gt;$dbh-&gt;disconnect();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The module&lt;strong&gt; CGI &lt;/strong&gt;deals quickly and efficiently with http headers.&lt;br /&gt;&lt;br /&gt;The module&lt;strong&gt; HTML::Template&lt;/strong&gt; that is called, allows you to state the Html layout in a separate file. In our example this calls empnew.tmpl&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- empnew.tmpl --&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;title&amp;gt;Employee Listing&amp;lt;/title&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;h1&amp;gt;Employees&amp;lt;/h1&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;table border=1&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;tr&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;td bgcolor="#ffff00"&amp;gt;&amp;lt;font COLOR="#800500"&amp;gt;&amp;lt;b&amp;gt;Emp Number&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;td bgcolor="#ffff00"&amp;gt;&amp;lt;font COLOR="#800500"&amp;gt;&amp;lt;b&amp;gt;Emp Name&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;td bgcolor="#ffff00"&amp;gt;&amp;lt;font COLOR="#800500"&amp;gt;&amp;lt;b&amp;gt;Job&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;              &amp;lt;td bgcolor="#ffff00"&amp;gt;&amp;lt;font COLOR="#800500"&amp;gt;&amp;lt;b&amp;gt;Salary&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;            &amp;lt;/tr&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- TMPL_LOOP NAME=ROWS --&amp;gt;&lt;br /&gt;&lt;br /&gt;   &amp;lt;tr&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;td&amp;gt;&amp;lt;!-- TMPL_VAR NAME=EMPNO --&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;td&amp;gt;&amp;lt;!-- TMPL_VAR NAME=ENAME --&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;td&amp;gt;&amp;lt;!-- TMPL_VAR NAME=JOB --&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;      &amp;lt;td&amp;gt;&amp;lt;!-- TMPL_VAR NAME=SAL --&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;br /&gt;   &amp;lt;/tr&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- /TMPL_LOOP --&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;There are basically 3 new kinds of tags to be aware of when making a .tmpl file for access by HTML::Template. These are&lt;br /&gt;&lt;br /&gt;# * VARIABLES defined by &amp;lt;tmp_var&amp;gt;&lt;br /&gt;# * LOOPS defined by &amp;lt;tmpl_loop&amp;gt;&lt;br /&gt;# * CONDITIONALS you can use &amp;lt;tmpl_if&amp;gt; &amp;lt;tmpl_unless&amp;gt; or &amp;lt;tmpl_else&amp;gt;&lt;br /&gt;&lt;br /&gt;Variable tags such as &amp;lt;tmpl_var name="FOO"&amp;gt; will be replaced by whatever value is assigned to parameters when calling the HTMP::Template to the parameter FOO&lt;br /&gt;&lt;br /&gt;The other tags can be standard html formatting stuff. Here's a good &lt;a href="http://html-template.sourceforge.net/article.html"&gt;introduction&lt;/a&gt; to using the HTML::Template&lt;br /&gt;&lt;br /&gt;Finally, in order to access data from the Mysql database we need to use the &lt;strong&gt;DBI&lt;/strong&gt; module. You can see from the Perl script that we connect to the database using parameters given (not a good idea from the security pov to have the password in this script in real life - better to bring in as a parameter from a file that can't be seen by public eyes), prepare the sql script, and then execute. For more information on starting with DBI  see &lt;a href="http://www.tizag.com/perlT/perldbiquery.php"&gt; this tutorial&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once this is setup, it's fairly simple to change the layout by editing the tmpl file directly without needing to change the program code.&lt;br /&gt;&lt;br /&gt;Lastly - want to introduce some way of bringing back different results according to a parameter you pass over? Simply modify the previous Perl code as follows ($sal here to be parameter you can change according to your program, the ? serves as a placeholder for this argument passed to the sql execution - this helps stop sql injection as quote characters etc are escaped):&lt;br /&gt;&lt;br /&gt;&lt;code&gt; my $sal = 2900;&lt;br /&gt;  &lt;br /&gt; my $dbh = DBI-&gt;connect($dsn, $user, $pass)&lt;br /&gt;   or die "Can’t connect to the DB: $DBI::errstr\n";&lt;br /&gt;  &lt;br /&gt; my $sth = $dbh-&gt;prepare("select empno, ename, job, sal from emp where sal &gt; ? order by empno");&lt;br /&gt;  my $rc = $sth-&gt;execute($sal);&lt;br /&gt;  &lt;br /&gt;  # Prepare a data structure for HTML::Template&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;I hope this has been of interest! Good luck with your web programming!&lt;br /&gt;&lt;br /&gt;NB. Whilst reproducing this entry I had a little difficulty in getting Blogger to print the HTML source code. There's a conversion utility on &lt;a href="http://www.felgall.com/htmlt47.htm"&gt;this site&lt;/a&gt; that allows you to do this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-4145672865460595511?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/4145672865460595511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/11/using-perl-and-mysql-to-create-webpage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4145672865460595511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4145672865460595511'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/11/using-perl-and-mysql-to-create-webpage.html' title='Using Perl and Mysql to create a webpage'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-589981708218766784</id><published>2009-11-14T09:36:00.000-08:00</published><updated>2009-11-28T05:32:28.366-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Perl'/><category scheme='http://www.blogger.com/atom/ns#' term='snippets'/><title type='text'>Perl snippets</title><content type='html'>I have a bad habit of writing down useful tricks/snippets and then losing the piece of paper. I've decided to start using this entry as a kind of jotter, to be added to at regular intervals. Here we go...&lt;br /&gt;&lt;br /&gt;To take an array that only contains numbers, leave out duplicates and sort in numeric order (the default sort function orders by ASCII value) :&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;my @array = (1, 3,4, 5, 4, 6,7,4, 20 , 21, 20, 19, 19,18);&lt;br /&gt;&lt;br /&gt;       my %hash   = map { $_, 1 } @array;&lt;br /&gt;       # or a hash slice: @hash{ @array } = ();&lt;br /&gt;       # or a foreach: $hash{$_} = 1 foreach ( @array );&lt;br /&gt;&lt;br /&gt;       my @unique = keys %hash;&lt;br /&gt; my @sorted =sort { $a&lt;=&gt;$b; } @unique;&lt;br /&gt;&lt;br /&gt;foreach $item(@sorted) {&lt;br /&gt; print " $item \t";&lt;br /&gt; }&lt;br /&gt;print "\n";&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;To work through lines fed in from a file, ignoring blank lines but outputting the first word of the line otherwise:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;  while (&lt;&gt;) {&lt;br /&gt;    next if /^$/;&lt;br /&gt;    ($primero)=split;&lt;br /&gt;&lt;br /&gt;    {print "Found:  $primero  \n"; }&lt;br /&gt;   }&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;How many elements in an array ? (ok, basic stuff here :) )&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;my @fruits = ("apples", "oranges", "guavas", "passionfruit", "grapes");&lt;br /&gt;&lt;br /&gt;my $last = $#fruits +1;  # ie last element of index +1&lt;br /&gt;&lt;br /&gt;Or simply force the array to a scalar context to find out the number of elements:&lt;br /&gt;&lt;br /&gt;my $last = @fruits;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-589981708218766784?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/589981708218766784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/11/perl-snippets.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/589981708218766784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/589981708218766784'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/11/perl-snippets.html' title='Perl snippets'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-5672800147608359709</id><published>2009-08-31T13:00:00.000-07:00</published><updated>2009-08-31T13:06:17.817-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='prime numbers'/><category scheme='http://www.blogger.com/atom/ns#' term='euler project'/><title type='text'>Using Mysql to find prime factors</title><content type='html'>On my  &lt;a href="http://www.oxfordtechnotes.co.uk/sqlblog"&gt;Mysql blog&lt;/a&gt; I've come up against the poser from the Euler Project : "What is the largest prime factor of the number 600851475143 ".&lt;br /&gt;&lt;br /&gt;I think I've cracked this in Mysql, but I'm not 100% confident (well it works in this case, but will it always work?)&lt;br /&gt;&lt;br /&gt;Anyway, here it is (I use the table Orders only as it contains plenty of rows):&lt;br /&gt;&lt;br /&gt;*** set variables ***&lt;br /&gt;set @var1=2;&lt;br /&gt;set @varreset=2;&lt;br /&gt;set @bignuma= 600851475143;&lt;br /&gt;&lt;br /&gt;*** sql code ***&lt;br /&gt;select a1factor from&lt;br /&gt;(select   &lt;br /&gt;case when mod(@bignuma,@var1) = 0 then @var1:=@varreset else @var1:=@var1+1  end as a1factor, &lt;br /&gt;case when mod(@bignuma,@var1) = 0 then @bignuma:=@bignuma/@var1 end as new_factor&lt;br /&gt; from orders where @var1&lt;@bignuma ) tmp&lt;br /&gt;where new_factor is not null &lt;br /&gt;order by a1factor desc;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-5672800147608359709?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/5672800147608359709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/08/using-mysql-to-find-prime-factors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/5672800147608359709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/5672800147608359709'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/08/using-mysql-to-find-prime-factors.html' title='Using Mysql to find prime factors'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-4988582455339900399</id><published>2009-08-29T01:31:00.000-07:00</published><updated>2009-08-29T01:33:43.498-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='password'/><category scheme='http://www.blogger.com/atom/ns#' term='hash'/><category scheme='http://www.blogger.com/atom/ns#' term='lifehacker'/><category scheme='http://www.blogger.com/atom/ns#' term='security'/><title type='text'>Passwords</title><content type='html'>Something that I find tiresome on many computer systems, is having to remember a password; worse still is when the password has to change after a periodic interval. The temptation is to use a common password across many systems, yet this is very dangerous. Now it may be the case that few systems nowadays store passwords unencrypted (although it's surprising that some still do), but it's often possible to break password security and log into your details. This is something to be aware of when coding. For instance, it's often recommended to store password fields as a hash, so intruders cannot retrieve directly the password even with full access to the database. To test that a user knows the correct password you retrieve the stored hash and then check against the password he/she inputs (after converting this password to a hash). Fairly secure? Well no, hackers have built up lists of hash values (normally on what is known as a rainbow table) and can use brute force to try and log in ie automatically try to log in thousands of times until the correct hash value is found. (Or perhaps they can use common tools like John the Ripper to crack weaker passwords). Salting the hash (prefixing a unique value to the password before hashing) makes security a lot safer (although still not 100%)  - read here &lt;a href="http://www.codinghorror.com/blog/archives/000949.html"&gt;www.codinghorror.com/&lt;/a&gt; ) Any other measures the coder should take? Restrict the number of attempts in one session a visitor can use to enter their password - reading up on the use of captchas is particularly useful here. Ensure that the password is of a minimum length (the longer it is, the harder it is to crack the password); better still enforce the use of non alphabetical characters like numbers or  _ or @ or * within the password. Also (and this is commonly overlooked) restrict the in-company access to that database table. Lastly, and it won't make you popular with users, force the changing of passwords after a certain passage of time.&lt;br /&gt;This all leads to the problem of having to remember your own passwords, especially when they keep changing. I personally write some (although not those relating to bank or email log-ins) down in my diary, suitably disguised. Luckily there are various secure password managers out there for example http://keepass.info/  You can find more choices at &lt;a href="http://lifehacker.com/5042616/five-best-password-managers"&gt;http://lifehacker.com/5042616/five-best-password-managers&lt;/a&gt; - it's also worthwhile searching on Lifehacker using the keyword 'password' to find many useful articles on how to create a strong password, how to be more secure etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-4988582455339900399?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/4988582455339900399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/08/passwords.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4988582455339900399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4988582455339900399'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/08/passwords.html' title='Passwords'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-1631958961813407207</id><published>2009-07-18T13:23:00.000-07:00</published><updated>2009-07-18T13:25:53.816-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Paco de Lucia'/><title type='text'>Well I never..</title><content type='html'>I never knew there was a Guitar-Tube !&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.guitar-tube.com/watch/cositas_buenas_tour2.html"&gt;Paco de Lucia clip&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-1631958961813407207?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/1631958961813407207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/07/well-i-never.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1631958961813407207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1631958961813407207'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/07/well-i-never.html' title='Well I never..'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-5861389317067107443</id><published>2009-07-03T09:05:00.001-07:00</published><updated>2009-07-03T09:07:22.343-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='duplicates'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='excel'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><title type='text'>Duplication versus effort</title><content type='html'>As someone who’s used SQL over many years, I have a habit of importing data into a database whenever I want to list duplicates (or sole entries as opposed to duplicates). Although this is normally easily done in sql (via the Group By clause) it can be a bad habit, as other programs can also accomplish this for you.&lt;br /&gt;For example, if you program in unix or linux, and you want to show unique lines in a file (ie remove duplicate entries), you can use the following command:&lt;br /&gt;sort yrfilename | uniq&lt;br /&gt;That’s not all, you can also use switches to manipulate the data further:&lt;br /&gt;sort yrfilename | uniq –d  # show the duplicate records&lt;br /&gt;sort yrfilename | uniq –u # displays only the nonduplicate entries&lt;br /&gt;sort yrfilename | uniq – c # count for each record&lt;br /&gt;Now not everyone is on a Unix based operating system, but never fear, there are various ways to look for duplicate entries in Excel too (I’d be surprised if there wasn’t an easy way to do it in Powershell either). A useful way to do this on a data set (in more modern versions of Excel) is to choose the Data Menu, then select the Advanced Filter  option.  Here you can either filter the list in-place, or copy to another location (my preferred solution). So long as you select the “Unique records only” option, you lose the duplicate lines. Alternatively you can just select the “Remove Duplicates” menu option in the Data Menu, and you’ll be given the choice of which columns to check for duplicate information.&lt;br /&gt;Incidentally, in older versions of Excel, I would use conditional formatting to show which fields were duplicated (I’d sort the column first). If the entries I were checking were in column A, I’d use something like || Formula Is = countif(A:A, A2) &gt; 1 || and copy down. &lt;br /&gt; I imagine there are lots of different ways of accomplishing the rooting out of duplicate entries (Perl, sed, awk anyone?). I think it’s always good to have an alternative way of achieving what you want – one day the database may be down, or Excel disabled by a virus. The more options you have under your belt the better!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-5861389317067107443?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/5861389317067107443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/07/duplication-versus-effort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/5861389317067107443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/5861389317067107443'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/07/duplication-versus-effort.html' title='Duplication versus effort'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-1346157552697306637</id><published>2009-06-23T13:11:00.000-07:00</published><updated>2009-06-23T13:15:02.596-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='youtube'/><title type='text'>Remember the bankers?</title><content type='html'>This made me laugh...&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.youtube.com/watch?v=nDFETK0JQUI"&gt;youtube clip - Strongbow Bankers&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-1346157552697306637?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/1346157552697306637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/06/remember-bankers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1346157552697306637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/1346157552697306637'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/06/remember-bankers.html' title='Remember the bankers?'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-4293130259432668232</id><published>2009-06-21T07:42:00.000-07:00</published><updated>2009-06-21T07:52:34.601-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Learning from other websites.</title><content type='html'>I already knew how to look at html code on a lot of websites. You press right-click and then select "View Page Source". However, what I didn't realise, was that it's possible in many cases to view the CSS values too (eg how big the font is, what padding and/or margin is used etc.). &lt;a href="http://cybertext.wordpress.com/2008/12/23/view-a-websites-css/"&gt;This page explains&lt;/a&gt; different ways to view a website's CSS. The option I took was to use a firefox add-in provided by &lt;a href="http://chrispederick.com/work/web-developer/"&gt;Chris Pederick at this address&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-4293130259432668232?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/4293130259432668232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/06/learning-from-other-websites.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4293130259432668232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4293130259432668232'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/06/learning-from-other-websites.html' title='Learning from other websites.'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4573350696846475792.post-4687948189507036578</id><published>2009-06-21T02:57:00.000-07:00</published><updated>2009-06-21T03:14:23.409-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='MD5'/><category scheme='http://www.blogger.com/atom/ns#' term='gravatar'/><title type='text'>Using avatars on forums</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_ymeKZIyQhz8/Sj4Hfx9J66I/AAAAAAAAAAU/GTQciZguCZQ/s1600-h/markwavatar.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 80px; height: 80px;" src="http://1.bp.blogspot.com/_ymeKZIyQhz8/Sj4Hfx9J66I/AAAAAAAAAAU/GTQciZguCZQ/s200/markwavatar.png" alt="" id="BLOGGER_PHOTO_ID_5349721649929907106" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_ymeKZIyQhz8/Sj4HSHtzAPI/AAAAAAAAAAM/MNWVhQYUdrI/s1600-h/markwavatar.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 80px; height: 80px;" src="http://4.bp.blogspot.com/_ymeKZIyQhz8/Sj4HSHtzAPI/AAAAAAAAAAM/MNWVhQYUdrI/s320/markwavatar.png" alt="" id="BLOGGER_PHOTO_ID_5349721415252902130" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I spend quite a bit of time (in fact too much) on forums (or should that be fora?). Anyway, I wanted to devise a couple of nice unique avatars for use in mentioned forums. After looking at the way stackoverflow.com produced unique avatars for each user, I was directed to &lt;a href="http://en.gravatar.com/site/implement/"&gt;this site&lt;/a&gt;, that explains how to generate your avatar. Basically you're going to need the MD5 hash of your email address. To get this on linux, you'd enter something like this on the command line:&lt;br /&gt;echo youremail@yahoo.co.uk | md5sum&lt;br /&gt;&lt;br /&gt;This will produce a string of numbers and hexadecimal characters. You can then use on the gravatar site as follows:&lt;br /&gt;&lt;br /&gt;http://www.gravatar.com/avatar/99[various]9f4028c2c.jpg?d=monsterid&lt;br /&gt;OR&lt;br /&gt;http://www.gravatar.com/avatar/99[various]9f4028c2c.jpg?d=identicon&lt;br /&gt;OR&lt;br /&gt;http://www.gravatar.com/avatar/99[various]9f4028c2c.jpg?d=wavatar&lt;br /&gt;&lt;br /&gt;Cool hey?&lt;br /&gt;My wavatar is up above. Sexy hey???&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4573350696846475792-4687948189507036578?l=markfightscode.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://markfightscode.blogspot.com/feeds/4687948189507036578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://markfightscode.blogspot.com/2009/06/using-avatars-on-forums.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4687948189507036578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4573350696846475792/posts/default/4687948189507036578'/><link rel='alternate' type='text/html' href='http://markfightscode.blogspot.com/2009/06/using-avatars-on-forums.html' title='Using avatars on forums'/><author><name>CafeMark</name><uri>http://www.blogger.com/profile/11476420052607732612</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_ymeKZIyQhz8/Sj4Hfx9J66I/AAAAAAAAAAU/GTQciZguCZQ/s72-c/markwavatar.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
