<?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>Snippets | Woody Hayday | Blog</title>
	<atom:link href="https://blog.woodylabs.com/category/code/snippets/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.woodylabs.com</link>
	<description>An exploration of life, technology and writing</description>
	<lastBuildDate>Tue, 13 Jan 2015 15:20:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.woodylabs.com/wp-content/uploads/2015/01/cropped-woody-hayday-yosemite-glacier-point-32x32.jpg</url>
	<title>Snippets | Woody Hayday | Blog</title>
	<link>https://blog.woodylabs.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Hotmail and Character Sets: Make Sure Your Emails Get There</title>
		<link>https://blog.woodylabs.com/2012/09/hotmail-and-character-sets-make-sure-your-emails-get-there/</link>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Wed, 19 Sep 2012 13:18:16 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[hotmail]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[web app prototypes]]></category>
		<category><![CDATA[web dev]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=916</guid>

					<description><![CDATA[<p>It&#8217;s been a hectic few months &#8211; the web development consultancy is going well with several new web app prototypes/platforms released in the last few months, a new plugin (Social Gallery for WordPress) is being well received (and even imitated already!) and amongst all that ChooseFest has had some interesting developments. Also I am now [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2012/09/hotmail-and-character-sets-make-sure-your-emails-get-there/">Hotmail and Character Sets: Make Sure Your Emails Get There</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s been a hectic few months &#8211; the <a href="http://www.stormgate.co.uk/blog/web-developer-for-hire/">web development consultancy</a> is going well with several new web app prototypes/platforms released in the last few months, a new plugin (<a href="http://www.socialgalleryplugin.com">Social Gallery for WordPress</a>) is being well received (and even imitated already!) and amongst all that <a href="http://www.choosefest.com">ChooseFest</a> has had some interesting developments. Also I am now a year older. Anyway enough with the stereotypical excuses for lack of blogging, here&#8217;s a snippet-size-little blog post with a little should-of-been-obvious fix for sending emails out of php in interesting character sets e.g. Japanese, sometimes its the most ridiculously simple stuff that catches you out!</p>
<p style="text-align: left;">Traditional and SMTP emails out of php&#8217;s main mail() function will often be ignored, it seems, by Hotmail (and sometimes yahoo) if the email contains character without specific mention of the correct character set. It&#8217;s irritating as every other carrier seems to just deal with it but Hotmail (and sometimes yahoo) just act like no email ever existed, there&#8217;s no bounce-back, no spam folder message &#8211; just nothing.</p>
<p style="text-align: center;"><img decoding="async" class="aligncenter  wp-image-918" title="Are your web app emails getting to their end destination? Blocked by Hotmail?" src="https://blog.woodylabs.com/wp-content/uploads/2012/09/hotmail-blocking-emails.jpg" alt="" width="162" height="100" /><span id="more-916"></span></p>
<p>In any case, set the header of your email to contain the character set, and if the email your sending is html then make sure you include that in the email body meta, seems obvious but is annoyingly easy to forget.</p>
<p>e.g. Add this line to whatever headers you are using:</p>
<pre class="brush: php; title: ; notranslate">$headers .= &quot;Content-Type: text/html; charset=UTF-8\r\n&quot;;</pre><p>The post <a href="https://blog.woodylabs.com/2012/09/hotmail-and-character-sets-make-sure-your-emails-get-there/">Hotmail and Character Sets: Make Sure Your Emails Get There</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>1and1 Web Hosting &#038; Git &#8211; Installing it for singular dev</title>
		<link>https://blog.woodylabs.com/2012/01/1and1-web-hosting-git-installing-it-for-singular-dev/</link>
					<comments>https://blog.woodylabs.com/2012/01/1and1-web-hosting-git-installing-it-for-singular-dev/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Mon, 16 Jan 2012 15:43:30 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[1and1]]></category>
		<category><![CDATA[ghetto first version]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=833</guid>

					<description><![CDATA[<p>I have a new project in the works and I thought it about time to get a verioning setup working beyond locally, I don&#8217;t want to use a PaaS (like Cloud control) though for this one as its Top Secret (for now.) Yeah Yeah I know, shared web hosting, 1and1 &#8211; not so secret eh? [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2012/01/1and1-web-hosting-git-installing-it-for-singular-dev/">1and1 Web Hosting & Git – Installing it for singular dev</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>I have a new project in the works and I thought it about time to get a verioning setup working beyond locally, I don&#8217;t want to use a PaaS (like Cloud control) though for this one as its Top Secret (for now.) Yeah Yeah I  know, shared web hosting, 1and1 &#8211; not so secret eh? Well behind a .htaccess passworded directory is better than sitting on AWS via a PaaS, it is, believe me.</p>
<p>The benefit of using GIT in the way below is that it maintains version history AS WELL as offering a managed host, i.e. it deals with uploading as well as versioning (in 1 git bash push.)</p>
<p>So here&#8217;s the scenario &#8211; there&#8217;s one of you, or maybe a few core founders/dev&#8217;s and you want to use GIT to version control your developments of a new web app or site. You already have a shared hosting account with 1and1 which works fine up to 20k hits a day or so, is there really need to have the thing scalable on demand from day one? No? Great, read on. If you REQUIRE scalability off the bat (I bet you don&#8217;t, really) then go find a PaaS/jump on AWS, for now here&#8217;s how to get GIT versioning (with automatic publication) working on your 1and1 shared hosting.</p>
<p>Firstly go read <a href="http://toroid.org/ams/git-website-howto" target="_blank" rel="nofollow">this</a>, its a great guide that pretty much* got me there (95% of the credit to Abhijit), there&#8217;s just a few changes to get it to work on 1and1. </p>
<h4>How I did it: GIT on 1and1</h4>
<p>Load up your FTP, get to the root of your hosting and make your main site dir, in this case we will call it AppDev1:<br />
<code>/AppDev1</code><br />
Next make two directories underneath it: &#8220;repo&#8221; and &#8220;live&#8221;, I shall explain these after you have made them:<br />
<code>/AppDev1/live<br />
/AppDev1/repo</code><br />
What these two are going to do is give you a live &#8220;root&#8221; for your web app/site as well as a GIT repository (which stores all the changes.) By separating them you keep everything simple. [live = web root folder, repo (or whatever you call it) = git bare repository.]</p>
<p>Next locally (on your machine) create a folder which you want to develop in:<br />
<code>C:/EpicNewApp</code></p>
<p>&#8230;And load up GIT BASH (assume you have) and enter the following:<br />
<code>cd "C:/EpicNewApp";<br />
git init;</code></p>
<p>Next go ahead and load your SSH client (putty) and log into your 1and1 Account (there is guidance on 1and1 under SSH accounts, if you need it.) Once logged in enter the following:</p>
<p><code>cd "/AppDev1/repo"<br />
git init --bare<br />
cat > hooks/post-receive<br />
#!/bin/sh<br />
GIT_WORK_TREE="../live" git checkout -f<br />
chmod +x hooks/post-receive</code></p>
<p><strong>*note</strong>: This differs from the aforementioned guide in the address entered under GIT_WORK_TREE, this is the only way I could get this setup to work on 1and1.</p>
<p>You can also simply stick these lines into a file called post-receive and upload the file to the &#8220;hooks&#8221; folder of your new bare repository (repo), if you are so inclined. </p>
<p>That&#8217;s it, your done with the SSH, now you can bind a remote location in GIT BASH (replace the obvious:)<br />
<code>$ git remote add web "ssh://u99999999@yourMain1and1Domain.com/~/AppDev1/repo/"</code><br />
&#8230;And go ahead and push to 1and1 (you will need your SSH password to do so.)<br />
<code>$ git push web +master:refs/heads/master</code><br />
All being well this should have pushed a version to your /AppDev1/repo folder and also updated the live files as per your changes!</p>
<p>Happy Ghetto Versioning!</p>
<p><strong>Note</strong>: As per comments, removed .git reference from link, thanks Ano.</p><p>The post <a href="https://blog.woodylabs.com/2012/01/1and1-web-hosting-git-installing-it-for-singular-dev/">1and1 Web Hosting & Git – Installing it for singular dev</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2012/01/1and1-web-hosting-git-installing-it-for-singular-dev/feed/</wfw:commentRss>
			<slash:comments>39</slash:comments>
		
		
			</item>
		<item>
		<title>IP to Location Alternative: Javascript &#8211; Using JS to find Browser Country / Location not from IP</title>
		<link>https://blog.woodylabs.com/2011/12/ip-to-location-alternative-javascript-using-js-to-find-browser-country-location-not-from-ip/</link>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Fri, 02 Dec 2011 09:04:41 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[explorations]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[timezones]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=821</guid>

					<description><![CDATA[<p>Know your audience? Got google analytics aggregating their details? Great, good for you! But doe&#8217;s that add any value in the short term? Improve THEIR browsing experience? In the long run you should use analytics to achieve better sites (although many don&#8217;t) &#8211; but for now, right here you can still add some of the [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/12/ip-to-location-alternative-javascript-using-js-to-find-browser-country-location-not-from-ip/">IP to Location Alternative: Javascript – Using JS to find Browser Country / Location not from IP</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>Know your audience? Got google analytics aggregating their details? Great, good for you! But doe&#8217;s that add any value in the short term? Improve THEIR browsing experience? In the long run you should use analytics to achieve better sites (although many don&#8217;t) &#8211; but for now, right here you can still add some of the future frill. Take this situation: You want to show different content/additional content to each nationalities (maybe aim for a few &#8211; US, UK, AUS) &#8211; Did you know that adding a national flag that a user can associate with may increase sales up to 20%, or More? Go read Ca$hvertising. In any case if your sitting comfortably, take a look below for the how to!</p>
<div align="center"><img fetchpriority="high" decoding="async" src="http://farm1.staticflickr.com/122/303184034_9ac842c4e1.jpg" width="500" height="358" alt="Mars Landers on Map"><br />
Javascript &#8211; Using JS to find Browser Country / Location not from IP <a href="http://www.flickr.com/photos/toasty/303184034/" title="Mars Landers on Map by ToastyKen, on Flickr" rel="nofollow" target="_blank" style="font-size:10px">Photo by ToastyKen</a>
</div>
<p><span id="more-821"></span></p>
<h4>Common solutions to identifying a users locale/localizing/localising a web client:</h4>
<p>Using PHP / ASP.NET take the users IP and feed into an ip to location service (geo ip) to find a country from ip.<br />
<strong>Pro&#8217;s:</strong> Server-side off the bat, can cache a database of IP&#8217;s (although would you?)<br />
<strong>Con&#8217;s:</strong> Adds another 2 hops to at least initial page load, IP location service&#8217;s can cost or be faulty</p>
<p>Using the request headers (again server-side) to identify an &#8220;accepted language&#8221; and then guestimating their location (taking en-US&#8230;for example.)<br />
<strong>Pro&#8217;s:</strong> Server-side to start with, no extra hops/calls required, this data is already available whether you use it or not, more useful for language (although limited)<br />
<strong>Con&#8217;s:</strong> Unreliable &#8211; mostly because of a few of the BIG browsers default to en-US for all english users, often international users might learn to use a browser in English anyway &#8211; defeating the point</p>
<h4>Another solution (work in progress:)</h4>
<p>A step towards a proper solution, and in my case a solution for MY original problem, is to at least work out their TIMEZONE. What? I hear you say, why the timezone? Well if you know, for example using analytics data, that your user base is 40% US, 50% UK and 10% rest of the world you can at least make a START by dealing with the two major constituents of your audience. I can envisage A more complete solution though, by combining the use of request headers accepted language AND the following Javascript timezone detection:</p>
<p>Searching around a bit I found <a href="http://unmissabletokyo.com/country-detector.html" target="_blank" rel="nofollow">this</a> which showed a lot of promise. This javascript works out the users Operating System time offset, and from that you can define which timezone they are in. Useful, if like me you know your users in a specific timezone are likely to be in one country, not particularly if they are possibly in multiple countries within a timezone. </p>
<h4>A solution / exploration &#8211; location detection in javascript</h4>
<p>The following Javascript gives you both indicators, using navigator.language/systemlanguage it detects the browser&#8217;s language, and then using an expanded upon version of the above script it will provide you with the possible countries from the users OS timezone offset. How useful this is to you is depending on the application, but check it out &#8211; build some fantastic solution off of it, then show me, because I probably won&#8217;t get round to it!</p>
<pre class="brush: jscript; title: ; notranslate">
var langCode = navigator.language || navigator.systemLanguage;
var lang = langCode.toLowerCase(); lang = lang.substr(0,2);

var dateObject = new Date(); //this timezone offset calc taken from http://unmissabletokyo.com/country-detector.html
var timeOffset = - dateObject.getTimezoneOffset() / 60; 
var c = &quot;&quot;; //this will ultimately end up as a country/csv of possible countries
switch (timeOffset) { //I expanded upon this switch, adding all the possible countries
	case 0: 
	 c = 'Algeria, Ascension Island, Burkina Faso, Faeroe Islands, Ghana, Guinea Republic, Iceland, Ireland, Ivory Coast, Liberia, Mali, Morocco, Sao Tome &amp; Principe, Senegal, Sierra Leone, St Helena, The Gambia, Togo, United Kingdom'; break;
	
	case 1: 
	 c = 'Albania, Andorra, Angola, Australia, Austria, Belgium, Benin, Bosnia, Cameroon, Central Africa Republic, Chad, Congo, Croatia, Czech Republic, Democratic Republic of Congo (Zaire), Denmark, Equatorial Guinea, France, Gabon, Germany, Gibraltar, Guam, Hungary, Italy, Liechtenstein, Luxembourg, Macedonia (Fyrom), Malta, Mariana Islands, Marshall Islands, Micronesia, Monaco, Netherlands, Niger, Nigeria, Norway, Papua New Guinea, Poland, Portugal, San Marino, Serbia, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, Tunisia'; break;
	 
	case -1: 
	 c = 'Cape Verde Islands, Cook Islands, French Polynesia, Guinea Bissau, USA'; break;
	 
	case 11:	
	 c = 'New Caledonia, Solomon Islands, Vanuatu'; break;
	 
	case -11:
	 c = 'Niue Island, Samoa (American), Samoa (Western), USA'; break;
	 
	case 11.5:
	 c = 'Norfolk Island'; break;
	 
	case 12:	
	 c = 'Fiji Islands, Kiribati, Nauru, New Zealand, Tuvalu, Wallis &amp; Futuna Islands'; break;
	 
	case 13:
	 c = 'Tonga'; break;
	 
	case 2:	
	 c = 'Botswana, Bulgaria, Burundi, Cyprus, Democratic Republic of Congo (Zaire), Egypt, Finland, Greece, Israel, Jordan, Lebanon, Lesotho, Libya, Lithuania, Malawi, Mozambique, Namibia, Palestine, Romania, Rwanda, South Africa, Sudan, Swaziland, Syria, Turkey, Zambia, Zimbabwe'; break;
	 
	case 3:
	 c = 'Bahrain, Belarus, Comoros Island, Djibouti, Eritrea, Estonia, Ethiopia, Iraq, Kenya, Kuwait, latvia, Madagascar, Mayotte Islands, Moldova, Qatar, Russia, Saudi Arabia, Somalia, Tanzania, Uganda, Ukraine, Yemen Arab Republic'; break;
	 
	case -3:
	 c = 'Argentina, Brazil, Cuba, Greenland, Guyana, Uruguay'; break;
	
	case 3.5:
	 c = 'Iran'; break;
	
	case -3.5:
	 c = 'Surinam'; break;
	
	case 4:
	 c = 'Armenia, Azerbaijan, Georgia, Mauritius, Oman, Reunion Island, Seychelles, United Arab Emirates'; break;
	
	case -4:
	 c = 'Anguilla, Antigua and Barbuda, Aruba, Barbados, Bermuda, Bolivia, Brazil, Canada, Chile, Dominica Islands, Dominican Republic, Falkland Islands, French Guiana , Grenada, Guadeloupe, Martinique, Montserrat, Netherlands Antilles, Paraguay, Puerto Rico, St Kitts &amp; Nevia, St Lucia, Trinidad &amp; Tobago, Venezuela'; break;
	
	case 5:
	 c = 'Diego Garcia, Maldives Republic, Pakistan, Turkmenistan'; break;
	
	case -5:
	 c = 'Bahamas, Brazil, Canada, Cayman Islands, Columbia, Ecuador, Haiti, Jamaica, Panama, Peru, Turks &amp; Caicos Islands, USA'; break;
	
	case 5.5:
	 c = 'Bhutan,India,Nepal,Sri Lanka'; break;
	
	case 6:
	 c = 'Bangladesh, Kazakhstan, Kyrgyzstan, Tajikistan, Uzbekistan'; break;
	
	case -6:
	 c = 'Belize, Canada, Costa Rica, El Salvador, Guatemala, Honduras, Mexico, Nicaragua, USA'; break;
	
	case 6.5:
	 c = 'Myanmar (Burma)'; break;
	
	case 7:
	 c = 'Australia, Cambodia, Indonesia, Laos, Thailand, Vietnam'; break;
	
	case -7:
	 c = 'Canada, Mexico, USA'; break;
	
	case 8:
	 c = 'Australia, Brunei, China, Hong Kong, Indonesia, Macau, Malaysia, Mongolia, Philippines, Singapore, Taiwan'; break;
	
	case -8:
	 c = 'Canada, Mexico, USA'; break;
	
	case 9:
	 c = 'Australia, Indonesia, Japan, Korea, North, Korea, South, Palau'; break;
	
	case -9:
	 c = 'USA'; break;
}

//at this point Lang should be a 2 letter language code (e.g. en), timeOffset will be the users hour offset from GMT and c will be the csv of possible countries!
alert('Lang: ' + lang + &quot;\r\n&quot; + 'timeOffset: ' + timeOffset + &quot;\r\n&quot; + 'Possible Countries: ' + &quot;\r\n&quot; + c);
</pre>
<p>You can get the full source for this zipped <a href="https://blog.woodylabs.com/downloads/javascript.timezone.country-detection.zip">here</a>, included is a minified version wrapped in a function, isn&#8217;t that nice of me? Use it as you will, and if you create something epic, show me!</p>
<p><strong>Countries/timezones:</strong> I built the timezone offset switch based on the wikipedia list of countries and their timezones, so its comprehensive.</p><p>The post <a href="https://blog.woodylabs.com/2011/12/ip-to-location-alternative-javascript-using-js-to-find-browser-country-location-not-from-ip/">IP to Location Alternative: Javascript – Using JS to find Browser Country / Location not from IP</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MySQL datetime examples &#8211; first/last day of the year &#8211; dates and unix-times</title>
		<link>https://blog.woodylabs.com/2011/11/mysql-datetime-examples-firstlast-day-of-the-year-dates-and-unix-times/</link>
					<comments>https://blog.woodylabs.com/2011/11/mysql-datetime-examples-firstlast-day-of-the-year-dates-and-unix-times/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Thu, 10 Nov 2011 09:09:22 +0000</pubDate>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Transactional SQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Technology]]></category>
		<category><![CDATA[data schemas]]></category>
		<category><![CDATA[facebook data acquisition]]></category>
		<category><![CDATA[facebook graph api]]></category>
		<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Workbench]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Timestamps]]></category>
		<category><![CDATA[UNIX]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=797</guid>

					<description><![CDATA[<p>For some reason I had an abstract memory of SQL SERVER 2000, timestamps and pain. Who knows why. Perhaps its a faulty memory. lol. Anyhow working with timestamps in MySQL/MSSQL these days is nothing short of simple. With MySQL Workbench free its ridiculous how far the barrier of entry for database design has come, its [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/11/mysql-datetime-examples-firstlast-day-of-the-year-dates-and-unix-times/">MySQL datetime examples – first/last day of the year – dates and unix-times</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>For some reason I had an abstract memory of SQL SERVER 2000, timestamps and pain. Who knows why. Perhaps its a faulty memory. lol. Anyhow working with timestamps in MySQL/MSSQL these days is nothing short of simple. With MySQL Workbench free its ridiculous how far the barrier of entry for database design has come, its now all pleasant schema&#8217;s and error messages that make sense, gone are the days of spending half the time fixing/navigating the database system, they just work now (99% of the time) what a lucky generation of programmers! Anyhow here&#8217;s some datetime examples that you might find useful:</p>
<p>Get last day of last year &#8211; obvious, but still (+1 this for first day):</p>
<pre class="brush: sql; title: ; notranslate">SELECT DATE(CURDATE()- INTERVAL DAYOFYEAR(CURDATE()) DAY);</pre>
<p>And how useful&#8230; FROM_UNIXTIME takes a unix timestamp and makes it a friendly datetime, its like they KNOW I am coding for facebook data acquisition&#8230;Anyhow&#8230;</p>
<p>To make a GMT UNIX time-stamp for the first day of this month:</p>
<pre class="brush: sql; title: ; notranslate">SELECT UNIX_TIMESTAMP(CONVERT_TZ(DATE(CURDATE()- INTERVAL DAYOFMONTH(CURDATE()) DAY), '+0:00', 'SYSTEM'));</pre>
<p>You can switch out the dates obviously, and there are probably other ways, still, mostly pain free.  </p><p>The post <a href="https://blog.woodylabs.com/2011/11/mysql-datetime-examples-firstlast-day-of-the-year-dates-and-unix-times/">MySQL datetime examples – first/last day of the year – dates and unix-times</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2011/11/mysql-datetime-examples-firstlast-day-of-the-year-dates-and-unix-times/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Maintain a CSV with Javascript &#8211; keep a hidden list</title>
		<link>https://blog.woodylabs.com/2011/11/maintain-a-csv-with-javascript-keep-a-hidden-list/</link>
					<comments>https://blog.woodylabs.com/2011/11/maintain-a-csv-with-javascript-keep-a-hidden-list/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Tue, 08 Nov 2011 13:25:20 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[client-side]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ui]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=813</guid>

					<description><![CDATA[<p>The situation: Want to build a comma separated list of int&#8217;s (or whatever) client-side, in javascript, remove/add items on the fly using JS. Well these tiny functions below are what I use, useful when you just need to get a clever form / app input done. Using the below you can add/remove items to an [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/11/maintain-a-csv-with-javascript-keep-a-hidden-list/">Maintain a CSV with Javascript – keep a hidden list</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>The situation: Want to build a comma separated list of int&#8217;s (or whatever) client-side, in javascript, remove/add items on the fly using JS. Well these tiny functions below are what I use, useful when you just need to get a clever form / app input done.</p>
<p>Using the below you can add/remove items to an input which acts as a csv holder, should be self explanatory, get and set are just shorteners.</p>
<pre class="brush: jscript; title: ; notranslate">function get(a){ //small get
	if (typeof a != &quot;undefined&quot;) {
		return document.getElementById(a).value;
	} else { 
		return '';
	}
}

function set(i,v){ //small set
	document.getElementById(i).value = v;	
}

function append(i,v){ //small append
	set(i,get(i) + v);		
}

function appendTocsv(i,v){ //small append csv
	if (get(i).length == 0){
		set(i,v);	
	} else { 
		append(i,', ' + v);
	}
}

function incsv(id,v){ //check a csv (in element with id) for a value (v)
	
	var csv = get(id);
	var csvArray = csv.split(', ');
	var found = false;
	
	if (csvArray.length &gt; 0){
		
		for (i = 0; i &lt;= csvArray.length; i++){
		
			if (csvArray&#x5B;i] == v){ found = true;  }
			
		}
		
	}
	
	return found;
		
}

function removeFromcsv(id,v){ //removes a val from csv
	
	var csv = get(id);
	var csvArray = csv.split(', ');
	var removed = false;
	var endString = &quot;&quot;;
	
	if (csvArray.length &gt; 0){
		
		for (i = 0; i &lt;= csvArray.length-1; i++){
		
				
			if (csvArray&#x5B;i] == v){ removed = true;  } else { 
			
				if (endString.length &gt; 0){ endString += ', '; } 
				endString += csvArray&#x5B;i]; 
			
			}
			
		}
		
	}
	
	set(id,endString);
	
	return removed;
	
}</pre><p>The post <a href="https://blog.woodylabs.com/2011/11/maintain-a-csv-with-javascript-keep-a-hidden-list/">Maintain a CSV with Javascript – keep a hidden list</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2011/11/maintain-a-csv-with-javascript-keep-a-hidden-list/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Unable to drop JQuery sortable onto empty list? Hack solution</title>
		<link>https://blog.woodylabs.com/2011/10/unable-to-drop-jquery-sortable-onto-empty-list-hack-solution/</link>
					<comments>https://blog.woodylabs.com/2011/10/unable-to-drop-jquery-sortable-onto-empty-list-hack-solution/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Thu, 13 Oct 2011 11:34:29 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Sortable]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=789</guid>

					<description><![CDATA[<p>The problem: You have a multi column (or area) JQuery UI Sortable (these are neat) which only needs to show a &#8220;drop zone&#8221; when the user has started to drag a sortable object. The JQuery documentation for this doesn&#8217;t account for the reality of the above, its all very well if you want the empty [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/10/unable-to-drop-jquery-sortable-onto-empty-list-hack-solution/">Unable to drop JQuery sortable onto empty list? Hack solution</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>The problem: You have a multi column (or area) JQuery UI Sortable (these are neat) which only needs to show a &#8220;drop zone&#8221; when the user has started to drag a sortable object.</p>
<p>The JQuery documentation for this doesn&#8217;t account for the reality of the above, its all very well if you want the empty column/div to SHOW all the time as empty, that is remain as some sort of visible placeholder, but if the empty list should show as empty, until an object is ready to be dropped on it then JQuery sortable&#8217;s don&#8217;t work. It all comes down to dimensions, if an empty list exists without a height value, you can&#8217;t drop onto it.</p>
<p>More specifically, if an empty jquery-sortable list exists without a specific height set at the point of [.sortable start] (that is BEFORE the event is fired) then you just cannot drop the sortable.</p>
<div align="center" style="font-size:10px;"><img decoding="async" src="http://farm3.static.flickr.com/2326/2378867408_4cc90791d6.jpg" width="500" height="375" alt="the JavaScript Code"><br />
<a href="http://www.flickr.com/photos/dmitry-baranovskiy/2378867408/" title="the JavaScript Code by Dmitry Baranovskiy, on Flickr">Image by Dmitry Baranovskiy</a></div>
<p>I played with fixing this by adjusting each empty list (in the example belows case #col1,#col2,#col3) to have a defined height (and background, which looks nice) within the sortable &#8220;start&#8221; option, but this just creates boxes (or landing pads/zones) you can see, but not drop on. </p>
<p>Long and short of it &#8211; the solution to being able to drop jquery sortable&#8217;s onto invisible empty lists is to bind a function which adds a css class (or sets the height specifically) to the empty (invisible) sortable list when a user clicks one of the goal objects. This is then fired BEFORE the sortable takes hold and so creates drag-droppable landing zones for the users held sortable. It then uses the sortables &#8220;stop&#8221; property to remove the class it has added to any columns which have it. </p>
<pre class="brush: jscript; title: ; notranslate">
function sortAndDrag() {
    
	//show BEFORE sortable starts
     $(&quot;#col1, #col2, #col3&quot;).bind('click mousedown', function(){
          $(&quot;.col&quot;).each(function (c) {
                if ($(&quot;div&quot;, this).size() == 0) {
                    $(this).addClass(&quot;colZoneEmpty&quot;)
                }
            })
     });
    
	//enable sortable
    $(&quot;#col1, #col2, #col3&quot;).sortable({
        revert: true,
        connectWith: &quot;.col&quot;,
        stop: function (a, d) {
            $(&quot;.col&quot;).removeClass(&quot;colZoneEmpty&quot;);
	    //any ajax processing
        }
    });
	
}
//in this example 3 column div's exist with the id's 'col1','col2','col3', all of which have the class 'col' 
//colZoneEmpty is a css class which makes the empty list visible
</pre>
<p>There are of course improvements you could make here, like checking the users dragging before setting any styling, but this quick hackaround works where it shouldn&#8217;t.</p><p>The post <a href="https://blog.woodylabs.com/2011/10/unable-to-drop-jquery-sortable-onto-empty-list-hack-solution/">Unable to drop JQuery sortable onto empty list? Hack solution</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2011/10/unable-to-drop-jquery-sortable-onto-empty-list-hack-solution/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Remove unwanted eBay strings from A2P [Auction2post] posts with Automated Editor</title>
		<link>https://blog.woodylabs.com/2011/08/remove-unwanted-ebay-strings-from-a2p-auction2post-posts-with-automated-editor/</link>
					<comments>https://blog.woodylabs.com/2011/08/remove-unwanted-ebay-strings-from-a2p-auction2post-posts-with-automated-editor/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 04:58:32 +0000</pubDate>
				<category><![CDATA[Affiliate Marketing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Search Engine Optimisation]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Auction2Post]]></category>
		<category><![CDATA[Automated Editor]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=718</guid>

					<description><![CDATA[<p>Free rules file with this post! Do you use Auction2Post [A2P]? If you don&#8217;t its a wordpress plugin which automatically implants listings from ebay as wordpress posts, including affiliate links through the ebay partner network from which you earn a commission. Its quite useful. Read my post about it here. Anyhow if you don&#8217;t use the [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/08/remove-unwanted-ebay-strings-from-a2p-auction2post-posts-with-automated-editor/">Remove unwanted eBay strings from A2P [Auction2post] posts with Automated Editor</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<h3 style="text-align: right;">Free rules file with this post!</h3>
<p>Do you use <a href="https://blog.woodylabs.com/2009/10/auction-2-post/">Auction2Post</a> [A2P]? If you don&#8217;t its a wordpress plugin which automatically implants listings from ebay as wordpress posts, including affiliate links through the ebay partner network from which you earn a commission. Its quite useful. Read my post about it <a href="https://blog.woodylabs.com/2009/10/auction-2-post/">here</a>. Anyhow if you don&#8217;t use the plugin you can pretty much skip this post, unless you use a similar thing which is generating all kinds of nasty strings you don&#8217;t want in your posts <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>This post will show you how to sanitise your auction2post posts for annoying (and contract breaking) ebay auction strings, it even has 125 rules already in a file for import!</p>
<h3>The problem</h3>
<p>Auction2Post is great in lots of respects, its well written and does a prescribed job. Where it caused irritation for me is arguably after its done its job, after the wordpress plugin had created its posts. You see you can create posts via templates, which is great, it allows enough customisation for most, however I wanted a bit of text processing as often you are left with irritating auction footers and garbage text which make the user hit back or close at a displeasing rate (some of these ebay strings might actually make your Auction 2 posts sites break ebay partner network terms of service, its really worth sanitising your posts as I describe below!)</p>
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;">
<strong>For Example:</strong></p>
<p>My EBAY User ID: yah00002009</p>
<p>welcome to Our ebay Store shop</p>
<p>IF YOU ARE NEW TO EBAY OR DO NOT HAVE A PAY PAL ACCOUNT PLEASE CONTACT ME SO WE CAN HELP MAKE ARRANGEMENTS WITH YOU</p>
</div>
<h3>The Solution</h3>
<p>This problem with Auction 2 Post and wordpress is one of the reasons <a href="http://www.automatededitor.com"  target="_blank">Automated Editor</a> was born, to give a bit more freedom in text processing, wordpress filters are great but I don&#8217;t think filtering hundreds of ebay phrases like that is effective.</p>
<p><span id="more-718"></span></p>
<p>If you want to cleanse your Auction2post posts of dirty ebay auction footers and the like here is how I currently do it:</p>
<ol>
<li>Install Automated Editor plugin on the blog in question. (Get it <a href="http://www.automatededitor.com/launch-offer-save-over-50-percent/" target="_blank">here</a> and install like a normal plugin.)</li>
<li>Go to the plugin (Auto Editor on its plugin menu) and read the disclaimer (big red box) and THEN accept it.</li>
<li>Download the rules file I have created (Get it at the bottom of this post) and unzip it somewhere.
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-726" title="ebay-string-replace-rules-file" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/ebay-string-replace-rules-file.png" alt="" width="96" height="116" /></div>
</li>
<li>Go to &#8220;Import/Export&#8221; on the Automated Editor plugin menu.
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-727" title="using-automated-editor-sidebar" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/using-automated-editor-sidebar.png" alt="" width="156" height="163" /></div>
</li>
<li>Choose the aforementioned rules file and hit import.
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-728" title="automated-editor-and-auction-2-post-importexport" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-and-auction-2-post-importexport.png" alt="" width="498" height="132" srcset="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-and-auction-2-post-importexport.png 498w, https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-and-auction-2-post-importexport-450x119.png 450w" sizes="auto, (max-width: 498px) 100vw, 498px" /></div>
</li>
<li>You should now have 125 or so rules in your rules list <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></li>
<li>Now go to Schedules on the plugin menu and then click Add New.</li>
<li>Scroll down and hit Select All (under the long list of rule checkboxes ebay1, ebay2 etc.)
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-723" title="automated-editor-plugin-ebay-replace-select-all" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-plugin-ebay-replace-select-all.png" alt="" width="355" height="144" /></div>
</li>
<li>Scroll down again and select Most Recent Post from the Target dropdown.</li>
<li>Make sure run option is on &#8220;After a post is published&#8221;.
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-724" title="automated-editor-schedule-for-ebay-phrase-replace" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-schedule-for-ebay-phrase-replace.png" alt="" width="344" height="220" /></div>
</li>
<li>Save it.</li>
<li>Turn on schedules.
<div style="border: 1px solid #09C; background-color: #b5d1ea; padding: 4px; margin: 10px; text-align: center;"><a target="_blank" href="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-automation-turned-on.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-722" title="automated-editor-automation-turned-on-sm" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-automation-turned-on-sm.png" border="0" alt="" width="600" height="190" srcset="https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-automation-turned-on-sm.png 600w, https://blog.woodylabs.com/wp-content/uploads/2011/08/automated-editor-automation-turned-on-sm-450x142.png 450w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></div>
</li>
<li>Post a test post, either via A2P or manually, it should remove any of the 125 annoying (common) ebay auction strings it finds! Sorted.</li>
</ol>
<h4>Notes on this method:</h4>
<ul>
<li>You will need the <a href="http://www.automatededitor.com/compare-versions/" target="_blank">Full version</a> (Ultra Pro) of Automated Editor, the free version is limited to 3 rules and this rules file alone has 125 ebay-string removing rules. It&#8217;s cheap though <a href="http://www.automatededitor.com/launch-offer-save-over-50-percent/" target="_blank">here</a>.</li>
<li>If you already have Auction2Post auction posts in the system you will have to setup a different schedule to operate on those, I usually set this up before I set any automation (it&#8217;s quite easy, just do the same thing and switch out &#8220;Most Recent post&#8221; for &#8220;all posts&#8221;, run it once then disable the schedule &#8211; you don&#8217;t want it operating on them all every time!)</li>
<li>Currently this removes 125 strings I have found previously, mostly from uk auctions, I am considering writing a simplified version of this whole setup, an &#8220;Auction2Post Post Cleaner&#8221; which you can just activate and leave, perhaps with cloud rules, so watch this space. Good thing about the above setup though is you can continually improve your own rules file by adding your own strings.</li>
</ul>
<h3>Rules File</h3>
<div>The link below offers a RAR&#8217;d version of my Automated Editor rules file which contains 125 x ebay string removal rules, yours for free <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Please however do use carefully, as with all automated-editor situations if you don&#8217;t understand what you are doing then don&#8217;t use it, this is for the people that understand the above problem and have the full version of the plugin.</div>
<div align="center"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-726" title="ebay-string-replace-rules-file" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/ebay-string-replace-rules-file.png" alt="" width="96" height="116" /><br />
<br /><a href="https://blog.woodylabs.com/downloads/Woodylabs_AE_Rules_Export_125.rar">Download Rules File</a><br />[Right click-Save as]</div><p>The post <a href="https://blog.woodylabs.com/2011/08/remove-unwanted-ebay-strings-from-a2p-auction2post-posts-with-automated-editor/">Remove unwanted eBay strings from A2P [Auction2post] posts with Automated Editor</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2011/08/remove-unwanted-ebay-strings-from-a2p-auction2post-posts-with-automated-editor/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Facebook Like button not working or showing 0 likes</title>
		<link>https://blog.woodylabs.com/2011/08/facebook-like-button-not-working-or-showing-0-likes/</link>
					<comments>https://blog.woodylabs.com/2011/08/facebook-like-button-not-working-or-showing-0-likes/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Wed, 17 Aug 2011 08:58:27 +0000</pubDate>
				<category><![CDATA[Facebook Pages]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fan page]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=740</guid>

					<description><![CDATA[<p>Got a facebook like button not working showing zero? Do you wan&#8217;t to add a facebook like button to your page that points to a facebook page (fanpage) rather than the page the likebutton is actually on? It is possible but you may have come across this facebook bug that I did. Scenario&#8217;s are either: [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/08/facebook-like-button-not-working-or-showing-0-likes/">Facebook Like button not working or showing 0 likes</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>Got a facebook like button not working showing zero? Do you wan&#8217;t to add a facebook like button to your page that points to a facebook page (fanpage) rather than the page the likebutton is actually on? It is possible but you may have come across this facebook bug that I did.</p>
<div align="center"><img loading="lazy" decoding="async" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/facebook-like-button-0-count-problem-zero-count.png" alt="" title="facebook-like-button-0-count-problem-zero-count" width="203" height="87" class="aligncenter size-full wp-image-743" /></div>
<p>Scenario&#8217;s are either:</p>
<ul>
<li>Use <a href="http://developers.facebook.com/docs/reference/plugins/like/" target="_blank" rel="nofollow">facebook like button generator</a> to generate code for a like button (sometimes even this bugs out..)</li>
<li>Use some service like ShareThis to generate code for a facebook like button</li>
</ul>
<div>And when you stick it on the webpage:</div>
<div>
<ul>
<li>It shows as Zero &#8211; Facebook likes &#8216;0&#8217; even if you know that URL (that you installed it on, or fb page) has likes</li>
<li>It occasionally shows correct like count, but most of the time shows Zero [0] like&#8217;s</li>
</ul>
<div>Investigate with:</div>
<div>
<ul>
<li><a href="http://developers.facebook.com/tools/debug/og/object?q=https://blog.woodylabs.com" target="_blank" rel="nofollow">Facebook Lint tool</a> (object debugger)</li>
</ul>
<div>After spending a few hours working out what was causing this 0 like problem on my facebook like button I narrowed it down to two problems people are experiencing:</div>
<p><span id="more-740"></span></p>
<div>
<ol>
<li>Error in the code you are copying across. It should be an iframe (unless you are using XFBML) like the code shown on the facebook lint tool (object debugger.) In fact the best way I found was to use the object debugger to make the iframe code and then adapt that using parameters from the facebook like button generator as the likebutton generator bugged out for me. MAKE SURE its pointing to the right url, use https if you can and point it to the page which validates in Lint tool.</li>
<li>Page Problems. If your page doesn&#8217;t validate properly in the Lint tool (object debugger) then this is your issue, this is the likely situation if you are seeing it OCCASIONALLY show the right figure in your likes box, but mostly 0 [zero] likes. Page problems as far as I have experienced boil down to:</li>
<ol>
<li>Facebook soft deleting your page and not telling you. If you are experiencing this ZERO likes situation it might well be that facebook has actually discontinued your page without telling you, leaving it on your admin menu&#8217;s and leaving the likes/wall/everything in tact. This is confusing as hell and I wish they would formally tell/make it obvious. Reasons why your page gets deleted? I am sure there are a bunch. I repeat. Your page may look to you to be live, with likes and all &#8211; but if you are experiencing zero likes on your like button it might also be deleted. Get your friend to search for it in the search box, if it doesn&#8217;t appear, you&#8217;ve had it deleted!</li>
<li>Restricted Content. We all love fangating, well its a working economy, but I have a sneaking suspicion it may occasionally cause a discrepancy in like button, potentially pointing a like button to an inaccessible page to the potential like&#8217;ee would mean facebook wouldn&#8217;t be able to access it and therefore show zero (whereas it might be showing you the proper number as you have access..)</li>
</ol>
</ol>
<div align="center"><img loading="lazy" decoding="async" src="https://blog.woodylabs.com/wp-content/uploads/2011/08/facebook-like-button-and-google-plus-one-buttons.png" alt="" title="facebook-like-button-and-google-plus-one-buttons" width="108" height="64" class="aligncenter size-full wp-image-745" /></div>
<div>Anyway, for a nice combo of a facebook like button and a google + button (are these going to be more and more important?) check the following code, don&#8217;t forget to replace your url <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></div>
</div>
<div style="margin-top:20px;margin-bottom:10px">
<pre class="brush: xml; title: ; notranslate">
&lt;div align=&quot;left&quot; style=&quot;height:70px&quot;&gt;
    &lt;div id=&quot;fbbox&quot; style=&quot;float:left;height:65px;width:55px;&quot;&gt;
    	&lt;iframe src=&quot;http://www.facebook.com/plugins/like.php?href=***YOURURL***&amp;layout=box_count&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;height: 65px; width: 55px&quot; allowTransparency=&quot;true&quot;&gt;&lt;/iframe&gt;
    &lt;/div&gt;
    &lt;div id=&quot;gbox&quot; style=&quot;float:left;height:65px;width:55px;&quot;&gt;&lt;g:plusone size=&quot;tall&quot; href=&quot;***YOURURL***&quot;&gt;&lt;/g:plusone&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
</div>
</div>
</div><p>The post <a href="https://blog.woodylabs.com/2011/08/facebook-like-button-not-working-or-showing-0-likes/">Facebook Like button not working or showing 0 likes</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2011/08/facebook-like-button-not-working-or-showing-0-likes/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>get_tag_name function for wordpress</title>
		<link>https://blog.woodylabs.com/2011/07/get_tag_name-function-for-wordpress/</link>
					<comments>https://blog.woodylabs.com/2011/07/get_tag_name-function-for-wordpress/#comments</comments>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Mon, 11 Jul 2011 16:48:04 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=679</guid>

					<description><![CDATA[<p>get_cat_name is a simple useful function to get the category name from its id in wordpress, there isn&#8217;t one for tag (and you cant use the same one&#8230;) so here&#8217;s I adapted it for tags. TBH its super lazy to be using this, but meh. Uses get_term. function get_tag_name( $tag_id ) { $tag_id = (int) [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2011/07/get_tag_name-function-for-wordpress/">get_tag_name function for wordpress</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p><a href="http://codex.wordpress.org/Function_Reference/get_cat_name" rel="nofollow" target="_blank">get_cat_name</a> is a simple useful function to get the category name from its id in wordpress, there isn&#8217;t one for tag (and you cant use the same one&#8230;) so here&#8217;s I adapted it for tags. TBH its super lazy to be using this, but meh. Uses <a href="http://codex.wordpress.org/Function_Reference/get_term" rel="nofollow" target="_blank">get_term</a>.</p>
<pre class="brush: php; title: ; notranslate">
function get_tag_name( $tag_id ) {

     $tag_id = (int) $tag_id;
     $tag = get_term( $tag_id, 'post_tag'; );

     if ( ! $tag || is_wp_error( $tag ) )

          return '';

     return $tag-&gt;name;

}
</pre>
<p>I am writing <a href="http://www.automatededitor.com">Automated Editor</a>, a wordpress plugin which will give you a bunch of pro automation possibilities, in case you were wondering.</p><p>The post <a href="https://blog.woodylabs.com/2011/07/get_tag_name-function-for-wordpress/">get_tag_name function for wordpress</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.woodylabs.com/2011/07/get_tag_name-function-for-wordpress/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>From SQL Server 2008 r2 to SQL Compact Edition. Doing things the wrong way.</title>
		<link>https://blog.woodylabs.com/2010/12/from-sql-server-2008-r2-to-sql-compact-edition-doing-things-the-wrong-way/</link>
		
		<dc:creator><![CDATA[Woody]]></dc:creator>
		<pubDate>Tue, 21 Dec 2010 11:56:59 +0000</pubDate>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Transactional SQL]]></category>
		<guid isPermaLink="false">http://blog.woodylabs.com/?p=451</guid>

					<description><![CDATA[<p>Program written using csharp and SQL Server 2008 r2? Great eh? &#8230; What about your users? &#8230;Doh. Anyway its good to re look at your data layer, so if this crops up and you need to switch to a more portable solution (Compact edition means anyone can use it on windows) then put in the [&#8230;]</p>
<p>The post <a href="https://blog.woodylabs.com/2010/12/from-sql-server-2008-r2-to-sql-compact-edition-doing-things-the-wrong-way/">From SQL Server 2008 r2 to SQL Compact Edition. Doing things the wrong way.</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p><hr /><a href="https://blog.woodylabs.com">Visit Woody Haydays Blog</a><hr />]]></description>
										<content:encoded><![CDATA[<p>Program written using csharp and SQL Server 2008 r2? Great eh? &#8230; What about your users? &#8230;Doh. Anyway its good to re look at your data layer, so if this crops up and you need to switch to a more portable solution (Compact edition means anyone can use it on windows) then put in the time. Heres a few snippets of SQL changes that you will need to deal with in recreating your tables in SQL Compact Edition (moving from full blown SQL server auto scripting)</p>
<ul>
<li>Dont try to SET anything, skip them. ANSI_NULLs, ANSI_PADDING</li>
<li>Replace CURRENT_TIMESTAMP with (getdate()) &#8211; easy to forget this but I always seem to use it as a default.</li>
<li>Keep constraints on line</li>
</ul>
<div align="center"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-452" title="sql-full-to-sql-compact" src="https://blog.woodylabs.com/wp-content/uploads/2010/12/sql-full-to-sql-compact.png" alt="" width="256" height="256" srcset="https://blog.woodylabs.com/wp-content/uploads/2010/12/sql-full-to-sql-compact.png 256w, https://blog.woodylabs.com/wp-content/uploads/2010/12/sql-full-to-sql-compact-250x250.png 250w" sizes="auto, (max-width: 256px) 100vw, 256px" /><br />
Of course if you wrote your tables from scratch in T-SQL it probably wont be a problem.</div><p>The post <a href="https://blog.woodylabs.com/2010/12/from-sql-server-2008-r2-to-sql-compact-edition-doing-things-the-wrong-way/">From SQL Server 2008 r2 to SQL Compact Edition. Doing things the wrong way.</a> first appeared on <a href="https://blog.woodylabs.com">Woody Hayday | Blog</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
